web/admin: improve default selection for property-mappings

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-18 14:21:05 +02:00
parent f328b21e89
commit caa5dc1d14
2 changed files with 17 additions and 7 deletions

View File

@ -117,7 +117,7 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
name="redirectUris"> name="redirectUris">
<textarea class="pf-c-form-control">${this.provider?.redirectUris}</textarea> <textarea class="pf-c-form-control">${this.provider?.redirectUris}</textarea>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Valid redirect URLs after a successful authorization flow. Also specify any origins here for CORS Headers.`} ${t`Valid redirect URLs after a successful authorization flow. Also specify any origins here for Implicit flows.`}
</p> </p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
</div> </div>
@ -157,9 +157,14 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
ordering: "scope_name" ordering: "scope_name"
}).then(scopes => { }).then(scopes => {
return scopes.results.map(scope => { return scopes.results.map(scope => {
const selected = Array.from(this.provider?.propertyMappings || []).some(su => { let selected = false;
if (!this.provider?.propertyMappings) {
selected = scope.managed?.startsWith("goauthentik.io/providers/oauth2/scope-") || false;
} else {
selected = Array.from(this.provider?.propertyMappings).some(su => {
return su == scope.pk; return su == scope.pk;
}); });
}
return html`<option value=${ifDefined(scope.pk)} ?selected=${selected}>${scope.name}</option>`; return html`<option value=${ifDefined(scope.pk)} ?selected=${selected}>${scope.name}</option>`;
}); });
}), html`<option>${t`Loading...`}</option>`)} }), html`<option>${t`Loading...`}</option>`)}

View File

@ -154,9 +154,14 @@ export class SAMLProviderFormPage extends Form<SAMLProvider> {
ordering: "saml_name" ordering: "saml_name"
}).then(mappings => { }).then(mappings => {
return mappings.results.map(mapping => { return mappings.results.map(mapping => {
const selected = Array.from(this.provider?.propertyMappings || []).some(su => { let selected = false;
if (!this.provider?.propertyMappings) {
selected = mapping.managed?.startsWith("goauthentik.io/providers/saml") || false;
} else {
selected = Array.from(this.provider?.propertyMappings).some(su => {
return su == mapping.pk; return su == mapping.pk;
}); });
}
return html`<option value=${ifDefined(mapping.pk)} ?selected=${selected}>${mapping.name}</option>`; return html`<option value=${ifDefined(mapping.pk)} ?selected=${selected}>${mapping.name}</option>`;
}); });
}), html`<option>${t`Loading...`}</option>`)} }), html`<option>${t`Loading...`}</option>`)}