Skip to content
This repository was archived by the owner on Aug 31, 2026. It is now read-only.

feat: configurable logout page URL for proxy/hook auth - #3884

Merged
hacdias merged 11 commits into
filebrowser:masterfrom
jake-dog:custom-logout-page
Nov 30, 2025
Merged

hacdias merged 11 commits into
filebrowser:masterfrom
jake-dog:custom-logout-page

Conversation

@jake-dog

@jake-dog jake-dog commented Apr 30, 2025 •

Copy link
Copy Markdown
Contributor

Update 2025-05-13: I've been running this for the past few weeks and added two commits to improve it. The integration with oauth2-proxy is seamless!

Description

  • add configurable logout page for use with proxy/hook auth
  • allow token renewal after expiration when safe to do so with proxy auth and a custom logout page
  • improve security by validating alg as recommended

Configurable logoutPage

The logout button is hidden when proxy auth is used (re: #934) because, at the time, logging out of oauth2_proxy cannot be done in filebrowser.

oauth2_proxy has since been updated to call the upstream auth provider's logout method, re: oauth2-proxy/oauth2-proxy#1876. filebrowser requires changes before this feature can be used:

  1. add a configurable logoutPage URL to filebrowser settings
  2. unhide the logout button when logoutPage is not set default (ie. /login)

Example:

  • set a custom logoutPage for filebrowser

    ./filebrowser config set --logoutpage "/oauth2/sign_out?rd=https%3A%2F%2Ffilebrowser"
    
  • run oauth2-proxy with custom logout URL (for keycloak)

    --backend-logout-url='https://keycloak/realms/myrealm/protocol/openid-connect/logout?id_token_hint={id_token}'
    

Token renewal after expiration

Users with proxy auth and a custom logout page are likely to encounter friction with filebrowser's default token renewal mechanism. The lifetime of session/renewal tokens issued by an auth proxy will conflict with filebrowser's JWT, prematurely logging out the user. To mitigate this issue the filebrowser token may be renewed after expiration if, and only if, the following conidtions are met:

  1. proxy auth is used with a custom logoutpage
  2. the filebrowser issued JWT is valid in every way except the expiration date

Validate token 'alg'

The golang-jwt/jwt/v4 library strongly encourages that the implementer validate the token 'alg'. From the documentation:

The caller is strongly encouraged to set the WithValidMethods option to validate the 'alg' claim in the token matches the expected algorithm.

In light of the fact that this request makes it possible to renew expired tokens under specific circumstances, it makes sense to also ensure all JWT security guidance is strictly adhered to.

🚨 Before submitting your PR, please indicate which issues are either fixed or closed by this PR. See GitHub Help: Closing issues using keywords.

  • DO make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • DO make sure you are making a pull request against the master branch (left side). Also you should start your branch off our master.
  • DO make sure that File Browser can be successfully built. See builds and development.
  • AVOID breaking the continuous integration build.

@jake-dog
jake-dog requested a review from o1egl as a code owner April 30, 2025 01:45
@hacdias
hacdias requested a review from a team as a code owner November 14, 2025 15:27
@hacdias
hacdias removed the request for review from o1egl November 14, 2025 15:28

@hacdias hacdias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jake-dog this is nice. I just updated your PR with the latest changes from main. Could you see my comment above?

Also, could you validate if it works correctly with my updates?

Comment thread cmd/config.go Resolved
@hacdias hacdias changed the title feat: Add configurable logoutPage URL for proxy/hook auth feat: configurable logout page URL for proxy/hook auth Nov 14, 2025
@jake-dog

jake-dog commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor Author

During testing I discovered that the idle timeout mechanism from #5439 conflicts with proxy auth's external token lifetime. As a temporary fix I've disabled the idle timeout logout mechanism when proxy auth and custom logout is used (eebfdbc), however a future improvement could be allow the idle timeout to be set to an arbitrary user configured value, or disabled entirely (set zero or negative).

Furthermore I noticed that the JWT was being accidentally validated twice per request due to #5535. The first token validation occurs in request.ParseFromRequest(), and the redundant validation occurs in (*jwt.Validator).Validate().

token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk))

err = jwt.NewValidator(jwt.WithExpirationRequired()).Validate(tk)

Filebrowser can regain a tiny bit of performance by omitting the redundant validation (8e5c0b1).

Breadcrumbs for how JWTv5 ParseFromRequest also validates
  1. request.ParseFromRequest() calls jwt.ParseWithClaims
  2. jwt.ParseWithClaims calls (*jwt.Validator).Validate()

@hacdias hacdias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions!

Comment thread frontend/src/utils/constants.ts Resolved
Comment thread http/auth.go Resolved
@hacdias
hacdias merged commit b9ac45d into filebrowser:master Nov 30, 2025
6 checks passed
@jake-dog
jake-dog deleted the custom-logout-page branch November 30, 2025 07:50
@ELERON23

Copy link
Copy Markdown

Hi,
Is there documentation on how to set this up?
Thank you

@jake-dog

Copy link
Copy Markdown
Contributor Author

Hi, Is there documentation on how to set this up? Thank you

I'm afraid not, but there is reasoning behind that. There are many possible permutations of frontend authn proxy and the auth.logoutPage flag provides only a tiny abstract integration. It would be very hard to document these options in a useful way without documenting other software with its own documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants