Merge branch 'master' into stage-challenge

# Conflicts:
#	web/src/elements/buttons/SpinnerButton.ts
This commit is contained in:
Jens Langhammer 2021-02-27 17:54:59 +01:00
commit 402afa1e85
23 changed files with 99 additions and 48 deletions

View File

@ -18,7 +18,7 @@ class PolicyCacheClearView(AdminRequiredMixin, SuccessMessageMixin, FormView):
"""View to clear Policy cache""" """View to clear Policy cache"""
form_class = PolicyCacheClearForm form_class = PolicyCacheClearForm
success_url = "/"
template_name = "generic/form_non_model.html" template_name = "generic/form_non_model.html"
success_message = _("Successfully cleared Policy cache") success_message = _("Successfully cleared Policy cache")
@ -36,7 +36,7 @@ class FlowCacheClearView(AdminRequiredMixin, SuccessMessageMixin, FormView):
"""View to clear Flow cache""" """View to clear Flow cache"""
form_class = FlowCacheClearForm form_class = FlowCacheClearForm
success_url = "/"
template_name = "generic/form_non_model.html" template_name = "generic/form_non_model.html"
success_message = _("Successfully cleared Flow cache") success_message = _("Successfully cleared Flow cache")

View File

@ -10,7 +10,7 @@ from authentik.lib.config import CONFIG
def get_geoip_reader() -> Optional[Reader]: def get_geoip_reader() -> Optional[Reader]:
"""Get GeoIP Reader, if configured, otherwise none""" """Get GeoIP Reader, if configured, otherwise none"""
path = CONFIG.y("authentik.geoip") path = CONFIG.y("authentik.geoip")
if path == "": if path == "" or not path:
return None return None
return Reader(path) return Reader(path)

View File

@ -157,7 +157,13 @@ class FlowImporter:
entries = deepcopy(self.__import.entries) entries = deepcopy(self.__import.entries)
for entry in entries: for entry in entries:
model_app_label, model_name = entry.model.split(".") model_app_label, model_name = entry.model.split(".")
model: SerializerModel = apps.get_model(model_app_label, model_name) try:
model: SerializerModel = apps.get_model(model_app_label, model_name)
except LookupError:
self.logger.error(
"app or model does not exist", app=model_app_label, model=model_name
)
return False
# Validate each single entry # Validate each single entry
try: try:
serializer = self._validate_single(entry) serializer = self._validate_single(entry)

View File

@ -1,5 +1,6 @@
"""Source API Views""" """Source API Views"""
from datetime import datetime from datetime import datetime
from time import time
from django.core.cache import cache from django.core.cache import cache
from django.db.models.base import Model from django.db.models.base import Model
@ -68,7 +69,7 @@ class LDAPSourceViewSet(ModelViewSet):
def sync_status(self, request: Request, slug: str) -> Response: def sync_status(self, request: Request, slug: str) -> Response:
"""Get source's sync status""" """Get source's sync status"""
source = self.get_object() source = self.get_object()
last_sync = cache.get(source.state_cache_prefix("last_sync"), None) last_sync = cache.get(source.state_cache_prefix("last_sync"), time())
return Response( return Response(
LDAPSourceSyncStatusSerializer( LDAPSourceSyncStatusSerializer(
{"last_sync": datetime.fromtimestamp(last_sync)} {"last_sync": datetime.fromtimestamp(last_sync)}

View File

@ -77,7 +77,8 @@ class LDAPPasswordChanger:
"""Change user's password""" """Change user's password"""
user_dn = user.attributes.get(LDAP_DISTINGUISHED_NAME, None) user_dn = user.attributes.get(LDAP_DISTINGUISHED_NAME, None)
if not user_dn: if not user_dn:
raise AttributeError(f"User has no {LDAP_DISTINGUISHED_NAME} set.") LOGGER.info(f"User has no {LDAP_DISTINGUISHED_NAME} set.")
return
self._source.connection.extend.microsoft.modify_password(user_dn, password) self._source.connection.extend.microsoft.modify_password(user_dn, password)
def _ad_check_password_existing(self, password: str, user_dn: str) -> bool: def _ad_check_password_existing(self, password: str, user_dn: str) -> bool:

View File

@ -1,6 +1,7 @@
trigger: trigger:
- master - master
- next - next
- version-*
resources: resources:
- repo: self - repo: self

View File

@ -1,6 +1,7 @@
trigger: trigger:
- master - master
- next - next
- version-*
variables: variables:
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}: ${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:

View File

@ -203,11 +203,11 @@ def apply_migration(app_name: str, migration_name: str):
def wrapper_outter(func: Callable): def wrapper_outter(func: Callable):
"""Retry test multiple times""" """Retry test multiple times"""
LOADER = MigrationLoader(connection) loader = MigrationLoader(connection)
@wraps(func) @wraps(func)
def wrapper(self: TransactionTestCase, *args, **kwargs): def wrapper(self: TransactionTestCase, *args, **kwargs):
migration = LOADER.get_migration(app_name, migration_name) migration = loader.get_migration(app_name, migration_name)
with connection.schema_editor() as schema_editor: with connection.schema_editor() as schema_editor:
for operation in migration.operations: for operation in migration.operations:
if not isinstance(operation, RunPython): if not isinstance(operation, RunPython):

View File

@ -1,6 +1,7 @@
trigger: trigger:
- master - master
- next - next
- version-*
variables: variables:
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}: ${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:

39
web/package-lock.json generated
View File

@ -197,6 +197,24 @@
} }
} }
}, },
"@sentry/integrations": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-6.2.0.tgz",
"integrity": "sha512-gvAhP61qs2fog2xCTDs94ZT8cZbWEjFZmOWfT1VXlZDIVopIporj5Qe6IgrLTiCWL61Yko5h5nFnPZ4mpjf+0w==",
"requires": {
"@sentry/types": "6.2.0",
"@sentry/utils": "6.2.0",
"localforage": "^1.8.1",
"tslib": "^1.9.3"
},
"dependencies": {
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
}
}
},
"@sentry/minimal": { "@sentry/minimal": {
"version": "6.2.0", "version": "6.2.0",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.2.0.tgz", "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.2.0.tgz",
@ -1727,6 +1745,11 @@
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
"integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw=="
}, },
"immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
"integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps="
},
"import-fresh": { "import-fresh": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
@ -1981,6 +2004,14 @@
"type-check": "~0.4.0" "type-check": "~0.4.0"
} }
}, },
"lie": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
"integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=",
"requires": {
"immediate": "~3.0.5"
}
},
"lit-analyzer": { "lit-analyzer": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/lit-analyzer/-/lit-analyzer-1.2.1.tgz", "resolved": "https://registry.npmjs.org/lit-analyzer/-/lit-analyzer-1.2.1.tgz",
@ -2162,6 +2193,14 @@
"resolved": "https://registry.npmjs.org/lit-html/-/lit-html-1.3.0.tgz", "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-1.3.0.tgz",
"integrity": "sha512-0Q1bwmaFH9O14vycPHw8C/IeHMk/uSDldVLIefu/kfbTBGIc44KGH6A8p1bDfxUfHdc8q6Ct7kQklWoHgr4t1Q==" "integrity": "sha512-0Q1bwmaFH9O14vycPHw8C/IeHMk/uSDldVLIefu/kfbTBGIc44KGH6A8p1bDfxUfHdc8q6Ct7kQklWoHgr4t1Q=="
}, },
"localforage": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.9.0.tgz",
"integrity": "sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g==",
"requires": {
"lie": "3.1.1"
}
},
"locate-path": { "locate-path": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",

View File

@ -13,6 +13,7 @@
"@fortawesome/fontawesome-free": "^5.15.2", "@fortawesome/fontawesome-free": "^5.15.2",
"@patternfly/patternfly": "^4.87.3", "@patternfly/patternfly": "^4.87.3",
"@sentry/browser": "^6.2.0", "@sentry/browser": "^6.2.0",
"@sentry/integrations": "^6.2.0",
"@sentry/tracing": "^6.2.0", "@sentry/tracing": "^6.2.0",
"@types/chart.js": "^2.9.31", "@types/chart.js": "^2.9.31",
"@types/codemirror": "0.0.108", "@types/codemirror": "0.0.108",

View File

@ -3,6 +3,7 @@ import * as Sentry from "@sentry/browser";
import { Integrations } from "@sentry/tracing"; import { Integrations } from "@sentry/tracing";
import { VERSION } from "../constants"; import { VERSION } from "../constants";
import { SentryIgnoredError } from "../common/errors"; import { SentryIgnoredError } from "../common/errors";
import { CaptureConsole as CaptureConsoleIntegration } from "@sentry/integrations";
export class Config { export class Config {
branding_logo: string; branding_logo: string;
@ -22,7 +23,10 @@ export class Config {
Sentry.init({ Sentry.init({
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8", dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
release: `authentik@${VERSION}`, release: `authentik@${VERSION}`,
integrations: [new Integrations.BrowserTracing()], integrations: [
new Integrations.BrowserTracing(),
new CaptureConsoleIntegration(),
],
tracesSampleRate: 0.6, tracesSampleRate: 0.6,
environment: config.error_reporting_environment, environment: config.error_reporting_environment,
beforeSend(event: Sentry.Event, hint: Sentry.EventHint) { beforeSend(event: Sentry.Event, hint: Sentry.EventHint) {

View File

@ -1,3 +1,4 @@
import { css, CSSResult } from "lit-element";
// @ts-ignore // @ts-ignore
import PF from "@patternfly/patternfly/patternfly.css"; import PF from "@patternfly/patternfly/patternfly.css";
// @ts-ignore // @ts-ignore
@ -6,10 +7,31 @@ import PFAddons from "@patternfly/patternfly/patternfly-addons.css";
import FA from "@fortawesome/fontawesome-free/css/fontawesome.css"; import FA from "@fortawesome/fontawesome-free/css/fontawesome.css";
// @ts-ignore // @ts-ignore
import AKGlobal from "../authentik.css"; import AKGlobal from "../authentik.css";
import { CSSResult } from "lit-element";
// @ts-ignore // @ts-ignore
import CodeMirrorStyle from "codemirror/lib/codemirror.css"; import CodeMirrorStyle from "codemirror/lib/codemirror.css";
// @ts-ignore // @ts-ignore
import CodeMirrorTheme from "codemirror/theme/monokai.css"; import CodeMirrorTheme from "codemirror/theme/monokai.css";
export const ColorStyles = css`
export const COMMON_STYLES: CSSResult[] = [PF, PFAddons, FA, AKGlobal, CodeMirrorStyle, CodeMirrorTheme]; .pf-m-success {
color: var(--pf-global--success-color--100);
}
.pf-c-button.pf-m-success {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--success-color--100);
}
.pf-m-warning {
color: var(--pf-global--warning-color--100);
}
.pf-c-button.pf-m-warning {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--warning-color--100);
}
.pf-m-danger {
color: var(--pf-global--danger-color--100);
}
.pf-c-button.pf-m-danger {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--danger-color--100);
}
`;
export const COMMON_STYLES: CSSResult[] = [PF, PFAddons, FA, AKGlobal, CodeMirrorStyle, CodeMirrorTheme, ColorStyles];

View File

@ -1,31 +1,6 @@
import { css } from "lit-element";
export const PRIMARY_CLASS = "pf-m-primary"; export const PRIMARY_CLASS = "pf-m-primary";
export const SUCCESS_CLASS = "pf-m-success"; export const SUCCESS_CLASS = "pf-m-success";
export const ERROR_CLASS = "pf-m-danger"; export const ERROR_CLASS = "pf-m-danger";
export const PROGRESS_CLASS = "pf-m-in-progress"; export const PROGRESS_CLASS = "pf-m-in-progress";
export const CURRENT_CLASS = "pf-m-current"; export const CURRENT_CLASS = "pf-m-current";
export const ColorStyles = css`
.pf-m-success {
color: var(--pf-global--success-color--100);
}
.pf-c-button.pf-m-success {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--success-color--100);
}
.pf-m-warning {
color: var(--pf-global--warning-color--100);
}
.pf-c-button.pf-m-warning {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--warning-color--100);
}
.pf-m-danger {
color: var(--pf-global--danger-color--100);
}
.pf-c-button.pf-m-danger {
color: var(--pf-c-button--m-primary--Color);
background-color: var(--pf-global--danger-color--100);
}
`;
export const VERSION = "2021.2.5-stable"; export const VERSION = "2021.2.5-stable";

View File

@ -5,8 +5,9 @@ import GlobalsStyle from "@patternfly/patternfly/base/patternfly-globals.css";
import ButtonStyle from "@patternfly/patternfly/components/Button/button.css"; import ButtonStyle from "@patternfly/patternfly/components/Button/button.css";
// @ts-ignore // @ts-ignore
import SpinnerStyle from "@patternfly/patternfly/components/Spinner/spinner.css"; import SpinnerStyle from "@patternfly/patternfly/components/Spinner/spinner.css";
import { ColorStyles, PRIMARY_CLASS, PROGRESS_CLASS } from "../../constants";
import { SpinnerSize } from "../Spinner"; import { SpinnerSize } from "../Spinner";
import { PRIMARY_CLASS, PROGRESS_CLASS } from "../../constants";
import { ColorStyles } from "../../common/styles";
@customElement("ak-spinner-button") @customElement("ak-spinner-button")
export class SpinnerButton extends LitElement { export class SpinnerButton extends LitElement {

View File

@ -4,7 +4,8 @@ import GlobalsStyle from "@patternfly/patternfly/base/patternfly-globals.css";
// @ts-ignore // @ts-ignore
import ButtonStyle from "@patternfly/patternfly/components/Button/button.css"; import ButtonStyle from "@patternfly/patternfly/components/Button/button.css";
import { Token } from "../../api/Tokens"; import { Token } from "../../api/Tokens";
import { ColorStyles, ERROR_CLASS, PRIMARY_CLASS, SUCCESS_CLASS } from "../../constants"; import { ERROR_CLASS, PRIMARY_CLASS, SUCCESS_CLASS } from "../../constants";
import { ColorStyles } from "../../common/styles";
@customElement("ak-token-copy-button") @customElement("ak-token-copy-button")
export class TokenCopyButton extends LitElement { export class TokenCopyButton extends LitElement {

View File

@ -2,7 +2,6 @@ import { gettext } from "django";
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element"; import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import { COMMON_STYLES } from "../../common/styles"; import { COMMON_STYLES } from "../../common/styles";
import { ColorStyles } from "../../constants";
@customElement("ak-aggregate-card") @customElement("ak-aggregate-card")
export class AggregateCard extends LitElement { export class AggregateCard extends LitElement {
@ -25,7 +24,7 @@ export class AggregateCard extends LitElement {
text-align: center; text-align: center;
color: var(--pf-global--Color--100); color: var(--pf-global--Color--100);
} }
`, ColorStyles]); `]);
} }
renderInner(): TemplateResult { renderInner(): TemplateResult {

View File

@ -3,7 +3,6 @@ import { css, CSSResult, customElement, html, LitElement, property, TemplateResu
import CodeMirrorStyle from "codemirror/lib/codemirror.css"; import CodeMirrorStyle from "codemirror/lib/codemirror.css";
// @ts-ignore // @ts-ignore
import CodeMirrorTheme from "codemirror/theme/monokai.css"; import CodeMirrorTheme from "codemirror/theme/monokai.css";
import { ColorStyles } from "../../constants";
import { COMMON_STYLES } from "../../common/styles"; import { COMMON_STYLES } from "../../common/styles";
import { Route } from "./Route"; import { Route } from "./Route";
import { ROUTES } from "../../routes"; import { ROUTES } from "../../routes";
@ -24,7 +23,6 @@ export class RouterOutlet extends LitElement {
return [ return [
CodeMirrorStyle, CodeMirrorStyle,
CodeMirrorTheme, CodeMirrorTheme,
ColorStyles,
css` css`
:host { :host {
height: 100vh; height: 100vh;

View File

@ -117,7 +117,7 @@
}, },
"model": "authentik_stages_user_login.userloginstage", "model": "authentik_stages_user_login.userloginstage",
"attrs": { "attrs": {
"session_duration": "seconds=-1" "session_duration": "seconds=0"
} }
}, },
{ {

View File

@ -136,7 +136,7 @@
}, },
"model": "authentik_stages_user_login.userloginstage", "model": "authentik_stages_user_login.userloginstage",
"attrs": { "attrs": {
"session_duration": "seconds=-1" "session_duration": "seconds=0"
} }
}, },
{ {

View File

@ -20,7 +20,7 @@
}, },
"model": "authentik_stages_user_login.userloginstage", "model": "authentik_stages_user_login.userloginstage",
"attrs": { "attrs": {
"session_duration": "seconds=-1" "session_duration": "seconds=0"
} }
}, },
{ {

View File

@ -20,7 +20,7 @@
}, },
"model": "authentik_stages_user_login.userloginstage", "model": "authentik_stages_user_login.userloginstage",
"attrs": { "attrs": {
"session_duration": "seconds=-1" "session_duration": "seconds=0"
} }
}, },
{ {

View File

@ -115,7 +115,7 @@
}, },
"model": "authentik_stages_user_login.userloginstage", "model": "authentik_stages_user_login.userloginstage",
"attrs": { "attrs": {
"session_duration": "seconds=-1" "session_duration": "seconds=0"
} }
}, },
{ {