web: move ak-form-element to separate file

This commit is contained in:
Jens Langhammer 2021-02-21 23:08:38 +01:00
parent 0fa97de06e
commit 20e0fe3941
9 changed files with 54 additions and 51 deletions

20
Pipfile
View File

@ -6,6 +6,9 @@ verify_ssl = true
[packages] [packages]
boto3 = "*" boto3 = "*"
celery = "*" celery = "*"
channels = "*"
channels-redis = "*"
dacite = "*"
defusedxml = "*" defusedxml = "*"
django = "*" django = "*"
django-cors-middleware = "*" django-cors-middleware = "*"
@ -17,19 +20,21 @@ django-otp = "*"
django-prometheus = "*" django-prometheus = "*"
django-recaptcha = "*" django-recaptcha = "*"
django-redis = "*" django-redis = "*"
djangorestframework = "*"
django-storages = "*" django-storages = "*"
djangorestframework = "*"
djangorestframework-guardian = "*" djangorestframework-guardian = "*"
docker = "*"
drf_yasg2 = "*" drf_yasg2 = "*"
facebook-sdk = "*" facebook-sdk = "*"
geoip2 = "*"
gunicorn = "*"
kubernetes = "*"
ldap3 = "*" ldap3 = "*"
lxml = "*" lxml = "*"
packaging = "*" packaging = "*"
psycopg2-binary = "*" psycopg2-binary = "*"
pycryptodome = "*" pycryptodome = "*"
pyjwkest = "*" pyjwkest = "*"
uvicorn = {extras = ["standard"],version = "*"}
gunicorn = "*"
pyyaml = "*" pyyaml = "*"
qrcode = "*" qrcode = "*"
requests-oauthlib = "*" requests-oauthlib = "*"
@ -38,14 +43,9 @@ service_identity = "*"
structlog = "*" structlog = "*"
swagger-spec-validator = "*" swagger-spec-validator = "*"
urllib3 = {extras = ["secure"],version = "*"} urllib3 = {extras = ["secure"],version = "*"}
dacite = "*" uvicorn = {extras = ["standard"],version = "*"}
channels = "*"
channels-redis = "*"
kubernetes = "*"
docker = "*"
xmlsec = "*"
geoip2 = "*"
webauthn = "*" webauthn = "*"
xmlsec = "*"
[requires] [requires]
python_version = "3.9" python_version = "3.9"

View File

@ -470,8 +470,6 @@ for _app in INSTALLED_APPS:
pass pass
if DEBUG: if DEBUG:
INSTALLED_APPS.append("debug_toolbar")
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_ALWAYS_EAGER = True
INSTALLED_APPS.append("authentik.core.apps.AuthentikCoreConfig") INSTALLED_APPS.append("authentik.core.apps.AuthentikCoreConfig")

View File

@ -63,13 +63,9 @@ urlpatterns += [
] ]
if settings.DEBUG: if settings.DEBUG:
import debug_toolbar
urlpatterns = ( urlpatterns = (
[ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
path("-/debug/", include(debug_toolbar.urls)),
]
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ urlpatterns + urlpatterns
) )

View File

