-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"csrf check failed" after Nextcloud session ends #743
Comments
found this issue which looks similar but using SAML nextcloud/server#40626 |
hi @julien-nc thank you for you attention. I tested the version you provided and there is an improvement in terms there is no more logout/login loop. the new version work, the user logins successfully but once the auto-logout happens user_oidc disappears somehow - clean original NC login UI appears and user_oidc doesn't start working (even when I restart the docker container) until I recover the original Application.php version.. Once it works I can apply the patch again and it works once.. I don't see anything useful in nextcloud.log
and nothing in the container logs.. but the app seems to work somehow in the backend - if I have valid OIDC session - I can access my Nextcloud directly - likely the fix broke the login redirection logic |
@isdnfan We think we figured out the source of the issue (or one of the sources). This is explained in nextcloud/server#43701 . Would you be ready to try it out on your instance? I can provide the new compiled scripts for your Nextcloud version. Are you still using Nextcloud 28.0.1 or did you upgrade to 28.0.2? |
hi @julien-nc thank you. definitely I would test in my instance. I'm running 28.0.2 now. |
So you can replace core-main.js.map.txt I'm not entirely sure this will fix the issue for you since you have auto_logout disabled but the symptoms on your side are very close to what the fix is addressing (being redirected multiple times to the logout page with the same requesttoken GET param). |
I replaced both files in my instance and first look is really good!! many thanks for your hard work!I see I only tested few scenarios - leave the browser time out in files, activities and calendar app - all worked and result in clean login into the system.. the only cosmetical problem - the session doesn't return to the same app but returns to "fresh login state". I can live with this limitation but definitely would be great if the client would return to the previous state. |
That's great news, thanks for the feedback! The problem you mention is tough to solve as the logout page is reached, we loose the information of which page you were browsing before being logged out. Let's keep this issue open until someone confirms this is solved by the next minor release. |
Good day, I have the same issue. Using auto_logout=true and user_oidc plugin. Even when logging in as native admin (non-oidc), when the forced logout kicks in, I get "CSRF check failed" and user is not logged out. I noticed that auto-logout seems to work without error when the browser tab is active/visible. But when the browser tab is inactive, auto-logout results in "CSRF check failed". Manual logout works without issues. Tested on NC 29 and 30. |
Hi, we're facing this same issue in Nextcloud AIO with Keycloak as IdP. Same configs as OP, with allow_multiple_user_backends=0. Logout results in loop back to Nextcloud dashboard with the user still logged in. If |
@phoenixtechnam @sikkgit Did you try applying the changes made in #761, or did you download the release version of the user_oidc app? |
I dont think this is an issue with this app exclusively. I have the very same issue using the oidc_login app. |
Problem
I successfully integrated Nextcloud with Zitadel IdP using user_oidc but I hit an issue with allow_multiple_user_backends=0 config.
Setup
The idea was to reduce Nextcloud session lifetime so NC session ends quickly and the user must re-login using IdP to ensure user session is still valid in IdP. To ensure I configure following settings in NC:
with allow_multiple_user_backends=1 the settings work fine and the user returns to login screen where hitting the button "login with IdP" allows to start another session.
the problem starts when I forced IdP login allow_multiple_user_backends=0 using
occ config:app:set --value=0 user_oidc allow_multiple_user_backends
which worked as expected immediately redirecting unauthorized user to IdP and allowing access upon successful authorization. But after Nextcloud session ends the user is unable to return to Nextcloud. The browser keeps bouncing between Nextcloud and IdP with requestskeeping requesttoken constant and at some point hitting 412 "CSRF check failed"
How to reproduce
Logs
I'm adding anonymized HAR file from browser dev tools showing the issue. In this log https://dev-nc.mydomain.tld is my Nextcloud and https://sso.mydomain.tld is the IdP. In my case I'm using Zitadel but the same issue happens with authentik and Keycloak as well.
dev-nc.mydomain.tld_Archive [23-12-28 20-22-20].har.zip
Nextcloud config report:
Enabled:
Disabled:
{
"htaccess.RewriteBase": "/",
"memcache.local": "\OC\Memcache\APCu",
"apps_paths": [
{
"path": "/var/www/html/apps",
"url": "/apps",
"writable": false
},
{
"path": "/var/www/html/custom_apps",
"url": "/custom_apps",
"writable": true
}
],
"overwritehost": "dev-nc.mydomain.tld",
"overwriteprotocol": "https",
"passwordsalt": "REMOVED SENSITIVE VALUE",
"secret": "REMOVED SENSITIVE VALUE",
"trusted_domains": [
"localhost"
],
"datadirectory": "REMOVED SENSITIVE VALUE",
"dbtype": "mysql",
"version": "28.0.1.1",
"dbname": "REMOVED SENSITIVE VALUE",
"dbhost": "REMOVED SENSITIVE VALUE",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "REMOVED SENSITIVE VALUE",
"dbpassword": "REMOVED SENSITIVE VALUE",
"installed": true,
"instanceid": "REMOVED SENSITIVE VALUE",
"loglevel": "1",
"maintenance": false,
"memcache.distributed": "\OC\Memcache\Redis",
"memcache.locking": "\OC\Memcache\Redis",
"redis": {
"host": "REMOVED SENSITIVE VALUE",
"password": "REMOVED SENSITIVE VALUE",
"port": 6379
},
"default_phone_region": "CH",
"mail_from_address": "REMOVED SENSITIVE VALUE",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_domain": "REMOVED SENSITIVE VALUE",
"mail_smtpsecure": "ssl",
"mail_smtpauthtype": "LOGIN",
"mail_smtpauth": 1,
"mail_smtphost": "REMOVED SENSITIVE VALUE",
"mail_smtpport": "465",
"mail_smtpname": "REMOVED SENSITIVE VALUE",
"mail_smtppassword": "REMOVED SENSITIVE VALUE",
"allow_local_remote_servers": true,
"trashbin_retention_obligation": "15, 180",
"app_install_overwrite": [
"suspicious_login"
],
"serverinfo": {
"token": "lmFaJ6JXR5e8wxCuyfSn"
},
"trusted_proxies": "REMOVED SENSITIVE VALUE",
"remember_login_cookie_lifetime": 0,
"session_keepalive": "true",
"session_lifetime": "120",
"auto_logout": "false",
"overwrite.cli.url": "https://dev-nc.mydomain.tld",
"theme": "",
"session_relaxed_expiry": "false",
"updater.release.channel": "stable",
"enabledPreviewProviders": [
"OC\Preview\MP3",
"OC\Preview\TXT",
"OC\Preview\MarkDown",
"OC\Preview\OpenDocument",
"OC\Preview\Krita",
"OC\Preview\Imaginary"
],
"preview_imaginary_url": "http://dev-nextcloud-imaginary:9000",
"preview_concurrency_all": "12",
"preview_concurrency_new": "8",
"log_rotate_size": 1048576
}
No mounts configured
The text was updated successfully, but these errors were encountered: