Merged in feat/SW-3639-autologin-sas (pull request #3245)
Feat/SW-3639 autologin sas * wip * cleanup * remove commented code and default lang to EN Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -115,6 +115,7 @@ const config: NextAuthConfig = {
|
||||
async signIn() {
|
||||
return true
|
||||
},
|
||||
|
||||
async jwt(params) {
|
||||
if (params.trigger === "signIn") {
|
||||
const accessToken = params.account?.access_token
|
||||
@@ -187,34 +188,45 @@ const config: NextAuthConfig = {
|
||||
}
|
||||
},
|
||||
async redirect({ baseUrl, url }) {
|
||||
authLogger.debug(`[auth] deciding redirect URL`, { baseUrl, url })
|
||||
authLogger.debug(`[redirect callback] deciding redirect URL`, {
|
||||
baseUrl,
|
||||
url,
|
||||
})
|
||||
if (url.startsWith("/")) {
|
||||
authLogger.debug(
|
||||
`[auth] relative URL accepted, returning: ${baseUrl}${url}`
|
||||
`[redirect callback] relative URL accepted, returning: ${baseUrl}${url}`
|
||||
)
|
||||
// Allows relative callback URLs
|
||||
return `${baseUrl}${url}`
|
||||
} else {
|
||||
// Assume absolute URL
|
||||
try {
|
||||
const parsedUrl = new URL(url)
|
||||
if (parsedUrl.hostname.endsWith(".scandichotels.com")) {
|
||||
authLogger.debug(`[auth] subdomain URL accepted, returning: ${url}`)
|
||||
// Allows any subdomains on all top level domains above
|
||||
return url
|
||||
} else if (parsedUrl.origin === baseUrl) {
|
||||
// Allows callback URLs on the same origin
|
||||
authLogger.debug(`[auth] origin URL accepted, returning: ${url}`)
|
||||
return url
|
||||
}
|
||||
} catch (e) {
|
||||
authLogger.error(
|
||||
`[auth] error parsing incoming URL for redirection`,
|
||||
e
|
||||
)
|
||||
}
|
||||
}
|
||||
authLogger.debug(`[auth] URL denied, returning base URL: ${baseUrl}`)
|
||||
|
||||
// Assume absolute URL
|
||||
try {
|
||||
const parsedUrl = new URL(url)
|
||||
if (parsedUrl.hostname.endsWith(".scandichotels.com")) {
|
||||
authLogger.debug(
|
||||
`[redirect callback] subdomain URL accepted, returning: ${url}`
|
||||
)
|
||||
// Allows any subdomains on all top level domains above
|
||||
return url
|
||||
}
|
||||
|
||||
if (parsedUrl.origin === baseUrl) {
|
||||
// Allows callback URLs on the same origin
|
||||
authLogger.debug(
|
||||
`[redirect callback] origin URL accepted, returning: ${url}`
|
||||
)
|
||||
return url
|
||||
}
|
||||
} catch (e) {
|
||||
authLogger.error(
|
||||
`[redirect callback] error parsing incoming URL for redirection`,
|
||||
e
|
||||
)
|
||||
}
|
||||
authLogger.debug(
|
||||
`[redirect callback] URL denied, returning base URL: ${baseUrl}`
|
||||
)
|
||||
|
||||
return baseUrl
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user