* feat(auth): implement oidc
* refactor(auth): centralize OIDC state cookie handling
* fix(web): resolve unused error variables in route handlers
* docs(readme): add OIDC authentication feature to list
* fix(auth): improve OIDC cookie handling for reverse proxy setups
The OIDC state cookie's Secure flag is now properly set when running behind a reverse proxy by checking both direct TLS and X-Forwarded-Proto header. This fixes authentication issues in common setups where:
- autobrr runs behind a reverse proxy that terminates HTTPS
- local development environments without TLS
- mixed protocol environments (internal HTTP, external HTTPS)
* fix: use crypt/random if argon2id fails
* feat(auth): show both login options when user exists in db
if user doesn't exist, e.g. canOnboard=true then we only show the OIDC button, since regular login makes no sense in that case
If user does not exist in db and the user wants to create a local user, OIDC needs to be disabled first
* feat(auth): improve OIDC provider initialization with discovery logging
* revert(issuer): do not remove trailing slash
* feat(auth): improve OIDC username resolution with additional claims
* fix(auth): handle OIDC issuer URLs with and without trailing slashes
When initializing the OIDC provider, automatically retry with/without trailing
slash if the first attempt fails.
- First attempts with original issuer URL
- If fails with trailing slash, retries without
- If fails without trailing slash, retries with
* feat(oidc): add gorilla sessions store for secure state management
Add gorilla sessions store to handle encrypted state cookies in OIDC flow,
while removing redundant session validation checks
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* fix(auth): prevent duplicate OIDC state cookies for authenticated sessions
Modify OIDC config handler to check for existing authenticated sessions
before setting state cookie. Still returns OIDC enabled status to maintain
UI state, but prevents unnecessary cookie creation for authenticated users.
* feat(oidc): use random secret for temporary state cookies
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* feat(auth): add rate limiting to OIDC endpoints
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* fix(auth): validate OIDC authorization code presence in callback
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* fix(auth): properly handle OIDC session errors
Improve error handling in OIDC login flow by properly handling cookie store
session errors. Return HTTP 500 if session cannot be retrieved instead of
silently continuing with potentially invalid state.
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
* feat(auth): track and display authentication method for oidc and password logins
* fix: tests
* docs(readme): add environment variable section
* go mod tidy
* chore: log style and errors
---------
Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
Co-authored-by: ze0s <ze0s@riseup.net>
* refactor: remove baseUrl from api calls and sseBaseUrl
* refactor: set cookie session to '/'.
Since that's where the api endpoint is that way we set it to the root domain, we can't set it to the subfolder since the api is called directly now and not using the baseUrl.
* feat: add the baseUrl route.
When user for example is in `/autobrr` and hit reload it should just return the index.html.
* refactor: now it have to be `/autobrr`
Remove the trailing `/`, now base url is set to /autobrr aligned with other arrs.
* refactor: remove baseUrl stuff.
* refactor: use separate router for the api endpoint and the baseUrl.
I don't think we need separate router, but I didn't test it, so feel free to test it and see if it works without the separate router, the whole point was to make sure that it's not prefixed with baseUrl and I noticed that it was being called in the frontend `APIClients.ts`. So yea just check if it works without it then keep the old one.
Also removed the index since it was zombie code not being used anywhere.
* feat: Dynamic base url.
* fix: auth handler deps
* feat(http): mount web and api on baseurl
* feat(http): web api client routes
* feat(http): baseurl legacy mode
* feat(http): baseurl legacy mode test
* feat(http): add assetBaseUrl
* feat(http): try separate web handlers
* feat(http): improve file serving
* feat(http): ignore .gitkeep
* fix(assets): windows paths
* fix(assets): windows paths trimprefix
* fix(assets): windows paths join
* fix(assets): cleanup
* fix(assets): additional web route check
* feat(http): add comments
---------
Co-authored-by: ze0s <ze0s@riseup.net>