diff --git a/web/.eslintrc.precommit.json b/web/.eslintrc.precommit.json
new file mode 100644
index 0000000000..6e81348788
--- /dev/null
+++ b/web/.eslintrc.precommit.json
@@ -0,0 +1,30 @@
+{
+ "env": {
+ "browser": true,
+ "es2021": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:@typescript-eslint/recommended",
+ "plugin:lit/recommended",
+ "plugin:custom-elements/recommended",
+ "plugin:storybook/recommended",
+ "plugin:sonarjs/recommended"
+ ],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "ecmaVersion": 12,
+ "sourceType": "module"
+ },
+ "plugins": ["@typescript-eslint", "lit", "custom-elements", "sonarjs"],
+ "rules": {
+ "indent": "off",
+ "linebreak-style": ["error", "unix"],
+ "quotes": ["error", "double", { "avoidEscape": true }],
+ "semi": ["error", "always"],
+ "@typescript-eslint/ban-ts-comment": "off",
+ "sonarjs/cognitive-complexity": ["warn", 9],
+ "sonarjs/no-duplicate-string": "off",
+ "sonarjs/no-nested-template-literals": "off"
+ }
+}
diff --git a/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts b/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts
index b87d43fd5a..df6116ecb1 100644
--- a/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts
+++ b/web/src/admin/applications/wizard/methods/oauth/ak-application-wizard-authentication-by-oauth.ts
@@ -1,16 +1,17 @@
import "@goauthentik/admin/applications/wizard/ak-wizard-title";
import "@goauthentik/admin/common/ak-crypto-certificate-search";
import "@goauthentik/admin/common/ak-flow-search/ak-branded-flow-search";
+import {
+ makeOAuth2PropertyMappingsSelector,
+ oauth2PropertyMappingsProvider,
+} from "@goauthentik/admin/providers/oauth2/OAuth2PropertyMappings.js";
import {
clientTypeOptions,
issuerModeOptions,
redirectUriHelp,
subjectModeOptions,
} from "@goauthentik/admin/providers/oauth2/OAuth2ProviderForm";
-import {
- makeOAuth2PropertyMappingsSelector,
- oauth2PropertyMappingsProvider,
-} from "@goauthentik/admin/providers/oauth2/Oauth2PropertyMappings.js";
+import { oauth2SourcesProvider } from "@goauthentik/admin/providers/oauth2/OAuth2Sources.js";
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { ascii_letters, digits, first, randomString } from "@goauthentik/common/utils";
import "@goauthentik/components/ak-number-input";
@@ -262,24 +263,17 @@ export class ApplicationWizardAuthenticationByOauth extends BaseProviderPanel {
name="jwksSources"
.errorMessages=${errors?.jwksSources ?? []}
>
-
+
${msg( "JWTs signed by certificates configured in the selected sources can be used to authenticate to this provider.", )}
-- ${msg("Hold control/command to select multiple items.")} -
diff --git a/web/src/admin/applications/wizard/methods/proxy/AuthenticationByProxyPage.ts b/web/src/admin/applications/wizard/methods/proxy/AuthenticationByProxyPage.ts index 05d45f6c86..36058f9d7d 100644 --- a/web/src/admin/applications/wizard/methods/proxy/AuthenticationByProxyPage.ts +++ b/web/src/admin/applications/wizard/methods/proxy/AuthenticationByProxyPage.ts @@ -1,4 +1,5 @@ import "@goauthentik/admin/applications/wizard/ak-wizard-title"; +import { oauth2SourcesProvider } from "@goauthentik/admin/providers/oauth2/OAuth2Sources.js"; import { makeProxyPropertyMappingsSelector, proxyPropertyMappingsProvider, @@ -10,6 +11,7 @@ import "@goauthentik/components/ak-text-input"; import "@goauthentik/components/ak-textarea-input"; import "@goauthentik/components/ak-toggle-group"; import "@goauthentik/elements/ak-dual-select/ak-dual-select-dynamic-selected-provider.js"; +import "@goauthentik/elements/ak-dual-select/ak-dual-select-provider.js"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { msg } from "@lit/localize"; @@ -226,26 +228,17 @@ export class AkTypeProxyApplicationWizardPage extends BaseProviderPanel { name="jwksSources" .errorMessages=${errors?.jwksSources ?? []} > - +${msg( "JWTs signed by certificates configured in the selected sources can be used to authenticate to this provider.", )}
-- ${msg("Hold control/command to select multiple items.")} -
diff --git a/web/src/admin/applications/wizard/methods/saml/ak-application-wizard-authentication-by-saml-configuration.ts b/web/src/admin/applications/wizard/methods/saml/ak-application-wizard-authentication-by-saml-configuration.ts index f2947a0381..403398bf37 100644 --- a/web/src/admin/applications/wizard/methods/saml/ak-application-wizard-authentication-by-saml-configuration.ts +++ b/web/src/admin/applications/wizard/methods/saml/ak-application-wizard-authentication-by-saml-configuration.ts @@ -266,11 +266,8 @@ export class ApplicationWizardProviderSamlConfiguration extends BaseProviderPane .options=${propertyPairs} .values=${pmValues} .richhelp=${html`- ${msg("Property mappings used for user mapping.")} -
-- ${msg("Hold control/command to select multiple items.")} -
`} + ${msg("Property mappings used for user mapping.")} + `} >${msg("Property mappings used for user mapping.")}
-- ${msg("Hold control/command to select multiple items.")} -
`} + `} >${msg("Property mappings used for group creation.")}
-- ${msg("Hold control/command to select multiple items.")} -
`} + `} >${msg( "Select which transports should be used to notify the user. If none are selected, the notification will only be shown in the authentik UI.", )}
-- ${msg("Hold control/command to select multiple items.")} -
${msg("Property mappings used to user mapping.")}
-- ${msg("Hold control/command to select multiple items.")} -
${msg("Property mappings used to group creation.")}
-- ${msg("Hold control/command to select multiple items.")} -
${msg("Property mappings used to user mapping.")}
-- ${msg("Hold control/command to select multiple items.")} -
${msg("Property mappings used to group creation.")}
-- ${msg("Hold control/command to select multiple items.")} -
${msg( "JWTs signed by certificates configured in the selected sources can be used to authenticate to this provider.", )}
-- ${msg("Hold control/command to select multiple items.")} -
`; diff --git a/web/src/admin/providers/oauth2/OAuth2Sources.ts b/web/src/admin/providers/oauth2/OAuth2Sources.ts new file mode 100644 index 0000000000..4adc6dd425 --- /dev/null +++ b/web/src/admin/providers/oauth2/OAuth2Sources.ts @@ -0,0 +1,21 @@ +import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; + +import { SourcesApi } from "@goauthentik/api"; + +export async function oauth2SourcesProvider(page = 1, search = "") { + const oauthSources = await new SourcesApi(DEFAULT_CONFIG).sourcesOauthList({ + ordering: "name", + hasJwks: true, + pageSize: 20, + search: search.trim(), + page, + }); + + return { + pagination: oauthSources.pagination, + options: oauthSources.results.map((source) => [ + source.pk, + `${source.name} (${source.slug})`, + ]), + }; +} diff --git a/web/src/admin/providers/proxy/ProxyProviderForm.ts b/web/src/admin/providers/proxy/ProxyProviderForm.ts index 86c4c5ba64..1e741fb1c8 100644 --- a/web/src/admin/providers/proxy/ProxyProviderForm.ts +++ b/web/src/admin/providers/proxy/ProxyProviderForm.ts @@ -1,10 +1,12 @@ import "@goauthentik/admin/common/ak-crypto-certificate-search"; import "@goauthentik/admin/common/ak-flow-search/ak-flow-search"; import { BaseProviderForm } from "@goauthentik/admin/providers/BaseProviderForm"; +import { oauth2SourcesProvider } from "@goauthentik/admin/providers/oauth2/OAuth2Sources.js"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; import "@goauthentik/components/ak-toggle-group"; import "@goauthentik/elements/ak-dual-select/ak-dual-select-dynamic-selected-provider.js"; +import "@goauthentik/elements/ak-dual-select/ak-dual-select-provider.js"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/SearchSelect"; @@ -21,11 +23,9 @@ import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css"; import { FlowsInstancesListDesignationEnum, - PaginatedOAuthSourceList, ProvidersApi, ProxyMode, ProxyProvider, - SourcesApi, } from "@goauthentik/api"; import { @@ -48,15 +48,6 @@ export class ProxyProviderFormPage extends BaseProviderForm${msg( "JWTs signed by certificates configured in the selected sources can be used to authenticate to this provider.", )}
-- ${msg("Hold control/command to select multiple items.")} -
`; diff --git a/web/src/admin/providers/radius/RadiusProviderForm.ts b/web/src/admin/providers/radius/RadiusProviderForm.ts index bb689d161e..9beb0e115f 100644 --- a/web/src/admin/providers/radius/RadiusProviderForm.ts +++ b/web/src/admin/providers/radius/RadiusProviderForm.ts @@ -159,9 +159,6 @@ export class RadiusProviderFormPage extends WithBrandConfig(BaseProviderForm- ${msg("Hold control/command to select multiple items.")} -
`; diff --git a/web/src/admin/sources/ldap/LDAPSourceForm.ts b/web/src/admin/sources/ldap/LDAPSourceForm.ts index 7ab4929018..3004abec19 100644 --- a/web/src/admin/sources/ldap/LDAPSourceForm.ts +++ b/web/src/admin/sources/ldap/LDAPSourceForm.ts @@ -34,6 +34,7 @@ async function propertyMappingsProvider(page = 1, search = "") { search: search.trim(), page, }); + return { pagination: propertyMappings.pagination, options: propertyMappings.results.map((m) => [m.pk, m.name, m.name, m]), diff --git a/web/src/admin/sources/plex/PlexSourceForm.ts b/web/src/admin/sources/plex/PlexSourceForm.ts index 4a01823af2..347954b76a 100644 --- a/web/src/admin/sources/plex/PlexSourceForm.ts +++ b/web/src/admin/sources/plex/PlexSourceForm.ts @@ -13,6 +13,8 @@ import { WithCapabilitiesConfig, } from "@goauthentik/elements/Interface/capabilitiesProvider"; import "@goauthentik/elements/ak-dual-select/ak-dual-select-dynamic-selected-provider.js"; +import "@goauthentik/elements/ak-dual-select/ak-dual-select-dynamic-selected-provider.js"; +import "@goauthentik/elements/ak-dual-select/ak-dual-select-provider.js"; import { DualSelectPair } from "@goauthentik/elements/ak-dual-select/types.js"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; @@ -194,9 +196,6 @@ export class PlexSourceForm extends WithCapabilitiesConfig(BaseSourceForm- ${msg("Hold control/command to select multiple items.")} -
`; } diff --git a/web/src/admin/stages/authenticator_validate/AuthenticatorValidateStageForm.ts b/web/src/admin/stages/authenticator_validate/AuthenticatorValidateStageForm.ts index bd35b02674..ff438f6963 100644 --- a/web/src/admin/stages/authenticator_validate/AuthenticatorValidateStageForm.ts +++ b/web/src/admin/stages/authenticator_validate/AuthenticatorValidateStageForm.ts @@ -3,7 +3,6 @@ import { deviceTypeRestrictionPair } from "@goauthentik/admin/stages/authenticat import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import "@goauthentik/elements/Alert"; import "@goauthentik/elements/ak-dual-select/ak-dual-select-provider"; -import { DataProvision } from "@goauthentik/elements/ak-dual-select/types"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/Radio"; @@ -23,6 +22,35 @@ import { UserVerificationEnum, } from "@goauthentik/api"; +async function stagesProvider(page = 1, search = "") { + const stages = await new StagesApi(DEFAULT_CONFIG).stagesAllList({ + ordering: "name", + pageSize: 20, + search: search.trim(), + page, + }); + + return { + pagination: stages.pagination, + options: stages.results.map((stage) => [stage.pk, `${stage.name} (${stage.verboseName})`]), + }; +} + +async function authenticatorWebauthnDeviceTypesListProvider(page = 1, search = "") { + const devicetypes = await new StagesApi( + DEFAULT_CONFIG, + ).stagesAuthenticatorWebauthnDeviceTypesList({ + pageSize: 20, + search: search.trim(), + page, + }); + + return { + pagination: devicetypes.pagination, + options: devicetypes.results.map(deviceTypeRestrictionPair), + }; +} + @customElement("ak-stage-authenticator-validate-form") export class AuthenticatorValidateStageForm extends BaseStageForm
${msg(
"Stages used to configure Authenticator when user doesn't have any compatible devices. After this configuration Stage passes, the user is not prompted again.",
@@ -242,19 +263,7 @@ export class AuthenticatorValidateStageForm extends BaseStageForm
${msg(
"Select sources should be shown for users to authenticate with. This only affects web-based sources, not LDAP.",
)}
- ${msg("Hold control/command to select multiple items.")}
-
${msg(
"Selected policies are executed when the stage is submitted to validate the data.",
)}
- ${msg("Hold control/command to select multiple items.")}
-