-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
web/admin: Improve WS-Fed algo selection logic (cherry-pick #20881 to version-2026.2) #21438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
63338f4
1d18ee7
e9e8021
5af82c1
2e564b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { ApplicationWizardProviderForm } from "./ApplicationWizardProviderForm.j | |
| import { type AkCryptoCertificateSearch } from "#admin/common/ak-crypto-certificate-search"; | ||
| import { renderForm } from "#admin/providers/wsfed/WSFederationProviderFormForm"; | ||
|
|
||
| import { type WSFederationProvider } from "@goauthentik/api"; | ||
| import { KeyTypeEnum, type WSFederationProvider } from "@goauthentik/api"; | ||
|
|
||
| import { msg } from "@lit/localize"; | ||
| import { customElement, state } from "@lit/reactive-element/decorators.js"; | ||
|
|
@@ -19,11 +19,15 @@ export class ApplicationWizardProviderWSFedForm extends ApplicationWizardProvide | |
| @state() | ||
| protected hasSigningKp = false; | ||
|
|
||
| @state() | ||
| protected signingKeyType: KeyTypeEnum | null = null; | ||
|
|
||
| renderForm() { | ||
| const setHasSigningKp = (ev: InputEvent) => { | ||
| const target = ev.target as AkCryptoCertificateSearch; | ||
| if (!target) return; | ||
| this.hasSigningKp = !!target.selectedKeypair; | ||
| this.signingKeyType = target.selectedKeypair?.keyType ?? KeyTypeEnum.Rsa; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This expression appears three different times, in three different Forms. If the default ever changes, someone's gonna miss one. I wonder if there's a way to extract this and put it somewhere safe. |
||
| }; | ||
|
|
||
| return html` <ak-wizard-title>${this.label}</ak-wizard-title> | ||
|
|
@@ -33,6 +37,7 @@ export class ApplicationWizardProviderWSFedForm extends ApplicationWizardProvide | |
| errors: this.wizard.errors?.provider, | ||
| setHasSigningKp, | ||
| hasSigningKp: this.hasSigningKp, | ||
| signingKeyType: this.signingKeyType, | ||
| })} | ||
| </form>`; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import "#elements/utils/TimeDeltaHelp"; | |
| import { propertyMappingsProvider, propertyMappingsSelector } from "./SAMLProviderFormHelpers.js"; | ||
| import { | ||
| availableHashes, | ||
| DEFAULT_HASH_ALGORITHM, | ||
| digestAlgorithmOptions, | ||
| retrieveSignatureAlgorithm, | ||
| SAMLSupportedKeyTypes, | ||
|
|
@@ -525,7 +526,8 @@ export function renderForm({ | |
| <option | ||
| value=${algorithmValue} | ||
| ?selected=${provider?.signatureAlgorithm === algorithmValue || | ||
| (!isCurrentAlgorithmAvailable && hash === "SHA256")} | ||
| (!isCurrentAlgorithmAvailable && | ||
| hash === DEFAULT_HASH_ALGORITHM)} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you touched it, maybe you can fix an issue here: |
||
| > | ||
| ${hash} | ||
| </option> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ import { DEFAULT_CONFIG } from "#common/api/config"; | |
| import AkCryptoCertificateSearch from "#admin/common/ak-crypto-certificate-search"; | ||
| import { BaseProviderForm } from "#admin/providers/BaseProviderForm"; | ||
|
|
||
| import { ProvidersApi, WSFederationProvider } from "@goauthentik/api"; | ||
| import { KeyTypeEnum, ProvidersApi, WSFederationProvider } from "@goauthentik/api"; | ||
|
|
||
| import { html, TemplateResult } from "lit"; | ||
| import { customElement, state } from "lit/decorators.js"; | ||
|
|
@@ -17,6 +17,9 @@ export class WSFederationProviderForm extends BaseProviderForm<WSFederationProvi | |
| @state() | ||
| protected hasSigningKp = false; | ||
|
|
||
| @state() | ||
| protected signingKeyType: KeyTypeEnum | null = null; | ||
|
|
||
| async loadInstance(pk: number): Promise<WSFederationProvider> { | ||
| const provider = await new ProvidersApi(DEFAULT_CONFIG).providersWsfedRetrieve({ | ||
| id: pk, | ||
|
|
@@ -42,12 +45,14 @@ export class WSFederationProviderForm extends BaseProviderForm<WSFederationProvi | |
| const target = ev.target as AkCryptoCertificateSearch; | ||
| if (!target) return; | ||
| this.hasSigningKp = !!target.selectedKeypair; | ||
| this.signingKeyType = target.selectedKeypair?.keyType ?? KeyTypeEnum.Rsa; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 47 echoes Line 27. Is there a reason line 48 has no equivalent setter in |
||
| }; | ||
|
|
||
| return html`${renderForm({ | ||
| provider: this.instance ?? {}, | ||
| setHasSigningKp, | ||
| hasSigningKp: this.hasSigningKp, | ||
| signingKeyType: this.signingKeyType, | ||
| })}`; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider putting a typeguard function here.
InputEventis very generic; checking that the source really is anAkCryptoCertificateSearchmight catch someone using this wrong.