Skip to content

Mailu should redirect to proxy authentication endpoints for users of proxy header authentication #2692

Closed
@ekrekeler

Description

@ekrekeler

Environment & Version

Environment

  • docker-compose
  • kubernetes
  • docker swarm

Version

  • Version: master

Description

This is related to #1972.
I've been testing proxy authentication with a new deployment of mailu. It works as expected, however there is one issue. The default login redirect for WEB_WEBMAIL path /webmail, and WEB_ADMIN path /admin will use /sso/login, where the user is prompted for credentials after completing SSO workflow. When using a proxy for auth, mailu should redirect logins to WEB_WEBMAIL to /sso/proxy and WEB_ADMIN logins to /sso/proxy/admin. We should have a setting in the configuration (disabled by default) to enable redirect to the proxy authentication endpoints. This would keep mailu from prompting users for their credentials where we expect all users to authenticate through the proxy. If proxy authentication breaks or there are users that do not authenticate through the proxy, users can still login by navigating to /sso/login.

As a workaround, I have configured requests to the base URL / to redirect to /sso/proxy using my proxy, but it's not an ideal solution. There is no way to redirect requests to /webmail and /admin to /sso/proxy because the proxy cannot tell if the request has been authenticated against mailu. Configuring redirects on those endpoints will only cause a redirect loop.

Replication Steps

Using docker-compose and mailu master tag. Tested with Google Chrome version 110 on Windows.

  1. Deploy mailu with a reverse proxy to perform authentication. I am using traefik2 for proxy and authentik for IdP.
  2. Configure a user in IdP that will authenticate to mailu. Optionally enable PROXY_AUTH_CREATE in mailu config.
  3. Confirm authentication through proxy works by navigating to /sso/proxy. A successful login will load Webmail.
  4. Logout of any sessions via mailu, or clear cookies set by mailu.
  5. Navigate to base URL /, webmail endpoint /webmail, and admin endpoint /admin.

Observed behaviour

The base URL / redirects to /webmail. This is expected. However, proxy authenticated requests to /webmail and /admin are redirected to /sso/login. Note the requests are correctly authenticated through the proxy, but not yet authenticated with mailu as it hasn't set the roundcube/rainloop/admin session cookies yet. When the browser is redirected here, mailu prompts the user for credentials which we don't want for users already authenticated through the proxy.

Expected behaviour

In environments where a proxy is configured for header authentication to mailu, requests to WEB_WEBMAIL (/webmail) and WEB_ADMIN (/admin) should redirect to /sso/proxy and /sso/proxy/admin respectively when the session cookies are unset/invalid/expired.

Logs

I don't think logs are necessary for this, but let me know if I can help by providing any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions