Repository navigation
Closed
Labels
Description
Describe the bug
While navigating through different folders in the web interface, the user is randomly logged out.
Steps to reproduce
- Open the web interface.
- Navigate through different folders back and forth.
- The simplest way: repeatedly click on "personal" for some time.
- At a random moment, the session ends and the user is logged out.
Expected behavior
Seamless, uninterrupted navigation between folders without unexpected logout.
Actual behavior
User gets logged out randomly while navigating folders in the web interface
Setup
Please describe how you started the server and provide a list of relevant environment variables or configuration files.
Details
OC_GRPC_MAX_RECEIVED_MESSAGE_SIZE=10240000
PROXY_CSP_CONFIG_FILE_LOCATION=/etc/opencloud/csp.yaml
OC_OIDC_ISSUER=https://myoidc.com/application/o/open-cloud-web/
OC_EXCLUDE_RUN_SERVICES=idp
OC_INSECURE=false
OC_URL=https://myopencloud.com
POSTPROCESSING_WORKERS=8
OC_LOG_LEVEL=debug
OC_ADD_RUN_SERVICES=notifications
OC_TRACING_ENABLED=true
PROXY_AUTOPROVISION_CLAIM_GROUPS=
PROXY_OIDC_REWRITE_WELLKNOWN=true
PROXY_ENABLE_BASIC_AUTH=false
PROXY_TLS=false
PROXY_CSP_CONFIG_FILE_LOCATION=/etc/opencloud/csp.yaml
PROXY_AUTOPROVISION_CLAIM_EMAIL=email
PROXY_OIDC_USERINFO_CACHE_STORE=memory
PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=none
PROXY_AUTOPROVISION_CLAIM_USERNAME=preferred_username
PROXY_USER_OIDC_CLAIM=preferred_username
PROXY_OIDC_USERINFO_CACHE_TTL=10s
PROXY_HTTP_ADDR=0.0.0.0:9200
PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM=groups
PROXY_USER_CS3_CLAIM=username
PROXY_ROLE_ASSIGNMENT_DRIVER=oidc
PROXY_AUTOPROVISION_CLAIM_DISPLAYNAME=given_name
PROXY_AUTOPROVISION_ACCOUNTS=true
WEB_OIDC_SCOPE=openid email profile
IDP_ID_TOKEN_EXPIRATION=300
IDP_REFRESH_TOKEN_EXPIRATION=2592000
IDP_ACCESS_TOKEN_EXPIRATION=300
Additional context
- The issue occurs because a 401 status code is returned in response to a PROPFIND request.
- Further investigation shows this happens due to the logic in oidc_auth.go#L72
- Token expiration is checked only when the token is found in the cache — but this is only part of the issue.
- If the token does not have the ExpiresAt field set, the function extractExpiration returns a value equal to PROXY_OIDC_USERINFO_CACHE_TTL, and the token is cached with this TTL.
- If the next request arrives at the exact second when the cache is supposed to expire, the cached value is still returned. However, verifyExpiresAt will return false, which results in a 401 response being sent to the user.
- If the request is made one second later, the token will no longer be in the cache, the expiration will not be verified, and a new expiration time will be calculated and stored in the cache.
- This behavior is very likely the root cause of the problem described in opencloud#909
- Currently, it is not clear why the token is missing the ExpiresAt field — in theory, it should be equal to IDP_ACCESS_TOKEN_EXPIRATION, but this does not happen.
- As a temporary workaround, the value of PROXY_OIDC_USERINFO_CACHE_TTL can be significantly increased.
Reacted by Voxay, Juan D Barreto, Dmytro Nelen, Piotr Maksymiuk, upendedshark, Janusz Kawczyński and Max Muth
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rhafer commentedon Sep 22, 2025
Thanks for the detailed analysis. I think you're right, there seems to be an issue with token validation when the access tokens issued by the IDP are not JWT encoded (PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=none).
This is not entirely true. If the IDP issues JWT encoded access tokens and
PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHODis set tojwt(which are the default settings), the token's expiry time is validated with every single request. No matter if it was cached before, or not. Also even in the non-jwt case there is an implicit validation through theuserinforequest. However there seems to be a (small) time window when the token hasn't been evicted from the cache but the expiry time stored in the cached record is already passed. We should just reject that token unconditionally but e.g. re-validate it with another userinfo request.Even better would be if we add support for using the introspection endpoint to validate the access-tokens in the non-JWT case.
That setting is only relevant when using the built-in IDP (it sets the lifetime for the tokens issued by the built-in idp). But as you have set
OC_EXCLUDE_RUN_SERVICES=idpandOC_OIDC_ISSUERdoes point to some external IDP that setting does not have any effect in your setup.asp24 commentedon Sep 22, 2025
Thanks for the reply, @rhafer. In practice, "a (small) time window" isn’t that small. While navigating through the web interface, the application makes many PROPFIND requests, and the likelihood of the described behavior is so high that the user gets logged out very frequently.
jeffreyvangorkum commentedon Oct 1, 2025
Having PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD is set to "jwt" is a world of difference, you don't actually get randomly logged out.
zerodarkzone commentedon Oct 1, 2025
The problem with
PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=jwtis that it breaks the Desktop and Mobile clients on a lot of providers (Like authentik). If we we're able to set the app id for mobile and desktop (like for the webapp) this would not be a problem.jeffreyvangorkum commentedon Oct 1, 2025
I found this out the hard way and was just getting back to this thread to post exactly that. Setting it to jwt will break desktop and android app :(
fix(oidc_auth): Fix userinfo cache expiration logic
fix(oidc_auth): Fix userinfo cache expiration logic
fix(oidc_auth): Fix userinfo cache expiration logic
fix(oidc_auth): Fix userinfo cache expiration logic
fix(oidc_auth): Fix userinfo cache expiration logic