diff --git a/flow_invitation.yaml.tmpl b/flow_invitation.yaml.tmpl index d3f6240..ccdac53 100644 --- a/flow_invitation.yaml.tmpl +++ b/flow_invitation.yaml.tmpl @@ -24,6 +24,24 @@ entries: id: invitation-enrollment-flow model: authentik_flows.flow +### POLICIES +- attrs: + expression: "if not regex_match(request.context.get('prompt_data').get('username'),\ + \ '\\s'):\n return True\n\nak_message(\"Username must not contain\ + \ whitespace!\")\nreturn False" + name: username-without-spaces-policy + id: username-without-spaces-policy + identifiers: + name: username-without-spaces-policy + model: authentik_policies_expression.expressionpolicy + +### POLICY BINDINGS +- identifiers: + policy: !KeyOf username-without-spaces-policy + target: !KeyOf prompt-stage-binding + order: 10 + model: authentik_policies.policybinding + ### STAGES - identifiers: name: invitation-stage @@ -53,6 +71,7 @@ entries: stage: !KeyOf enrollment-prompt-userdata target: !KeyOf invitation-enrollment-flow model: authentik_flows.flowstagebinding + id: prompt-stage-binding - identifiers: order: 20 stage: !Find [authentik_stages_user_write.userwritestage, [name, default-source-enrollment-write]] diff --git a/flow_translation.yaml.tmpl b/flow_translation.yaml.tmpl index 2baaa3f..0c709b6 100644 --- a/flow_translation.yaml.tmpl +++ b/flow_translation.yaml.tmpl @@ -69,3 +69,16 @@ entries: attrs: label: !Context transl_username placeholder: !Context transl_username + +### POLICIES +- model: authentik_policies_expression.expressionpolicy + identifiers: + name: username-without-spaces-policy + attrs: + expression: "if not regex_match(request.context.get('prompt_data').get('username'),\ + \ '\\s'):\n return True\n\nak_message(\"Benutzername darf kein Leerzeichen\ + \ enthalten\")\nreturn False" + name: username-without-spaces-policy + id: username-without-spaces-policy + +Benutzername darf kein Leerzeichen enthalten\")\n \ No newline at end of file