[Solved] Can't logout (even though reverse proxy auth is disabled)

Using a Kanboard fresh install (v1.2.57 running with PHP 8.4) without any plugins installed and with LDAP and reverse proxy authentication disabled in the config file, I login using admin:admin default account and:

  • when clicking the Logout button, I am redirected to a URL of the following format: https://domain.tld/kanboard/logout?csrf_token=b8c3c4d86266ae3337a5823e3c0e44b8560bcc7099103229b2801c4f06fae52a
    It sends me to the Dashboard (HTTP response code 200), but I am still logged in.
  • if I manually go to URL https://domain.tld/kanboard/logout I see “Access forbidden” error (HTTP response code 403).

Now if I comment out $this->checkCSRFParam(); in app/Controller/AuthController.php:

  • same thing as above when clicking the Logout button.
  • but logout does work when going to https://domain.tld/kanboard/logout (HTTP response code 302, logged out and redirected to login page).

The app is behind a Nginx reverse proxy, but adding var_dump($_SERVER['REQUEST_URI']); to index.php at the root of kanboard directory outputs something of the following format: "/logout?csrf_token=daebc7508a8baa37792fbb9daba3108aa5a237646ca38889fe55f8ea5e60335f", so I guess the app receives the token as expected.

Anyone able to logout using 1.2.57?
Would you have a guess of what goes wrong here?

Full config.php content:

<?php

/*******************************************************************/
/* Rename this file to config.php if you want to change the values */
/*                                                                 */
/* Make sure all paths are absolute                                */
/*******************************************************************/

// Data folder (must be writeable by the web server user and absolute)
define('DATA_DIR', '/home/yunohost.app/kanboard/');

// Enable/Disable debug
define('DEBUG', false);

// Available log drivers: syslog, stderr, stdout, system or file
define('LOG_DRIVER', 'system');

// Log filename if the log driver is "file"
define('LOG_FILE',  '/home/yunohost.app/kanboard/debug.log');

// Plugins directory
define('PLUGINS_DIR', '/var/www/kanboard/plugins');

// Plugins directory URL
define('PLUGIN_API_URL', 'https://kanboard.org/plugins.json');

// Enable/Disable plugin installer (Disabled by default for security reasons)
// There is no code review or any approval process to submit a plugin.
// This is up to the Kanboard instance owner to validate if a plugin is legit.
define('PLUGIN_INSTALLER', true);

// Cache folder to use if cache driver is "file" (must be writeable by the web server user)
define('CACHE_DIR', '/home/yunohost.app/kanboard/cache');

// Folder for uploaded files (must be writeable by the web server user)
define('FILES_DIR', '/home/yunohost.app/kanboard/files');

// Enable/disable email configuration from the user interface
define('MAIL_CONFIGURATION', true);

// E-mail address used for the "From" header (notifications)
define('MAIL_FROM', 'noreply@REDACTED');

// E-mail address used for the "Bcc" header to send a copy of all notifications
define('MAIL_BCC', '');

// Mail transport available: "smtp", "sendmail", "mail" (PHP mail function), "postmark", "mailgun", "sendgrid"
define('MAIL_TRANSPORT', 'smtp');

// SMTP configuration to use when the "smtp" transport is chosen
define('MAIL_SMTP_HOSTNAME', 'localhost');
define('MAIL_SMTP_PORT', 25);
define('MAIL_SMTP_USERNAME', 'kanboard');
define('MAIL_SMTP_PASSWORD', 'REDACTED');
define('MAIL_SMTP_HELO_NAME', null); // valid: null (default), or FQDN
define('MAIL_SMTP_ENCRYPTION', null); // Valid values are null (not a string "null"), "ssl" or "tls"

// Sendmail command to use when the transport is "sendmail"
define('MAIL_SENDMAIL_COMMAND', '/usr/sbin/sendmail -bs');

// Run automatically database migrations
// If set to false, you will have to run manually the SQL migrations from the CLI during the next Kanboard upgrade
// Do not run the migrations from multiple processes at the same time (example: web page + background worker)
define('DB_RUN_MIGRATIONS', false);

// Database driver: sqlite, mysql, postgres, odbc, dblib, or mssql (sqlite by default)
define('DB_DRIVER', 'mysql');

// Database username
define('DB_USERNAME', 'kanboard');

// Database password
define('DB_PASSWORD', 'REDACTED');

// Database hostname
define('DB_HOSTNAME', 'localhost');

// Database database name
define('DB_NAME', 'kanboard');

// Database custom port (null = default port)
define('DB_PORT', null);

// Mysql SSL key
define('DB_SSL_KEY', null);

// Mysql SSL certificate
define('DB_SSL_CERT', null);

// Mysql SSL CA
define('DB_SSL_CA', null);

// Mysql SSL server verification, set to false if you don't want the Mysql driver to validate the certificate CN
define('DB_VERIFY_SERVER_CERT', null);

