Replies: 1 comment 4 replies
-
Hello, I am attempting a similar setup but using Keycloak, Oauth2-proxy and Nginx. I have managed to get the proxy header mapping working and able to pull the roles (Admin/Viewer) and username from my Keycloak users. I am currently experiencing issues with the "Review" tab as thumbnails are not loading when I have authentication disabled and proxy mapping setup. Viewing the web browser console the thumbnail URL (https://mydomain.com/clips/review/thumb-driveway-1758747684.421608-wetqpi.webp) is returning a 401 authorization required error. If I remove the proxy setting and enable authentication within Frigate the thumbnails start loading fine. I was wondering if you are also experiencing similar issues or had any advice for this problem? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The breakdown
Frigate has its own auth with user based roles:
admin
andviewer
. In order to make use of these roles via authentik, you must disable frigate's auth and configure a header that has one of those roles in the value. Frigate has a predefined list of header keys that can be used to pass the role/username, or you can mount a file into the frigate container to overwrite and add your own header keys (see example below).The goal is to sign in to authentik and not have to type in another password for frigate, yet frigate is still secure and retains user roles. Because frigate's built-in auth is disabled, already created users and their assigned roles will not be used, modified or deleted.
Assumptions
authentik.mydomain.com
which points tohttps://192.168.10.10:9443
internally)frigate.mydomain.com
which points tohttps://192.168.20.20:8971
internally)Frigate
Tip
To make things easy for myself, I set up a separate frigate install to test this on before running it on prod. I would highly recommend doing the same
Custom headers to pass username/role
Frigate can be configured to allow using custom header keys to set username and/or user role. This is accomplished via config and using a mount in the docker compose file.
The frigate docs example uses the same usernames between authentik and frigate. Meaning, your logged-in authentik username will be the same in frigate. You can configure and pass a different header key pair for the username. I did this to pass the user role, so if you want, you can use that method to pass frigate a username if you don't want the same username as you have in authentik.
Create the override file
Warning
The header names in this file ARE case sensitive
The default data was pulled by running:
docker exec -it frigate bash
, once inside the container run:cat /usr/local/nginx/conf/proxy_trusted_headers.conf
proxy_trusted_headers.conf
in the same dir as your frigate docker compose fileEdit docker compose file
Remember to recreate the container after editing:
docker compose up -d --force-recreate
Config
As mentioned, the built-in auth must be turned off. To keep things secure, there is an extra header that frigate can be configured to receive a secret known only to the reverse proxy and frigate. Frigate will only accept requests with that secret header key pair
Note
It's essential that SSL is used to encrypt the secret in transit
Generate
auth_secret
See https://docs.frigate.video/configuration/authentication/#proxy-configuration
python3 -c 'import secrets; print(secrets.token_hex(64))'
on a machine with python3 installedAuthentik
Application and provider config
Applications > Applications
Create with Provider
), name it, and leave the rest of the settings as default, clickNext
Next
Authorization flow
(I use implicit), scroll downhttps://frigate.mydomain.com
https://192.168.20.20:8971
Internal host SSL validation
(unless you have a valid SSL chain for your internal host), clickNext
Next
Submit
Outpost config
An outpost is basically a reverse proxy protected by authentik.
Note
the authentik web GUI and the embedded outpost use the same ports, if your SSL authentik endpoint uses port 9443, so does the outpost
Applications > Outposts
:authentik Embedded Outpost
Available Applications
and add it toSelected Applications
Passing the custom headers via an authentik group
Note
You can also pass custom headers using user attributes. I find groups a better fit, YMMV.
Two groups will need to be created to pass each user role:
Directory > Groups
Create
frigate-admin
orfrigate-viewer
)attributes
, this is where we can pass extra headers{}
X-Frigate-Username: <username>
if needed.Warning
The header names here ARE case sensitive
DNS
frigate.mydomain.com
must point to the authentik instanceauthentik.mydomain.com
, as authentik will handle auth and act as a reverse proxy.Cloudflare tunnels
Change the
frigate.mydomain.com
public hostname to point towards the internal authentik SSL endpoint (https://192.168.10.10:9443
) instead of the internal frigate SSL endpoint (https://192.168.20.20:8971
).How it works
Because frigate's built-in auth is turned off, you can use whatever username (even ones existing in frigates auth system) and assign it whatever role using the authentik
Groups
and theattributes
additionalHeaders
config. You can assign yourself as admin and family members as viewers through their authentik login and which group they are a member of.Flow
frigate.mydomain.com
Hopefully this is clear enough to follow, if it isn't, let me know!
Beta Was this translation helpful? Give feedback.
All reactions