Skip to content

Commit

Permalink
feat: add redirectUrl to OAuthMicrosoftConfig for HTTP vs HTTPS Han…
Browse files Browse the repository at this point in the history
…dling
  • Loading branch information
andreagroferreira authored Apr 3, 2024
1 parent 00c8287 commit 50ba6fe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/runtime/server/lib/oauth/microsoft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export interface OAuthMicrosoftConfig {
* @see https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
*/
authorizationParams?: Record<string, string>
/**
* Redirect URL to prevent in prod prevent redirect_uri mismatch http to https
* @default process.env.NUXT_OAUTH_MICROSOFT_REDIRECT_URL
* @see https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
*/
redirectUrl?: string
}

interface OAuthConfig {
Expand Down Expand Up @@ -78,7 +84,7 @@ export function microsoftEventHandler({ config, onSuccess, onError }: OAuthConfi
const authorizationURL = config.authorizationURL || `https://login.microsoftonline.com/${config.tenant}/oauth2/v2.0/authorize`
const tokenURL = config.tokenURL || `https://login.microsoftonline.com/${config.tenant}/oauth2/v2.0/token`

const redirectUrl = getRequestURL(event).href
const redirectUrl = config.redirectUrl || getRequestURL(event).href
if (!code) {

const scope = config.scope && config.scope.length > 0 ? config.scope : ['User.Read']
Expand Down

0 comments on commit 50ba6fe

Please sign in to comment.