* web: Add InvalidationFlow to Radius Provider dialogues
## What
- Bugfix: adds the InvalidationFlow to the Radius Provider dialogues
- Repairs: `{"invalidation_flow":["This field is required."]}` message, which was *not* propagated
to the Notification.
- Nitpick: Pretties `?foo=${true}` expressions: `s/\?([^=]+)=\$\{true\}/\1/`
## Note
Yes, I know I'm going to have to do more magic when we harmonize the forms, and no, I didn't add the
Property Mappings to the wizard, and yes, I know I'm going to have pain with the *new* version of
the wizard. But this is a serious bug; you can't make Radius servers with *either* of the current
dialogues at the moment.
* This (temporary) change is needed to prevent the unit tests from failing.
\# What
\# Why
\# How
\# Designs
\# Test Steps
\# Other Notes
* Revert "This (temporary) change is needed to prevent the unit tests from failing."
This reverts commit dddde09be5.
* web: Update to OpenAPI 7.11.
This commit updates our Makefile to generate the Typescript api using OpenAPI 7.11, and updates
names (mostly of enum targets) in our product to correspond to the changes in how OpenAPI generates
enum source names.
1. Replaced `ProviderModelEnum.` (note terminal period) with `ProviderModelEnum.AuthentikProvider`.
For example:
```
- ProviderModelEnum.SamlSamlprovider
+ ProviderModelEnum.AuthentikProvidersSamlSamlprovider
```
2. Replaced `RbacPermissionsAssignedByUsersListModelEnum.` (note terminal period) with
`RbacPermissionsAssignedByUsersListModelEnum.Authentik`. For example:
```
- RbacPermissionsAssignedByUsersListModelEnum.ProvidersLdapLdapprovider.toString(),
+ RbacPermissionsAssignedByUsersListModelEnum.AuthentikProvidersLdapLdapprovider.toString(),
```
3. Replaced `SyncObjectModelEnum.` (note terminal period) with
`SyncObjectModelEnum.AuthentikCoreModels`. For example:
```
- model=${SyncObjectModelEnum.Group}
+ model=${SyncObjectModelEnum.AuthentikCoreModelsGroup}
```
4. Replaced `SignatureAlgorithmEnum._` (note terminal symbols) with
`SignatureAlgorithmEnum.HttpWwwW3Org`. For example:
```
- ["ECDSA-SHA256", SignatureAlgorithmEnum._200104XmldsigMoreecdsaSha256],
+ ["ECDSA-SHA256", SignatureAlgorithmEnum.HttpWwwW3Org200104XmldsigMoreecdsaSha256],
```
5. Replaced `DigestAlgorithmEnum._` (note terminal symbols) with `DigestAlgorithmEnum.HttpWwwW3Org`.
For example:
```
- ["SHA256", DigestAlgorithmEnum._200104Xmlencsha256, true],
+ ["SHA256", DigestAlgorithmEnum.HttpWwwW3Org200104Xmlencsha256, true],
```
6. Replaced `NameIdPolicyEnum._` (note terminal symbols) with
`NameIdPolicyEnum.UrnOasisNamesTcSaml`. This one is trickier than the others: If you look
closely, you'll see that how OpenAPI generates the names has changed, with `nameid` now being
`Nameid`, and `FormatemailAddress` now being `FormatEmailAddress`.
```
- value=${NameIdPolicyEnum._11nameidFormatemailAddress}
+ value=${NameIdPolicyEnum.UrnOasisNamesTcSaml11NameidFormatEmailAddress}
```
# How
After determining how the enum prefixes had changed, I just ran six of these, testing after each
step to ensure that `npm run lint:types` had fewer errors than the previous run, until the product
built without type errors.
``` sh
$ perl -pi.bak -e 's/DigestAlgorithmEnum\._/DigestAlgorithmEnum.HttpWwwW3Org/' $(rg -l 'DigestAlgorithmEnum\.' src/)
```
# Testing
You can validate that these items have changed by finding the prefixes in the source code and
assuring yourself that every option, checkbox, or radio associated with them is populated correctly.
# User documentation changes required.
None.
# Developer documentation changes required.
None.
198 lines
7.7 KiB
TypeScript
198 lines
7.7 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { first } from "@goauthentik/common/utils";
|
|
import "@goauthentik/elements/CodeMirror";
|
|
import { CodeMirrorMode } from "@goauthentik/elements/CodeMirror";
|
|
import { Form } from "@goauthentik/elements/forms/Form";
|
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
|
import "@goauthentik/elements/forms/SearchSelect";
|
|
import YAML from "yaml";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { TemplateResult, html, nothing } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
|
import {
|
|
CoreApi,
|
|
CoreGroupsListRequest,
|
|
CoreUsersListRequest,
|
|
Group,
|
|
PropertyMapping,
|
|
PropertyMappingTestRequest,
|
|
PropertyMappingTestResult,
|
|
PropertymappingsApi,
|
|
RbacPermissionsAssignedByUsersListModelEnum,
|
|
User,
|
|
} from "@goauthentik/api";
|
|
|
|
@customElement("ak-property-mapping-test-form")
|
|
export class PolicyTestForm extends Form<PropertyMappingTestRequest> {
|
|
@property({ attribute: false })
|
|
mapping?: PropertyMapping;
|
|
|
|
@property({ attribute: false })
|
|
result?: PropertyMappingTestResult;
|
|
|
|
@property({ attribute: false })
|
|
request?: PropertyMappingTestRequest;
|
|
|
|
getSuccessMessage(): string {
|
|
return msg("Successfully sent test-request.");
|
|
}
|
|
|
|
async send(data: PropertyMappingTestRequest): Promise<PropertyMappingTestResult> {
|
|
this.request = data;
|
|
const result = await new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllTestCreate({
|
|
pmUuid: this.mapping?.pk || "",
|
|
propertyMappingTestRequest: data,
|
|
formatResult: true,
|
|
});
|
|
return (this.result = result);
|
|
}
|
|
|
|
renderResult(): TemplateResult {
|
|
return html`<ak-form-element-horizontal label=${msg("Result")}>
|
|
${this.result?.successful
|
|
? html`<ak-codemirror
|
|
mode=${CodeMirrorMode.JavaScript}
|
|
?readOnly=${true}
|
|
value="${ifDefined(this.result?.result)}"
|
|
>
|
|
</ak-codemirror>`
|
|
: html` <div class="pf-c-form__group-label">
|
|
<div class="c-form__horizontal-group">
|
|
<span class="pf-c-form__label-text">
|
|
<pre>${this.result?.result}</pre>
|
|
</span>
|
|
</div>
|
|
</div>`}
|
|
</ak-form-element-horizontal>`;
|
|
}
|
|
|
|
renderExampleButtons() {
|
|
return this.mapping?.metaModelName ===
|
|
RbacPermissionsAssignedByUsersListModelEnum.AuthentikSourcesLdapLdapsourcepropertymapping
|
|
? html`<p>${msg("Example context data")}</p>
|
|
${this.renderExampleLDAP()}`
|
|
: nothing;
|
|
}
|
|
|
|
renderExampleLDAP(): TemplateResult {
|
|
return html`
|
|
<button
|
|
class="pf-c-button pf-m-secondary"
|
|
role="button"
|
|
@click=${() => {
|
|
this.request = {
|
|
user: this.request?.user || 0,
|
|
context: {
|
|
ldap: {
|
|
displayName: "authentik test user",
|
|
distinguishedName: "cn=user,ou=users,dc=goauthentik,dc=io",
|
|
givenName: "test",
|
|
name: "test-user",
|
|
objectClass: "person",
|
|
objectSid: "S-1-5-21-2611707862-2219215769-354220275-1137",
|
|
sAMAccountName: "sAMAccountName",
|
|
sn: "user",
|
|
},
|
|
},
|
|
};
|
|
}}
|
|
>
|
|
${msg("Active Directory User")}
|
|
</button>
|
|
<button
|
|
class="pf-c-button pf-m-secondary"
|
|
role="button"
|
|
@click=${() => {
|
|
this.request = {
|
|
user: this.request?.user || 0,
|
|
context: {
|
|
ldap: {
|
|
name: "test-group",
|
|
objectSid: "S-1-5-21-2611707862-2219215769-354220275-1137",
|
|
objectClass: "group",
|
|
distinguishedName: "cn=group,ou=groups,dc=goauthentik,dc=io",
|
|
},
|
|
},
|
|
};
|
|
}}
|
|
>
|
|
${msg("Active Directory Group")}
|
|
</button>
|
|
`;
|
|
}
|
|
|
|
renderForm(): TemplateResult {
|
|
return html`<ak-form-element-horizontal label=${msg("User")} name="user">
|
|
<ak-search-select
|
|
blankable
|
|
.fetchObjects=${async (query?: string): Promise<User[]> => {
|
|
const args: CoreUsersListRequest = {
|
|
ordering: "username",
|
|
};
|
|
if (query !== undefined) {
|
|
args.search = query;
|
|
}
|
|
const users = await new CoreApi(DEFAULT_CONFIG).coreUsersList(args);
|
|
return users.results;
|
|
}}
|
|
.renderElement=${(user: User): string => {
|
|
return user.username;
|
|
}}
|
|
.renderDescription=${(user: User): TemplateResult => {
|
|
return html`${user.name}`;
|
|
}}
|
|
.value=${(user: User | undefined): number | undefined => {
|
|
return user?.pk;
|
|
}}
|
|
.selected=${(user: User): boolean => {
|
|
return this.request?.user?.toString() === user.pk.toString();
|
|
}}
|
|
>
|
|
</ak-search-select>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("Group")} name="group">
|
|
<ak-search-select
|
|
blankable
|
|
.fetchObjects=${async (query?: string): Promise<Group[]> => {
|
|
const args: CoreGroupsListRequest = {
|
|
ordering: "name",
|
|
};
|
|
if (query !== undefined) {
|
|
args.search = query;
|
|
}
|
|
const groups = await new CoreApi(DEFAULT_CONFIG).coreGroupsList(args);
|
|
return groups.results;
|
|
}}
|
|
.renderElement=${(group: Group): string => {
|
|
return group.name;
|
|
}}
|
|
.value=${(group: Group | undefined): string | undefined => {
|
|
return group?.pk;
|
|
}}
|
|
.selected=${(group: Group): boolean => {
|
|
return this.request?.group?.toString() === group.pk.toString();
|
|
}}
|
|
>
|
|
</ak-search-select>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("Context")} name="context">
|
|
<ak-codemirror
|
|
mode=${CodeMirrorMode.YAML}
|
|
value=${YAML.stringify(first(this.request?.context, {}))}
|
|
>
|
|
</ak-codemirror>
|
|
<p class="pf-c-form__helper-text">${this.renderExampleButtons()}</p>
|
|
</ak-form-element-horizontal>
|
|
${this.result ? this.renderResult() : html``}`;
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-property-mapping-test-form": PolicyTestForm;
|
|
}
|
|
}
|