goauthentik / goauthentik/authentik

Can you login to forward auth proxy with the API?

Open
#16,044 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
25.6k
Forks
2k
Avg merge
1d 1h
Merged PRs (30d)
644

Description

I am creating an application where I want to protect the internal application API with a forward auth proxy, but have the user login via a custom flow executor that is embedded in a page component.

Currently I can have the user login using a custom UI powered by `/api/v3/flows/executor/default-authentication-flow/`. This then allows access to any authentik API resources I want, but trying to access anything behind the forward auth proxy results in a 401. Some investigation has revealed that if a missing `authentik_proxy_xxxxxxxx` cookie is set, then forward auth works. This cookie is set if I login again through `/outpost.goauthentik.io/start`.

How can I get this `authentik_proxy` cookie set via the API? All calls to forward auth protected URLs are non-interactive, and I do not want to have to redirect for any login or force users to login twice.

The default Nginx forward auth configuration has you redirect on 401 to the proxy login start URL (`/outpost.goauthentik.io/start`), however this is entirely unsuitable for use in an environment where forward auth is only protecting the API side of the application. I there some modification I can make to the login flow I am using to make it also login to the proxy?

(Also as a side issue, the API flow executor would not work until I set the `X-authentik-CSRF` header to the contents of the `authentik_csrf` cookie. As far as I can find, no mention of this requirement is in the documentation for the API. Fun.)

**Version and Deployment:**

- authentik version: 2025.6.4
- Deployment: docker-compose
- Forward auth is via nginx/1.25.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.