@ -3,6 +3,7 @@ import { css, CSSResult, customElement, html, property, TemplateResult } from "l
import { WithUserInfoChallenge } from "../../../api/Flows"; import { WithUserInfoChallenge } from "../../../api/Flows";
import { COMMON_STYLES } from "../../../common/styles"; import { COMMON_STYLES } from "../../../common/styles";
import { BaseStage } from "../base"; import { BaseStage } from "../base";
import "../form";
export interface AuthenticatorStaticChallenge extends WithUserInfoChallenge { export interface AuthenticatorStaticChallenge extends WithUserInfoChallenge {
codes: number[]; codes: number[];

View File

@ -4,6 +4,7 @@ import { WithUserInfoChallenge } from "../../../api/Flows";
import { COMMON_STYLES } from "../../../common/styles"; import { COMMON_STYLES } from "../../../common/styles";
import { BaseStage } from "../base"; import { BaseStage } from "../base";
import "webcomponent-qr-code"; import "webcomponent-qr-code";
import "../form";
export interface AuthenticatorTOTPChallenge extends WithUserInfoChallenge { export interface AuthenticatorTOTPChallenge extends WithUserInfoChallenge {
config_url: string; config_url: string;

View File

@ -0,0 +1,35 @@
import { customElement, LitElement, CSSResult, property } from "lit-element";
import { TemplateResult, html } from "lit-html";
import { Error } from "../../api/Flows";
import { COMMON_STYLES } from "../../common/styles";
@customElement("ak-form-element")
export class FormElement extends LitElement {
static get styles(): CSSResult[] {
return COMMON_STYLES;
}
@property()
label?: string;
@property({ type: Boolean })
required = false;
@property({ attribute: false })
errors?: Error[];
render(): TemplateResult {
return html`<div class="pf-c-form__group">
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${this.label}</span>
${this.required ? html`<span class="pf-c-form__label-required" aria-hidden="true">*</span>` : html``}
</label>
<slot></slot>
${(this.errors || []).map((error) => {
return html`<p class="pf-c-form__helper-text pf-m-error">${error.string}</p>`;
})}
</div>`;
}
}

View File

@ -1,8 +1,9 @@
import { gettext } from "django"; import { gettext } from "django";
import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { CSSResult, customElement, html, property, TemplateResult } from "lit-element";
import { Challenge, Error } from "../../../api/Flows"; import { Challenge } from "../../../api/Flows";
import { COMMON_STYLES } from "../../../common/styles"; import { COMMON_STYLES } from "../../../common/styles";
import { BaseStage } from "../base"; import { BaseStage } from "../base";
import "../form";
export interface IdentificationChallenge extends Challenge { export interface IdentificationChallenge extends Challenge {
@ -23,37 +24,6 @@ export interface UILoginButton {
icon_url?: string; icon_url?: string;
} }
@customElement("ak-form-element")
export class FormElement extends LitElement {
static get styles(): CSSResult[] {
return COMMON_STYLES;
}
@property()
label?: string;
@property({type: Boolean})
required = false;
@property({attribute: false})
errors?: Error[];
render(): TemplateResult {
return html`<div class="pf-c-form__group">
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${this.label}</span>
${this.required ? html`<span class="pf-c-form__label-required" aria-hidden="true">*</span>` : html``}
</label>
<slot></slot>
${(this.errors || []).map((error) => {
return html`<p class="pf-c-form__helper-text pf-m-error">${error.string}</p>`;
})}
</div>`;
}
}
@customElement("ak-stage-identification") @customElement("ak-stage-identification")
export class IdentificationStage extends BaseStage { export class IdentificationStage extends BaseStage {
@ -77,7 +47,7 @@ export class IdentificationStage extends BaseStage {
} }
renderFooter(): TemplateResult { renderFooter(): TemplateResult {
if (!(this.challenge?.enroll_url && this.challenge.recovery_url)) { if (!this.challenge?.enroll_url && !this.challenge?.recovery_url) {
return html``; return html``;
} }
return html`<div class="pf-c-login__main-footer-band"> return html`<div class="pf-c-login__main-footer-band">

View File

@ -3,6 +3,7 @@ import { CSSResult, customElement, html, property, TemplateResult } from "lit-el
import { WithUserInfoChallenge } from "../../../api/Flows"; import { WithUserInfoChallenge } from "../../../api/Flows";
import { COMMON_STYLES } from "../../../common/styles"; import { COMMON_STYLES } from "../../../common/styles";
import { BaseStage } from "../base"; import { BaseStage } from "../base";
import "../form";
export interface PasswordChallenge extends WithUserInfoChallenge { export interface PasswordChallenge extends WithUserInfoChallenge {
recovery_url?: string; recovery_url?: string;

View File

@ -3,6 +3,7 @@ import { CSSResult, customElement, html, property, TemplateResult } from "lit-el
import { Challenge } from "../../../api/Flows"; import { Challenge } from "../../../api/Flows";
import { COMMON_STYLES } from "../../../common/styles"; import { COMMON_STYLES } from "../../../common/styles";
import { BaseStage } from "../base"; import { BaseStage } from "../base";
import "../form";
export interface Prompt { export interface Prompt {
field_key: string; field_key: string;