From 3ab475d916867a18bf02f5089a6cb785c4397dda Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 2 Jul 2022 18:41:16 +0200 Subject: [PATCH] website/docs: add snippet to skip authenticated flow Signed-off-by: Jens Langhammer --- website/docs/flow/examples/snippets.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/website/docs/flow/examples/snippets.md b/website/docs/flow/examples/snippets.md index b5df0e7e9..dcd972f0e 100644 --- a/website/docs/flow/examples/snippets.md +++ b/website/docs/flow/examples/snippets.md @@ -15,3 +15,11 @@ return False ``` This policy should be bound to the stage after your redirect should happen. For example, if you have an identification and a password stage, and you want to redirect after identification, bind the policy to the password stage. Make sure the policy binding is set to re-evaluate policies. + +### Deny flow when user is authenticated + +```python +return not request.user.is_authenticated +``` + +When used with authentik 2022.7 or later, set the flow _Denied action_ to _CONTINUE_. This will redirect already authenticated users to the default interface if they try to use the respective flow.