Skip to content

feat(oauth): add optional host-based automatic Generic OAuth login - #1654

Open
NicolasRoelofs wants to merge 4 commits into
crocodilestick:mainfrom
NicolasRoelofs:feat/optional-oauth-auto-login
Open

NicolasRoelofs wants to merge 4 commits into
crocodilestick:mainfrom
NicolasRoelofs:feat/optional-oauth-auto-login

Conversation

@NicolasRoelofs

Copy link
Copy Markdown

feat(oauth): add optional host-based automatic Generic OAuth login

Summary

Add an optional, disabled-by-default feature to automatically initiate Generic OAuth authentication when an unauthenticated visitor accesses the CWA home page using a configured hostname.

This eliminates the need to manually select "Log in with SSO" after passing through an external authentication gateway.

Motivation

Some deployments use an external OIDC authentication gateway in front of CWA while retaining anonymous access through a separate local network address.

After successful gateway authentication, CWA may still display its anonymous Guest session.

Users must then manually initiate CWA's own OAuth login to access their personal account.

This feature provides an optional automatic transition into the existing Generic OAuth flow.

Configuration

CWA_OAUTH_AUTO_LOGIN_HOSTS=books.example.com

The setting is optional and disabled by default.

Multiple hosts may be specified as a comma-separated list.

Expected behavior

  • Automatic OAuth login is triggered only for explicitly configured hostnames.
  • Existing authenticated CWA sessions remain unchanged.
  • Unconfigured hosts retain their current behavior.
  • Anonymous local browsing remains possible.
  • The existing Generic OAuth login flow and account-linking logic are reused.
  • Automatic retries are limited to avoid infinite authentication redirects.
  • No database schema changes are introduced.

Security considerations

The hostname setting controls login initiation only. It does not grant authorization or establish user identity.

Normal OAuth token validation and CWA account permissions remain authoritative.

Reverse proxy configurations must continue to enforce their own authentication and access restrictions.

Compatibility

The feature is opt-in and should not change existing CWA installations when the environment variable is unset.

Validation

The equivalent host-specific redirect behavior was manually validated with CWA v4.0.8 behind an external OIDC authentication gateway.

The generalized environment-variable implementation still requires regression tests and review against the current development branch.

Scope

This PR introduces optional automatic Generic OAuth initiation.

It does not modify identity-to-account linking or depend on a specific identity provider, reverse proxy, or network appliance.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant