providers/proxy: allow configuring of additional scope mappings for proxy

closes #1255

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-31 22:25:42 +01:00
parent bfc8a56a0b
commit 6036d88392
2 changed files with 35 additions and 2 deletions

View File

@ -138,7 +138,7 @@ class ProxyProvider(OutpostModel, OAuth2Provider):
SCOPE_AK_PROXY,
]
)
self.property_mappings.set(scopes)
self.property_mappings.add(*list(scopes))
self.redirect_uris = _get_callback_url(self.external_host)
def __str__(self):

View File

@ -14,6 +14,7 @@ import {
CryptoApi,
FlowsApi,
FlowsInstancesListDesignationEnum,
PropertymappingsApi,
ProvidersApi,
ProxyMode,
ProxyProvider,
@ -320,7 +321,7 @@ export class ProxyProviderFormPage extends ModelForm<ProxyProvider, number> {
</ak-form-element-horizontal>
<ak-form-group>
<span slot="header"> ${t`Advanced protocol settings`} </span>
<span slot="header">${t`Advanced protocol settings`}</span>
<div slot="body" class="pf-c-form">
<ak-form-element-horizontal label=${t`Certificate`} name="certificate">
<select class="pf-c-form-control">
@ -347,6 +348,38 @@ export class ProxyProviderFormPage extends ModelForm<ProxyProvider, number> {
)}
</select>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Scopes`} name="propertyMappings">
<select class="pf-c-form-control" multiple>
${until(
new PropertymappingsApi(DEFAULT_CONFIG)
.propertymappingsScopeList({
ordering: "scope_name",
})
.then((scopes) => {
return scopes.results.filter((scope) => {
return !scope.managed?.startsWith("goauthentik.io/providers");
}).map((scope) => {
const selected = (this.instance?.propertyMappings || []).some((su) => {
return su == scope.pk;
});
return html`<option
value=${ifDefined(scope.pk)}
?selected=${selected}
>
${scope.name}
</option>`;
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text">
${t`Additional scope mappings, which are passed to the proxy.`}
</p>
<p class="pf-c-form__helper-text">
${t`Hold control/command to select multiple items.`}
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Skip path regex`} name="skipPathRegex">
<textarea class="pf-c-form-control">