Repository navigation
Conversation
The access and ID tokens of each login are encrypted (XChaCha20-Poly1305) in a site transient, with a key derived from the session token in WordPress's login cookie and the AUTH salt. The database, its backups and staging copies no longer hold a token anyone can read. Back-channel logout (logout_token and the old ?state=) ends a session by deleting a per-sid marker. Also: - Token endpoints and person UID/groups need a WordPress login. - Endpoints skip the session-expired redirect, so widgets get '' instead. - Plaintext token transients of older versions are purged after the update, daily and from "Delete subscribers". - New PHP API for themes; reads of the old oidc_* transients keep working for logged-in visitors for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Users log in again once after this update, as tokens are now stored sealed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved security flaws allow legacy endpoints to cache plaintext tokens, sessions to cross OIDC-client boundaries, and concurrent login callbacks to reactivate sessions revoked by back-channel logout.
3 open issues
What changed in this PR
BCC Login 1.3.0 replaces plaintext OIDC token storage with encrypted session storage tied to the browser’s WordPress login cookie. Existing users must log in again after deployment.
Changes:
- Adds encrypted token storage and session-marker-based back-channel logout.
- Routes token endpoints and theme APIs through the authenticated session, with legacy transient compatibility.
- Adds legacy plaintext cleanup, documents the new APIs, and bumps the release version.
| File | Description |
|---|---|
| plugins/bcc-login/package.json | Bumps version to 1.3.0. |
| plugins/bcc-login/includes/class-bcc-login-visibility.php | Allows token endpoints to return empty responses for expired sessions. |
| plugins/bcc-login/includes/class-bcc-login-settings.php | Adds plaintext-token cleanup to Delete subscribers. |
| plugins/bcc-login/includes/class-bcc-login-session-vault.php | Implements token encryption, storage, and revocation markers. |
| plugins/bcc-login/includes/class-bcc-login-client.php | Integrates the vault, token APIs, and compatibility filters. |
| plugins/bcc-login/includes/class-bcc-login-cleanup.php | Schedules and performs legacy plaintext-token deletion. |
| plugins/bcc-login/endpoints/user-profile.php | Reads the ID token through the session API. |
| plugins/bcc-login/endpoints/logout.php | Revokes sessions by SID or legacy state. |
| plugins/bcc-login/endpoints/id-token.php | Uses authenticated ID-token retrieval. |
| plugins/bcc-login/endpoints/clear-cookies.php | Deletes stored tokens before clearing cookies. |
| plugins/bcc-login/endpoints/access-token.php | Uses authenticated access-token retrieval. |
| plugins/bcc-login/bcc-login.php | Loads the vault and exposes the login client. |
| docs/signon/getting-user-information.md | Documents endpoint behavior, PHP APIs, and encrypted storage. |
Review effort: Balanced
- Bind each session to the generation of its sid marker, so a marker created again by a later login doesn't bring back sessions a back-channel logout ended. - Store the tokens per OIDC client (and scope): a site of a network that logs in with another client gets its own tokens and never those of another client. The same person logging in again keeps their WordPress session, so moving between such sites doesn't replace the login cookie (and other sites' tokens). - Serve the old oidc_* transient reads only on pages the theme renders, so scripts that load WordPress themselves (like BCC Signon's access-token.php, which keeps what it reads in the PHP session) don't get the tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
load() only accepts sealed tokens while their sid marker exists with the same generation, but save() didn't check that the marker was written (set_site_transient() also returns false when the value doesn't change). If the write was lost, every login succeeded and the next page found the session invalid, which started a silent loop through login.bcc.no. Read the marker back and fail the login, as when the tokens can't be stored, if it's missing. If a login of the same sid at the same moment wrote another generation, the tokens take that one instead of failing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013xX9Qfhaxav4Uigkz4HaF5
- The cleanup right after the update marked the old tokens as deleted even when a query failed. It now retries in an hour instead, and is only marked as done once it succeeded (or was skipped because BCC Signon stores its tokens under the same names, which it now reports as null rather than 0). - A failed batch no longer skips clearing the cached options, as the rows of earlier batches are deleted. - The back-channel logout answers 400 when it couldn't end the sessions (their marker is still there after deleting it) or can't handle the request (no sid or state), so login.bcc.no doesn't take it as done, and sends Cache-Control: no-store. The state is kept when its marker couldn't be deleted, so the logout can be retried. - A login fails, before its tokens are stored, when the state for the old back-channel logout can't be stored, as it already did for the sid marker. - An existing session that couldn't be extended to the new tokens' expiry isn't reused: a new session lasts as long as they do. - Starting the login again because the tokens couldn't be loaded keeps them, so a failed read (e.g. the object cache briefly unavailable) doesn't lose them. - The settings page says when the old tokens were kept because BCC Signon is active, and that a site of a network only removes its own expired transients. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013xX9Qfhaxav4Uigkz4HaF5
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The access and ID tokens are no longer stored readable anywhere on the server. They're encrypted, and only the browser's WordPress login cookie holds what's needed to decrypt them. Static checks and a local WordPress test pass, but a real login through login.bcc.no hasn't been tried yet.
How it works
wordpress_logged_in_*cookie plus the AUTH salt in wp-config. WordPress stores only a hash of that token.oidc_token_idcookie is gone.?state=style still works.What changes for users and themes
''(for example the analytics widget). Before, a leftoveroidc_token_idcookie was enough.'', which widgets handle; before, theirfetchfailed on the redirect.bcc_login()->get_client()->get_current_id_token_claims(), plusget_current_access_token()andget_current_id_token(). It's documented indocs/signon/getting-user-information.md.The core change is in
includes/class-bcc-login-session-vault.php(new) andincludes/class-bcc-login-client.php.Checks
php -lpasses on PHP 7.4 and 8.4. PHPStan level 1 and Psalm with taint analysis also pass, both set up like CI.eyJ…tokens remain inwp_options; try the widgets, a real back-channel logout from Auth0, and log out.Version: bumped to 1.3.0 in
package.json, since this makes everyone log in again. CI releases it as 1.3.0 when merged.Follow-ups
functions.php,template-parts/posts/theme-resources.php) still reads the old transients and puts the access token into iframe URLs. Once it uses the new API, the compatibility layer can be removed.logout_tokensignature. That was already the case before this change.After Copilot's review (c70d776)
sidmarker. A marker created again by a later login can't bring back sessions that a back-channel logout ended.oidc_*transient reads only works on pages the theme renders. Scripts that load WordPress themselves, like BCC Signon'saccess-token.php(which writes what it reads into the PHP session), get nothing.🤖 Generated with Claude Code