Repository navigation
Conversation
|
Thanks for raising this issue. I was planning on refactoring the OAuth2 plugin as I came across some critical issues with the implementation and was planning to fix it anyways within the next couple of days. I'll provide a separate PR fixing the main issues around OAuth2 and making it more robust then you can rebase on this branch and incorporate just the Microsoft provider. Ideally we don't want multiple things being implemented like this in a PR as I prefer to separate things out when it comes to features etc. Looking forward to getting your contribution merged in though. Bear with me in the meantime until I get these fixes in. I'll ping you on this GitHub issue thread here once the fixes are merged in. |
Sounds good. I'll wait for the OAuth2 refactor, then rebase and keep only the Microsoft Entra ID provider. The verified-email requirement for account linking goes into its own PR against your refactored plugin, since it's a separate concern. If your refactor already covers it, say so and I'll drop it rather than duplicate work. Ping me here when the fixes land. |
|
You can now rebase against the |
|
Also make sure to update the title of the PR to something like: "feat: Added Microsoft Entra ID provider to OAuth2 plugin". |
I have already resolved the file conflict. |
Sure, i have changed the title |
|
Can you resubmit this PR under a proper branch because I don't want to merge your main branch into our main branch. Please create a proper branch like so: "feat/microsoft-entra-id-oauth2-provider" and then push it again and open a PR. |
|
I have created the new PR, and i want to close this PR |


Summary
Adds Microsoft (Entra ID v2) as a built-in OAuth2 provider. Microsoft never verifies the
mail/UPN it returns, and a tenant admin can set it to any address. The old callback linked a login to any existing user with the same email, so adding Microsoft as-is would allow account takeover ("nOAuth"). This PR also fixes how the callback picks the user.plugins/oauth2/ ├── plugin.go # + register "microsoft", env MICROSOFT_* (+ optional TENANT_ID) ├── services/ +│ ├── microsoft_provider.go # AzureAD(tenant) endpoint, Graph /v1.0/me, id = oid │ ├── google_provider.go # + EmailVerified from verified_email │ ├── discord_provider.go # + EmailVerified from verified │ └── github_provider.go # + EmailVerified (GitHub only exposes verified emails) ├── types/ │ ├── types.go # + UserInfo.EmailVerified │ └── config.go # + ProviderConfig.TenantID └── usecases/ └── callback_usecase.go # resolveUser()How the callback picks the user now:
Microsoft config:
providers.microsoftMICROSOFT_CLIENT_IDclient_idMICROSOFT_CLIENT_SECRETclient_secretMICROSOFT_TENANT_IDtenant_idTenant defaults to
common. Other values:organizations,consumers, or a tenant ID. Redirect URI is{BaseURL}{BasePath}/oauth2/callback/microsoft.Evidence
UpdateFieldsmatcheduser_idagainst the account ID.After:
go test -race ./...passes. New tests:Merge Danger
Door: two-way, with one sticky choice.
Reverting the code is easy. But Microsoft accounts are stored with the Graph object ID (
oid) asaccount_id. Switching to another identifier later (for example the OIDCsub) would need a data migration.Blast Radius: every OAuth2 login.
resolveUser.email is not verified by <provider>; sign in with your existing method first. Linking from a logged-in session is not implemented yet.email_verifiedfrom the provider instead of alwaystrue. This can affect flows gated on verified email.