// Timeout value for PDO attribute
define('DB_TIMEOUT', null);

// ODBC DSN (default: kanboard)
define('DB_ODBC_DSN', 'kanboard');

// Enable LDAP authentication (false by default)
define('LDAP_AUTH', false);

// LDAP server protocol, hostname and port URL (ldap[s]://hostname:port)
define('LDAP_SERVER', 'ldap://127.0.0.1:389');

// LDAP server port (389 by default)
define('LDAP_PORT', 389);

// By default, require certificate to be verified for ldaps:// style URL. Set to false to skip the verification
define('LDAP_SSL_VERIFY', true);

// Enable LDAP START_TLS
define('LDAP_START_TLS', false);

// By default Kanboard lowercase the ldap username to avoid duplicate users (the database is case sensitive)
// Set to true if you want to preserve the case
define('LDAP_USERNAME_CASE_SENSITIVE', false);

// LDAP bind type: "anonymous", "user" or "proxy"
define('LDAP_BIND_TYPE', 'anonymous');

// LDAP username to use with proxy mode
// LDAP username pattern to use with user mode
define('LDAP_USERNAME', null);

// LDAP password to use for proxy mode
define('LDAP_PASSWORD', null);

// LDAP DN for users
// Example for ActiveDirectory: CN=Users,DC=kanboard,DC=local
// Example for OpenLDAP: ou=People,dc=example,dc=com
define('LDAP_USER_BASE_DN', 'ou=users,dc=yunohost,dc=org');

// LDAP pattern to use when searching for a user account
// Example for ActiveDirectory: '(&(objectClass=user)(sAMAccountName=%s))'
// Example for OpenLDAP: 'uid=%s'
define('LDAP_USER_FILTER', 'uid=%s');

// LDAP attribute for username
// Example for ActiveDirectory: 'sAMAccountName'
// Example for OpenLDAP: 'uid'
define('LDAP_USER_ATTRIBUTE_USERNAME', 'uid');

// LDAP attribute for user full name
// Example for ActiveDirectory: 'displayname'
// Example for OpenLDAP: 'cn'
define('LDAP_USER_ATTRIBUTE_FULLNAME', 'displayname');

// LDAP attribute for user email
define('LDAP_USER_ATTRIBUTE_EMAIL', 'mail');

// LDAP attribute to find groups in user profile
define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');

// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
define('LDAP_USER_ATTRIBUTE_PHOTO', '');

// LDAP attribute for user language, example: 'preferredlanguage'
// Put an empty string to disable language sync
define('LDAP_USER_ATTRIBUTE_LANGUAGE', '');

// Automatically create a user profile when a user authenticates via LDAP.
// If set to false, only LDAP users can log in for whom a Kanboard profile already exists.
define('LDAP_USER_CREATION', true);

// Set new user as Manager
define('LDAP_USER_DEFAULT_ROLE_MANAGER', false);

// LDAP DN for administrators
// Example: CN=Kanboard-Admins,CN=Users,DC=kanboard,DC=local
define('LDAP_GROUP_ADMIN_DN', '');

// LDAP DN for managers
// Example: CN=Kanboard Managers,CN=Users,DC=kanboard,DC=local
define('LDAP_GROUP_MANAGER_DN', '');

// Enable LDAP group provider for project permissions
// The end-user will be able to browse LDAP groups from the user interface and allow access to specified projects
define('LDAP_GROUP_PROVIDER', false);

// LDAP Base DN for groups
define('LDAP_GROUP_BASE_DN', '');

// LDAP group filter
// Example for ActiveDirectory: (&(objectClass=group)(sAMAccountName=%s*))
define('LDAP_GROUP_FILTER', '');

// LDAP user group filter
// If this filter is configured, Kanboard will search user groups in LDAP_GROUP_BASE_DN with this filter
// Example for OpenLDAP: (&(objectClass=posixGroup)(memberUid=%s))
define('LDAP_GROUP_USER_FILTER', '');

// LDAP attribute for the user in the group filter
// 'username' or 'dn'
define('LDAP_GROUP_USER_ATTRIBUTE', 'username');

// LDAP attribute for the group name
define('LDAP_GROUP_ATTRIBUTE_NAME', 'cn');

// Enable/Disable groups synchronization when external authentication is used.
define('LDAP_GROUP_SYNC', true);

// Enable/disable the reverse proxy authentication
define('REVERSE_PROXY_AUTH', false);

// Header name to use for the username
define('REVERSE_PROXY_USER_HEADER', 'REMOTE_USER');

// Username of the admin, by default blank
define('REVERSE_PROXY_DEFAULT_ADMIN', 'admin');

// Header name to use for the user email
define('REVERSE_PROXY_EMAIL_HEADER', 'REMOTE_EMAIL');

// Header name to use for the user full name
define('REVERSE_PROXY_FULLNAME_HEADER', 'REMOTE_NAME');

