Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure AD Authentication with Next.js and Prisma #445

Closed
wants to merge 4 commits into from

Conversation

mvthul
Copy link

@mvthul mvthul commented Jun 19, 2024

Al that is needed are the following environment variables:
AZURE_AD_CLIENT_ID=
AZURE_AD_CLIENT_SECRET=
AZURE_AD_TENANT_ID=
ALLOW_DANGEROUS_EMAIL_LINKING=true (Somehow it doesnt work without this)
OAUTH_EXCLUSIVE_LOGIN=true (Shows only Sign in with Azure AD button)

mvthul and others added 2 commits June 19, 2024 17:19
Al that is needed are the following environment variables:
AZURE_AD_CLIENT_ID=
AZURE_AD_CLIENT_SECRET=
AZURE_AD_TENANT_ID=
ALLOW_DANGEROUS_EMAIL_LINKING=true (Somehow it doesnt work without this)
OAUTH_EXCLUSIVE_LOGIN=true (Shows only Sign in with Azure AD button)
Copy link
Owner

@sinamics sinamics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation needs to be updated as well.

.devcontainer/init-cmd.sh Outdated Show resolved Hide resolved
Comment on lines +62 to 64
"expires_in" INTEGER,
"ext_expires_in" INTEGER,
"token_type" TEXT,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these really neccessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these really neccessary?

I can try without but seems necessary according to documentation next auth.

Comment on lines 111 to 142
// {
// id: 'azure-ad',
// name: 'Azure Active Directory',
// type: 'oauth',
// version: '2.0',
// authorization: { params: { scope: "openid profile user.Read email" } },
// accessTokenUrl: 'https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/token',
// authorizationUrl: 'https://login.microsoftonline.com/{tenantID}/oauth2/v2.0/authorize',
// clientId: process.env.AZURE_AD_CLIENT_ID,
// clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
// },
AzureADProvider({
// id: "azure-ad",
// name: "Active Directory Azure AD ",
// checks: ["state", "pkce"],
// authorization: { params: { scope: "openid profile user.Read email" } },
allowDangerousEmailAccountLinking:
Boolean(process.env.ALLOW_DANGEROUS_EMAIL_LINKING) || true,
clientId: process.env.AZURE_AD_CLIENT_ID,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AZURE_AD_TENANT_ID,
profile(profile) {
return Promise.resolve({
id: profile.sub || profile.id.toString(), // Handle ID based on provider
name: profile.name || profile.login || profile.username,
email: profile.email,
image: profile.picture || profile.avatar_url || profile.image_url || profile.image,
role: "USER",
});
},
}),
CredentialsProvider({
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all unused code.
also, i would prefer if we could incorporate this into the custom oauth adapter. I dont want to add code for all providers out there.

@@ -26,6 +26,7 @@ chmod +x /usr/local/bin/ztmkworld
# apply migrations to the database
echo "Applying migrations to the database..."
npx prisma migrate deploy
# npm install && npm run dev
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

@mvthul mvthul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the files

@sinamics
Copy link
Owner

sinamics commented Aug 9, 2024

Added azure oauth to the generic provider. #483

@sinamics sinamics closed this Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants