Azure AD inconsistencies #2690
-
I've tried to use Auzre AD auth form the next(version 4.0.0-beta.2) branch and came across some inconsistencies that it'd like to share. Azure setup is for accounts withing organization only, i.e no personal user accounts are permitted. Implicit and hybrid flows are disabled. API/Permissions configured like that: Essentially it's a setup with default options and additional permissions. So lets take example from the doc providers: [
AzureADProvider({
clientId: process.env.AZURE_CLIENT_ID,
clientSecret: process.env.AZURE_CLIENT_SECRET,
tenantId: process.env.AZURE_TENANT_ID,
scope: 'offline_access User.Read',
}),
], The result is Once that been done auth request url is
That's an interesting one, according to this discussion https://github.com/MicrosoftDocs/azure-docs/issues/28317 https://graph.microsoft.com/v1.0/me/ endpoint does not have sub property. The only endpoint that have that sub property is https://graph.microsoft.com/oidc/userinfo but its format is incompatible with the format that's used in the provider profile parser. It uses email, name etc in opposite to displayName, userPrincipalName on the me endpoint. Changing user info endpoint https://graph.microsoft.com/oidc/userinfo and updating profile callback makes it work. So the final look is something like return {
id: "azure-ad",
name: "Azure Active Directory",
type: "oauth",
scope: 'https://graph.microsoft.com/user.read',
authorization: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/authorize?response_mode=query&scope=openid User.Read`,
token: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`,
userinfo: "https://graph.microsoft.com/oidc/userinfo",
profile(profile) {
return {
id: profile.email,
name: profile.name,
email: profile.email,
image: profile.picture,
};
},
options
}; While working on this post I've started getting another error So can anyone confirm that next version Azuer AD works fine and what's your configuration? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
Unfortunately, I/we cannot confirm each and every Provider config as stated in #2524 There are just so many, so we kind of rely on the community to help us migrate them. Most of the providers have never been tested since they have been added, so it is highly likely, that some of them may have never even worked... 👀 |
Beta Was this translation helpful? Give feedback.
-
Here is mine. I gave up trying to use the built-in module. So I just call the below. const tenant = 'common' //or put in your tenant
providers: [{
id: "azure-ad",
name: "Azure Active Directory",
type: "oauth",
authorization: { // *** CHANGED ***
url: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/authorize?response_mode=query`,
params: {
scope: 'openid email profile user.read offline_access'
}
},
token: `https://login.microsoftonline.com/${tenant}/oauth2/v2.0/token`,
userinfo: "https://graph.microsoft.com/oidc/userinfo", /**** CHANGED ****/
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture
}
},
options: {
clientId: '*** UPDATE *****',
clientSecret: '*** UPDATE *****',
}
}] |
Beta Was this translation helpful? Give feedback.
-
thanks for addressing this guys, i ran into the same issue this morning when upgrading to v4. i ended up figuring this out on my own and wish i had found this thread sooner! however, there are some concerns that i still have with this solution: a) there is no user ID returned anymore when using the new /userinfo endpoint. i feel like this is important to have, especially when you might need to do user-specific operations with an API. and according to the docs, you cannot extend this payload: https://docs.microsoft.com/en-us/azure/active-directory/develop/userinfo#notes-and-caveats-on-the-userinfo-endpoint b) i'm still only seeing the |
Beta Was this translation helpful? Give feedback.
-
Azure AD is fixed now, see: #2524 (comment) |
Beta Was this translation helpful? Give feedback.
Azure AD is fixed now, see: #2524 (comment)