// Default domain to use for setting the email address
define('REVERSE_PROXY_DEFAULT_DOMAIN', 'REDACTED');

// Enable/disable remember me authentication
define('REMEMBER_ME_AUTH', false);

// Enable or disable "Strict-Transport-Security" HTTP header
define('ENABLE_HSTS', false);

// Enable or disable "X-Frame-Options: DENY" HTTP header
define('ENABLE_XFRAME', true);

// Escape html inside markdown text
define('MARKDOWN_ESCAPE_HTML', true);

// API alternative authentication header, the default is HTTP Basic Authentication defined in RFC2617
define('API_AUTHENTICATION_HEADER', '');

// Enable/disable url rewrite
define('ENABLE_URL_REWRITE', true);

// Hide login form, useful if all your users use Google/Github/ReverseProxy authentication
define('HIDE_LOGIN_FORM', false);

// Disabling logout (useful for external SSO authentication)
define('DISABLE_LOGOUT', false);

// Enable captcha after 3 authentication failure
define('BRUTEFORCE_CAPTCHA', 3);

// Lock the account after 6 authentication failure
define('BRUTEFORCE_LOCKDOWN', 6);

// Lock account duration in minute
define('BRUTEFORCE_LOCKDOWN_DURATION', 15);

// Session duration in second (0 = until the browser is closed)
// See http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
define('SESSION_DURATION', 0);

// Session handler: db or php
define('SESSION_HANDLER', 'db');

// HTTP client proxy
define('HTTP_PROXY_HOSTNAME', '');
define('HTTP_PROXY_PORT', '3128');
define('HTTP_PROXY_USERNAME', '');
define('HTTP_PROXY_PASSWORD', '');
define('HTTP_PROXY_EXCLUDE', 'localhost');

// Set to false to allow self-signed certificates
define('HTTP_VERIFY_SSL_CERTIFICATE', false);

// TOTP (2FA) issuer name
define('TOTP_ISSUER', 'Kanboard');

// Comma separated list of fields to not synchronize when using external authentication providers
define('EXTERNAL_AUTH_EXCLUDE_FIELDS', 'username');

// Enable or disable displaying group-memberships in userlist (true by default)
define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST', true);

// Limit number of groups to display in userlist (The full list of group-memberships is always shown, ...
// ... when hovering the mouse over the group-icon of a given user!)
// If set to 0 ALL group-memberships will be listed (7 by default)
define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT', 7);

// Maximum number of projects displayed in the dashboard
define('DASHBOARD_MAX_PROJECTS', 10);

// Comma separated list of trusted proxy headers, for example: "HTTP_X_REAL_IP,HTTP_X_FORWARDED_FOR"
define('TRUSTED_PROXY_HEADERS', '');

// Comma separated list of trusted proxy IP networks (CIDR), for example: "192.168.0.0/16,10.0.0.0/8,::1/128"
define('TRUSTED_PROXY_NETWORKS', '10.10.10.1/32, ::ffff:a0a:a01/128');

// Allow private network access when fetching metadata for external links
define('EXTERNAL_LINK_ALLOW_PRIVATE_NETWORKS', false);

// Allow private network access for webhook notifications
define('WEBHOOK_ALLOW_PRIVATE_NETWORKS', false);

I know you said you don’t have any plugins installed, but this sounds strangely similar to the token bug in Customizer that prevents logging out.

1 Like

It does look similar, and I have been pointed to the related topic on the forum which is how I came to try this workaround, which works if I remove the token parameter as explained above.
But yes, the major difference is that I am having the issue on a fresh instance without any plugin.

Looking at the fix linked to the issue you pointed on Github, I notice that what is new in this fix is already there for me in bare Kanboard 1.2.57 without plugin. And that it was actually added via a commit to Kanboard merged like one month before the related fix to Customizer. So my guess (although I know nothing about this plugin) is that Customizer copies some of Kanboard functions, and caught up with the upstream changes with this commit.

My issue is different even if it probably deals with the same Kanboard components. Customizer got fixed by adding the token to the logout button’s link. In my case the token is already in that link, the HTTP request is made using the token as parameter, the token goes through the reverse proxy, and I guess the app sees it as I understand the result of the var_dump($_SERVER['REQUEST_URI']); test described in my previous message.

So why do I get a HTTP answer 200 with nothing happening. With the workaround disabling token check, I get a 302 response when the logout works.

I’m thinking that there should be something with the webserver config…
Would you able to confirm that logout works for you when disabling reverse proxy auth ?

So yes that was it…
The nginx conf was not passing $args in the fallback.

Had to change:

alias /var/www/kanboard/;
try_files $uri $uri/ /index.php;

for:

root /var/www/kanboard/;
try_files $uri $uri/ /index.php$is_args$args;

Thank you for the feedback which somehow encouraged me to clarify this.

Excellent! I enjoyed reading your detective work and thought process. Glad you got this fixed and have shared it.