Replies: 1 comment 16 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Edit: I highly recommend using another idP. Authentik team likes to release buggy and broken software then drag their feet on releasing fixes. Join their discord and see the messages of everyone complaining that they consistently break instances on updates.
The breakdown
Frigate has its own auth with user based roles:
adminandviewer. 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.comwhich points tohttps://192.168.10.10:9443internally)frigate.mydomain.comwhich points tohttps://192.168.20.20:8971internally)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.confproxy_trusted_headers.confin the same dir as your frigate docker compose fileEdit docker compose file
Remember to recreate the container after editing:
docker compose up -d --force-recreateConfig
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_secretSee 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 > ApplicationsCreate with Provider), name it, and leave the rest of the settings as default, clickNextNextAuthorization flow(I use implicit), scroll downhttps://frigate.mydomain.comhttps://192.168.20.20:8971Internal host SSL validation(unless you have a valid SSL chain for your internal host), clickNextNextSubmitOutpost 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 OutpostAvailable Applicationsand add it toSelected ApplicationsPassing 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 > GroupsCreatefrigate-adminorfrigate-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.commust point to the authentik instanceauthentik.mydomain.com, as authentik will handle auth and act as a reverse proxy.Cloudflare tunnels
Change the
frigate.mydomain.compublic 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
Groupsand theattributesadditionalHeadersconfig. 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.comHopefully this is clear enough to follow, if it isn't, let me know!
Beta Was this translation helpful? Give feedback.
All reactions