show dropdown if issuer has list of algorithms

This commit is contained in:
apocer 2024-04-09 22:29:06 +02:00
parent 304d0f6d43
commit f75f0b8cc8
2 changed files with 21 additions and 3 deletions

View File

@ -58,7 +58,8 @@
<ui-text-input-with-label ref="openidClientSecret" v-model="newAuthSettings.authOpenIDClientSecret" :disabled="savingSettings" :label="'Client Secret'" class="mb-2" /> <ui-text-input-with-label ref="openidClientSecret" v-model="newAuthSettings.authOpenIDClientSecret" :disabled="savingSettings" :label="'Client Secret'" class="mb-2" />
<ui-text-input-with-label ref="openidTokenSigningAlgorithm" v-model="newAuthSettings.authOpenIDTokenSigningAlgorithm" :disabled="savingSettings" :label="'Signing Algorithm'" class="mb-2" /> <ui-dropdown v-if="hasSupportedSigningAlgorithms" v-model="newAuthSettings.authOpenIDTokenSigningAlgorithm" :items="openIdSigningAlgorithmsSupportedByIssuer" :label="'Signing Algorithm'" :disabled="savingSettings" class="mb-2" />
<ui-text-input-with-label v-else ref="openidTokenSigningAlgorithm" v-model="newAuthSettings.authOpenIDTokenSigningAlgorithm" :disabled="savingSettings" :label="'Signing Algorithm'" class="mb-2" />
<ui-multi-select ref="redirectUris" v-model="newAuthSettings.authOpenIDMobileRedirectURIs" :items="newAuthSettings.authOpenIDMobileRedirectURIs" :label="$strings.LabelMobileRedirectURIs" class="mb-2" :menuDisabled="true" :disabled="savingSettings" /> <ui-multi-select ref="redirectUris" v-model="newAuthSettings.authOpenIDMobileRedirectURIs" :items="newAuthSettings.authOpenIDMobileRedirectURIs" :label="$strings.LabelMobileRedirectURIs" class="mb-2" :menuDisabled="true" :disabled="savingSettings" />
<p class="sm:pl-4 text-sm text-gray-300 mb-2" v-html="$strings.LabelMobileRedirectURIsDescription" /> <p class="sm:pl-4 text-sm text-gray-300 mb-2" v-html="$strings.LabelMobileRedirectURIsDescription" />
@ -140,6 +141,7 @@ export default {
enableOpenIDAuth: false, enableOpenIDAuth: false,
showCustomLoginMessage: false, showCustomLoginMessage: false,
savingSettings: false, savingSettings: false,
openIdSigningAlgorithmsSupportedByIssuer: [],
newAuthSettings: {} newAuthSettings: {}
} }
}, },
@ -162,6 +164,9 @@ export default {
value: 'username' value: 'username'
} }
] ]
},
hasSupportedSigningAlgorithms() {
return this.openIdSigningAlgorithmsSupportedByIssuer.length > 0
} }
}, },
methods: { methods: {
@ -180,6 +185,19 @@ export default {
this.newAuthSettings.authOpenIDIssuerURL = this.newAuthSettings.authOpenIDIssuerURL.replace('/.well-known/openid-configuration', '') this.newAuthSettings.authOpenIDIssuerURL = this.newAuthSettings.authOpenIDIssuerURL.replace('/.well-known/openid-configuration', '')
} }
const setSupportedSigningAlgorithms = (algorithms) => {
this.openIdSigningAlgorithmsSupportedByIssuer = algorithms
if(!algorithms || algorithms.length === 0) return
// If a signing algorithm is already selected, then keep it, when it is still supported.
// But if it is not supported, then select one of the supported ones.
let currentAlgorithm = this.newAuthSettings.authOpenIDTokenSigningAlgorithm
if(!algorithms.includes(currentAlgorithm)) {
this.newAuthSettings.authOpenIDTokenSigningAlgorithm = algorithms[0]
}
}
this.$axios this.$axios
.$get(`/auth/openid/config?issuer=${issuerUrl}`) .$get(`/auth/openid/config?issuer=${issuerUrl}`)
.then((data) => { .then((data) => {
@ -189,7 +207,7 @@ export default {
if (data.userinfo_endpoint) this.newAuthSettings.authOpenIDUserInfoURL = data.userinfo_endpoint if (data.userinfo_endpoint) this.newAuthSettings.authOpenIDUserInfoURL = data.userinfo_endpoint
if (data.end_session_endpoint) this.newAuthSettings.authOpenIDLogoutURL = data.end_session_endpoint if (data.end_session_endpoint) this.newAuthSettings.authOpenIDLogoutURL = data.end_session_endpoint
if (data.jwks_uri) this.newAuthSettings.authOpenIDJwksURL = data.jwks_uri if (data.jwks_uri) this.newAuthSettings.authOpenIDJwksURL = data.jwks_uri
if (data.id_token_signing_algorithm) this.newAuthSettings.authOpenIDTokenSigningAlgorithm = data.id_token_signing_algorithm if (data.id_token_signing_alg_values_supported) setSupportedSigningAlgorithms(data.id_token_signing_alg_values_supported)
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to receive data', error) console.error('Failed to receive data', error)

View File

@ -652,7 +652,7 @@ class Auth {
userinfo_endpoint: data.userinfo_endpoint, userinfo_endpoint: data.userinfo_endpoint,
end_session_endpoint: data.end_session_endpoint, end_session_endpoint: data.end_session_endpoint,
jwks_uri: data.jwks_uri, jwks_uri: data.jwks_uri,
id_token_signing_algorithm: data.id_token_signing_alg_values_supported?.[0] id_token_signing_alg_values_supported: data.id_token_signing_alg_values_supported
}) })
}).catch((error) => { }).catch((error) => {
Logger.error(`[Auth] Failed to get openid configuration at "${configUrl}"`, error) Logger.error(`[Auth] Failed to get openid configuration at "${configUrl}"`, error)