Files
authentik/website/docs/flow/examples/snippets.md
Jens L. 27380e9903 website/docs: use a more consistent version requirement notice (#11400)
* website/docs: use a more consistent version requirement notice

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* adjust colours

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* fix some anchors

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2024-09-23 17:42:17 +02:00

24 lines
885 B
Markdown

---
title: Example policy snippets for flows
---
### Redirect current flow to another URL <span class="badge badge--version">authentik 2022.7+</span>
```python
plan = request.context.get("flow_plan")
if not plan:
return False
plan.redirect("https://foo.bar")
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 stage binding's option _Evaluate when stage is run_ is enabled.
### 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.