feat: support MOG_TENANT_ID env var for single-tenant Azure AD apps#14
Open
MrtyMfly-85 wants to merge 1 commit into
Open
feat: support MOG_TENANT_ID env var for single-tenant Azure AD apps#14MrtyMfly-85 wants to merge 1 commit into
MrtyMfly-85 wants to merge 1 commit into
Conversation
Adds initAuthURL() that reads MOG_TENANT_ID environment variable to construct the OAuth2 endpoint URL. Falls back to /common/ when not set, maintaining backward compatibility. This enables mogcli to work with single-tenant Azure AD app registrations, which require tenant-specific OAuth endpoints instead of the /common/ multi-tenant endpoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mogcli hardcodes the
/common/OAuth2 endpoint, which doesn't work with single-tenant Azure AD app registrations. Single-tenant apps require the tenant-specific endpoint (/\{tenant-id\}/oauth2/v2.0), otherwise Azure returns:This affects any M365 Business user whose admin registers a single-tenant app (a common security practice).
Solution
Adds an
initAuthURL()function that reads theMOG_TENANT_IDenvironment variable. If set, it constructs the tenant-specific OAuth endpoint. If not set, it falls back to/common/— so existing behavior is completely unchanged.Usage
Changes
internal/graph/client.go: Replace hardcodedAuthURLwithinitAuthURL()that readsMOG_TENANT_IDenv var (11 lines changed)Fully backward compatible. No new dependencies.