import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { docLink } from "@goauthentik/common/global"; import "@goauthentik/elements/CodeMirror"; import { CodeMirrorMode } from "@goauthentik/elements/CodeMirror"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { msg } from "@lit/localize"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { PropertymappingsApi, SAMLPropertyMapping } from "@goauthentik/api"; @customElement("ak-property-mapping-saml-form") export class PropertyMappingSAMLForm extends ModelForm { loadInstance(pk: string): Promise { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlRetrieve({ pmUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return msg("Successfully updated mapping."); } else { return msg("Successfully created mapping."); } } async send(data: SAMLPropertyMapping): Promise { if (this.instance) { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlUpdate({ pmUuid: this.instance.pk || "", sAMLPropertyMappingRequest: data, }); } else { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsSamlCreate({ sAMLPropertyMappingRequest: data, }); } } renderForm(): TemplateResult { return html`

${msg( "Attribute name used for SAML Assertions. Can be a URN OID, a schema reference, or a any other string. If this property mapping is used for NameID Property, this field is discarded.", )}

${msg("Optionally set the 'FriendlyName' value of the Assertion attribute.")}

${msg("Expression using Python.")} ${msg("See documentation for a list of all variables.")}

`; } }