PhoenixKit 1.7.235: Rank checks on user management and safer OAuth sign-in
PhoenixKit 1.7.235 is a security release. It makes managing other users follow rank, ends a deactivated user’s sessions, and stops provider sign-in from taking over an account on a matching email alone.
What was fixed
On the admin user form, the password, the reset email, the email and the username could be changed by anyone with access to the admin area. They now follow rank: an Owner or Admin target can be managed only by an Owner. Activating, deactivating, confirming and deleting users check the same rule on every page, not only in the edit form. Deactivating a user now deletes their sessions, and a deactivated account can no longer sign in by magic link, QR code or OAuth.
OAuth sign-in joined an existing account whenever the provider returned the same email. It now needs the provider to say it verified the address. Settings → Authorization has a new checkbox, Require the provider to confirm the email address, on by default. A new unconfirmed OAuth account is now sent the confirmation mail.
The background colour on the sign-in page branding settings could carry a script to anonymous visitors. Values are now checked on save and on display, which also cleans values already stored.
Upgrading
No migration. If OAuth users with unverified addresses can no longer join their accounts, that is the new default.
Full release notes: PhoenixKit 1.7.235
1.7.235 · 7 August 2026
Security
- Credential management on the admin user form now answers to rank, not to a
permission (#686).
/admin/users/edit/:idgated the password field onScope.can_access_admin_area?/1— true for any holder of a single permission — while the comment above it said “Admin/Owner only”, and nothing else in the path checked rank. NewAuth.can_manage_user_credentials?/2decides by role and rank (your own account is yours; the actor must be Owner/Admin; an Owner or Admin target may be managed only by an Owner), and it gates the password field, the reset-mail button and the email field — owning the address a reset link is delivered to takes an account just as surely as setting the password does.usernameis dropped with them, sinceget_user_by_email_or_username_and_password/3accepts it as a sign-in route. Every event refuses independently of the template. - Deactivation now revokes sessions instead of merely denying them (#686).
update_user_status/3flippedis_activeand left the token rows valid for their full 60-day life; it now deletes the user’s session tokens. - Activation, deactivation and email-confirmation toggling are rank-checked in
the context (#686).
update_user_status/3andtoggle_user_confirmation/2take an:actorand enforceAuth.can_manage_user_status?/2; omitting the actor is the system path (Referrals). The rule lived only in the edit form’s markup, so the user-list and user-detail pages reached both functions ungated — a role holding onlyuserscould switch off an Admin, and unconfirming an account locks it out of the eleven gates that honourrequire_email_confirmation. - Deleting a user answers to that same rank rule (#686 post-merge review).
can_delete_user?/2refused only an Admin target and never checked the actor’s role at all, deferring that to a page gate that admits any single permission holder. Because an Owner holds only theOwnerrole, an Admin — or ausers-permission role — could delete any Owner who was not the last one. It now routes through the same authority check; the self and last-Owner rules keep their own messages. - Multi-session resolves the root account through the active-user filter
(#686).
root_user/1androot_authenticated?/1used a bare token lookup, so a deactivated Owner/Admin holding a live cookie could still reachPOST /users/session/impersonate/:uuid. The same filter was added toPhoenixKitWeb.Users.Session, the OAuth scope resolver and the maintenance plug. - A deactivated account is refused at the shared sign-in funnel (#686).
log_in_user/3checksis_activeitself — the password controller did, but magic-link verification, QR-login completion and the OAuth callback called it directly and did not. - Stored XSS in the auth-page branding settings (#686).
AuthPageWrapper.bg_style_tag/1built a<style>element by string concatenation and emitted it withraw/1; a<style>body is raw character data, so</style>in the background-colour value closed the element. The value is free text on/admin/settings/authorization(keysettings, held by Manager as well as Admin) and is served to every anonymous visitor of the login, registration and reset pages. NewPhoenixKit.Utils.CssValueis an allowlist that fails to"", applied on read (neutralising anything already stored), in the one function that assembles the stylesheet, and on write. - OAuth no longer attaches an external identity on email string equality
(#686).
find_or_create_user/3looked the callback address up locally and, on a hit, confirmed that account and issued a session — no verification claim read, no prior link required. Resolution is now ordered by the proof each case carries: an existing(provider, provider_uid)link is decisive and consults no email; a pre-existing local account requires the provider’s own assertion (Google/OIDCemail_verified, GitHub per-addressverified, Facebookverified); a new account is created but auto-confirmed only on an assertion. GitHub’s strategy is now configured withdefault_scope: "user:email", without which the token cannot read/user/emailsand the claim is never present.
Added
oauth_require_verified_emailsetting (default"true", #686) with a checkbox on the authorization settings page — lets a deployment lift the verified-address requirement deliberately rather than by accident.
Fixed
- A new OAuth account that is left unconfirmed is now sent the confirmation
mail (#686 post-merge review). Nothing on the OAuth path ever sent it —
Auth.register_user/2does not, and only the registration controller did — so an account the provider did not vouch for was signed in with “Successfully signed in!” and then bounced off every gate honouringrequire_email_confirmation, with an empty inbox. - The confirm/unconfirm menu entry is gated like its status twin (#686 post-merge review). Only the status button was hidden for an out-of-rank target, so the confirmation button next to it advertised an action the server now refuses.
- The new per-row rank guard no longer queries per row (#686 post-merge
review).
can_manage_user_status?/2in the users-list template asked up to fourEXISTSquestions per row — ~200 round trips on a fifty-row page, on every sort, filter and PubSub re-render — even thoughlist_users_paginated/1already preloads:roles. The rank rule now reads a preloaded:rolesassociation when there is one, and the list hands it an actor loaded once.
PhoenixKit 1.7.235. Install or update: {:phoenix_kit, "~> 1.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.