web/admin/providers/oauth2: only show client secret when clientType is not public

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-03 14:52:12 +02:00
parent aaa1f92945
commit 82c2a202cb
2 changed files with 17 additions and 1 deletions

View File

@ -66,6 +66,10 @@ export class OutpostForm extends Form<Outpost> {
});
}), html``)}
</select>
<p class="pf-c-form__helper-text">${gettext("Selecting a service-connection enables the management of the outpost by authentik.")}</p>
<p class="pf-c-form__helper-text">
See <a _target="blank" href="https://goauthentik.io/docs/outposts/outposts">documentation</a>.
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${gettext("Providers")}

View File

@ -18,12 +18,16 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
id: value,
}).then(provider => {
this.provider = provider;
this.showClientSecret = provider.clientType === OAuth2ProviderClientTypeEnum.Confidential;
});
}
@property({attribute: false})
provider?: OAuth2Provider;
@property({type: Boolean})
showClientSecret = true;
getSuccessMessage(): string {
if (this.provider) {
return gettext("Successfully updated provider.");
@ -79,7 +83,14 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
label=${gettext("Client type")}
?required=${true}
name="clientType">
<select class="pf-c-form-control">
<select class="pf-c-form-control" @change=${(ev: Event) => {
const target = ev.target as HTMLSelectElement;
if (target.selectedOptions[0].value === OAuth2ProviderClientTypeEnum.Public) {
this.showClientSecret = false;
} else {
this.showClientSecret = true;
}
}}>
<option value=${OAuth2ProviderClientTypeEnum.Confidential} ?selected=${this.provider?.clientType === OAuth2ProviderClientTypeEnum.Confidential}>
${gettext("Confidential")}
</option>
@ -96,6 +107,7 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
<input type="text" value="${first(this.provider?.clientId, randomString(40))}" class="pf-c-form-control" required>
</ak-form-element-horizontal>
<ak-form-element-horizontal
?hidden=${!this.showClientSecret}
label=${gettext("Client Secret")}
name="clientSecret">
<input type="text" value="${first(this.provider?.clientSecret, randomString(128))}" class="pf-c-form-control">