web: full web components part 1 (#4964)
* migrate loading Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate api browser Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate base css Signed-off-by: Jens Langhammer <jens@goauthentik.io> * move tenant fetching to base interface Signed-off-by: Jens Langhammer <jens@goauthentik.io> * import pre-loaded stages in flow interface and not executor to strip down executor size Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix redirect and such Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -12,17 +12,7 @@ import { Interface } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/LoadingOverlay";
|
||||
import "@goauthentik/flow/stages/FlowErrorStage";
|
||||
import "@goauthentik/flow/stages/RedirectStage";
|
||||
import "@goauthentik/flow/stages/access_denied/AccessDeniedStage";
|
||||
// Import webauthn-related stages to prevent issues on safari
|
||||
// Which is overly sensitive to allowing things only in the context of a
|
||||
// user interaction
|
||||
import "@goauthentik/flow/stages/authenticator_validate/AuthenticatorValidateStage";
|
||||
import "@goauthentik/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage";
|
||||
import "@goauthentik/flow/stages/autosubmit/AutosubmitStage";
|
||||
import { StageHost } from "@goauthentik/flow/stages/base";
|
||||
import "@goauthentik/flow/stages/captcha/CaptchaStage";
|
||||
import "@goauthentik/flow/stages/identification/IdentificationStage";
|
||||
import "@goauthentik/flow/stages/password/PasswordStage";
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
@ -43,7 +33,6 @@ import {
|
||||
ChallengeChoices,
|
||||
ChallengeTypes,
|
||||
ContextualFlowInfo,
|
||||
CurrentTenant,
|
||||
FlowChallengeResponseRequest,
|
||||
FlowErrorChallenge,
|
||||
FlowsApi,
|
||||
@ -92,9 +81,6 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
@property({ type: Boolean })
|
||||
loading = false;
|
||||
|
||||
@property({ attribute: false })
|
||||
tenant!: CurrentTenant;
|
||||
|
||||
@state()
|
||||
inspectorOpen = false;
|
||||
|
||||
@ -186,7 +172,6 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
this.addEventListener(EVENT_FLOW_INSPECTOR_TOGGLE, () => {
|
||||
this.inspectorOpen = !this.inspectorOpen;
|
||||
});
|
||||
tenant().then((tenant) => (this.tenant = tenant));
|
||||
}
|
||||
|
||||
async getTheme(): Promise<UiThemeEnum> {
|
||||
@ -283,25 +268,25 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
async renderChallengeNativeElement(): Promise<TemplateResult> {
|
||||
switch (this.challenge?.component) {
|
||||
case "ak-stage-access-denied":
|
||||
// Statically imported for performance reasons
|
||||
await import("@goauthentik/flow/stages/access_denied/AccessDeniedStage");
|
||||
return html`<ak-stage-access-denied
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-access-denied>`;
|
||||
case "ak-stage-identification":
|
||||
// Statically imported for performance reasons
|
||||
await import("@goauthentik/flow/stages/identification/IdentificationStage");
|
||||
return html`<ak-stage-identification
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-identification>`;
|
||||
case "ak-stage-password":
|
||||
// Statically imported for performance reasons
|
||||
await import("@goauthentik/flow/stages/password/PasswordStage");
|
||||
return html`<ak-stage-password
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-password>`;
|
||||
case "ak-stage-captcha":
|
||||
// Statically imported to prevent browsers blocking urls
|
||||
await import("@goauthentik/flow/stages/captcha/CaptchaStage");
|
||||
return html`<ak-stage-captcha
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
@ -325,7 +310,7 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-email>`;
|
||||
case "ak-stage-autosubmit":
|
||||
// Statically imported for performance reasons
|
||||
await import("@goauthentik/flow/stages/autosubmit/AutosubmitStage");
|
||||
return html`<ak-stage-autosubmit
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
@ -368,6 +353,9 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-authenticator-sms>`;
|
||||
case "ak-stage-authenticator-validate":
|
||||
await import(
|
||||
"@goauthentik/flow/stages/authenticator_validate/AuthenticatorValidateStage"
|
||||
);
|
||||
return html`<ak-stage-authenticator-validate
|
||||
.host=${this as StageHost}
|
||||
.challenge=${this.challenge}
|
||||
@ -411,9 +399,8 @@ export class FlowExecutor extends Interface implements StageHost {
|
||||
.challenge=${this.challenge}
|
||||
></ak-stage-flow-error>`;
|
||||
default:
|
||||
break;
|
||||
return html`Invalid native challenge element`;
|
||||
}
|
||||
return html`Invalid native challenge element`;
|
||||
}
|
||||
|
||||
async renderChallenge(): Promise<TemplateResult> {
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
import { autoDetectLanguage } from "@goauthentik/common/ui/locale";
|
||||
import "@goauthentik/elements/messages/MessageContainer";
|
||||
import "@goauthentik/flow/FlowExecutor";
|
||||
// Statically import some stages to speed up load speed
|
||||
import "@goauthentik/flow/stages/access_denied/AccessDeniedStage";
|
||||
// Import webauthn-related stages to prevent issues on safari
|
||||
// Which is overly sensitive to allowing things only in the context of a
|
||||
// user interaction
|
||||
import "@goauthentik/flow/stages/authenticator_validate/AuthenticatorValidateStage";
|
||||
import "@goauthentik/flow/stages/authenticator_webauthn/WebAuthnAuthenticatorRegisterStage";
|
||||
import "@goauthentik/flow/stages/autosubmit/AutosubmitStage";
|
||||
import "@goauthentik/flow/stages/captcha/CaptchaStage";
|
||||
import "@goauthentik/flow/stages/identification/IdentificationStage";
|
||||
import "@goauthentik/flow/stages/password/PasswordStage";
|
||||
|
||||
// end of stage import
|
||||
|
||||
autoDetectLanguage();
|
||||
|
||||
@ -44,7 +44,7 @@ export class AuthenticatorValidateStage
|
||||
return this.host.loading;
|
||||
}
|
||||
|
||||
get tenant(): CurrentTenant {
|
||||
get tenant(): CurrentTenant | undefined {
|
||||
return this.host.tenant;
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ export interface StageHost {
|
||||
loading: boolean;
|
||||
submit(payload: unknown): Promise<boolean>;
|
||||
|
||||
readonly tenant: CurrentTenant;
|
||||
readonly tenant?: CurrentTenant;
|
||||
}
|
||||
|
||||
export function readFileAsync(file: Blob) {
|
||||
|
||||
Reference in New Issue
Block a user