Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
930b1587a0 | ||
|
|
358ee5d308 | ||
|
|
aa8396916e |
16
README.md
16
README.md
@@ -17,18 +17,18 @@ It owns the `users` table extensions, `user_throttle`, `jwt_blacklist`, `user_ap
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Registration and activation.** `POST /register`, `POST /activate`, `POST /activate-by-code`. Registration can be switched off and throttled; `activate_mode` is `auto`, `user` (a mailed code) or `admin`, with codes from `IssueActivationCode` and `VerifyActivationCode`. A `/register` body sets only the `User.RegisterFillable` columns: `name`, `surname`, `email`, `password` (stored as its hash), `preferred_locale` and `marketing_consent`. It cannot set `organisation_id` or `organisation_role` (membership is the administrator's or the application's), `is_onboarded`, `must_change_password`, or the activation, reset, address proof, handle and permission columns; other keys are ignored (they still reach `RegisterEvent.Payload`). `created_ip_address` and `last_ip_address` are server-set from the client address only.
|
- **Registration and activation.** `POST /register`, `POST /activate`, `POST /activate-by-code`. Registration can be switched off and throttled; `activate_mode` is `auto`, `user` (a mailed code) or `admin`, with codes from `IssueActivationCode` and `VerifyActivationCode`. A `/register` body sets only the `User.RegisterFillable` columns: `name`, `surname`, `email`, `password` (stored as its hash), `preferred_locale` and `marketing_consent`. It cannot set `organisation_id` or `organisation_role` (membership is the administrator's or the application's), `is_onboarded`, `must_change_password`, or the activation, reset, address proof, handle and permission columns; other keys are ignored (they still reach `RegisterEvent.Payload`). `created_ip_address` and `last_ip_address` are server-set from the client address only.
|
||||||
- **JWT sessions.** `POST /login`, `GET /fetch`, `POST /refresh`, `POST /logout`. Boot registers the `jwt` guard with the framework's `bouncer.Registry` and exposes it as the `jwt.auth` middleware for other plugins. Logged-out tokens go to the Postgres `jwt_blacklist`, which a background sweep prunes. `POST /refresh` loads the token's user and refuses (401, `Could not refresh token`, `User not found`) a deactivated or banned user and a token issued before the user's `tokens_valid_after`; a suspension alone does not stop a refresh.
|
- **JWT sessions.** `POST /login`, `GET /fetch`, `POST /refresh`, `POST /logout`. Boot registers the `jwt` guard with the framework's `bouncer.Registry` and exposes it as the `jwt.auth` middleware for other plugins. `POST /logout` ends the session however the token travels: the bearer header, or only the `token` or `auth_token` cookie the guard also reads. Every session token the request carries goes to the Postgres `jwt_blacklist` until its refresh window closes (the later of `exp` and `iat` plus `refresh_ttl`, plus a minute), so the guard refuses it on the next request and `POST /refresh` cannot revive it after the access token expired; a token whose access lifetime passed is revoked too while it could still be refreshed. The answer, a 401 included, expires the `auth.cookie.*` token cookie (the one `golem15.sociallogin`'s `token_cookie` sets), and any other session cookie the request carries, with that cookie's path, domain, SameSite and Secure. A background sweep prunes the blacklist. `POST /refresh` loads the token's user and refuses (401, `Could not refresh token`, `User not found`) a deactivated or banned user and a token issued before the user's `tokens_valid_after`; a suspension alone does not stop a refresh.
|
||||||
- **Password reset and change.** `POST /forgot-password` answers the same body for known and unknown addresses; `POST /reset-password` consumes a code from `IssueResetCode`. `POST /change-password` requires the current password.
|
- **Password reset and change.** `POST /forgot-password` answers the same body for known and unknown addresses; `POST /reset-password` consumes a code from `IssueResetCode`. `POST /change-password` requires the current password.
|
||||||
- **Must-change-password lock.** The `user:require-password-change` console command flags an account. The flag rides on the authenticated principal (`bouncer.Principal.MustChangePassword`) for guards and other plugins to act on, and a successful `POST /change-password` clears it.
|
- **Must-change-password lock.** The `user:require-password-change` console command flags an account. The flag rides on the authenticated principal (`bouncer.Principal.MustChangePassword`) for guards and other plugins to act on, and a successful `POST /change-password` clears it.
|
||||||
- **Login throttling.** Failed logins are counted per user and IP in `user_throttle` (`CheckAndRecordLogin`, `RejectIfThrottled`) and suspend the account for a configured time.
|
- **Login throttling.** Failed logins are counted per user and IP in `user_throttle` (`CheckAndRecordLogin`, `RejectIfThrottled`) and suspend the account for a configured time.
|
||||||
- **Rate limiting.** Every route runs behind the `user-api` bucket: 120 requests a minute per authenticated user, or per client IP for anonymous calls.
|
- **Rate limiting.** Every route runs behind the `user-api` bucket: 120 requests a minute per authenticated user, or per client IP for anonymous calls.
|
||||||
- **Profile.** `POST /update`, `POST /marketing-consent`, `POST /avatar` and `POST /avatar/remove` (the avatar is stored through the framework's attachment storage).
|
- **Profile.** `POST /update`, `POST /marketing-consent`, `POST /avatar` and `POST /avatar/remove` (the avatar is stored through the framework's attachment storage).
|
||||||
- **Deactivation and bans.** Deactivation is self-service and reversible: a password login or a `golem15.sociallogin` sign-in restores a deactivated account and sends the reactivate mail, and an administrator can restore it too. It ends every earlier session JWT and personal API token of the user (`RevokeUserAccess` stamps `tokens_valid_after` and revokes the `user_api_tokens` rows), so the user signs in again and gets a fresh token, while the old API tokens stay revoked. A ban is the lock: password login, social sign-in and `POST /refresh` refuse a banned user, and banning revokes the user's sessions and API tokens. Neither unban nor restore revives a token. Upgrade note: accounts deactivated or banned before this version keep their API tokens until they are deactivated or banned again (both actions are idempotent) or `RevokeUserAccess` runs for them.
|
- **Deactivation and bans.** Deactivation is self-service and reversible: a password login or a `golem15.sociallogin` sign-in restores a deactivated account and sends the reactivate mail, and an administrator can restore it too. It ends every earlier session JWT and personal API token of the user (`RevokeUserAccess` stamps `tokens_valid_after` and revokes the `user_api_tokens` rows), so the user signs in again and gets a fresh token, while the old API tokens stay revoked. A ban is the lock: password login, social sign-in and `POST /refresh` refuse a banned user, and banning revokes the user's sessions and API tokens. Neither unban nor restore revives a token. Upgrade note: accounts deactivated or banned before this version keep their API tokens until they are deactivated or banned again (both actions are idempotent) or `RevokeUserAccess` runs for them.
|
||||||
- **Organisations.** The `Organisation` model and the `organisation_id` and `organisation_role` user columns, as a foreign-key target for other plugins. An organisation has a name, a slug (filled from the name by `Slugify` when it is left empty), a description, an avatar and its members: the users whose `organisation_id` points at it.
|
- **Organisations.** The `Organisation` model and the `organisation_id` and `organisation_role` user columns, as a foreign-key target for other plugins. An organisation has a name, a slug (filled from the name by `Slugify` when it is left empty), a description, an avatar and its members: the users whose `organisation_id` points at it. `organisation_role` belongs to that membership: the admin clears it whenever a user's organisation changes (see the Organisations screen), and an application that sets `organisation_id` itself sets or clears the role with it.
|
||||||
- **User groups.** The `user_groups` table (seeded with the `guest` and `registered` groups, as in PHP) and the `users_groups` membership pivot, the `UserGroup` model and the `User.Groups` relation, which is never serialized. `UserGroupCodes` and `HasGroupCode` let other plugins check membership server-side, for example a site-admin check on the group code `admin`. No user API route reads or writes groups, and the user payload still answers `"groups":[]`. Membership is written in one place only: the `groups` field of the admin user form. Apart from that, rows leave `users_groups` only when a user or a group is deleted for good. The admin Users list can filter by group.
|
- **User groups.** The `user_groups` table (seeded with the `guest` and `registered` groups, as in PHP) and the `users_groups` membership pivot, the `UserGroup` model and the `User.Groups` relation, which is never serialized. `UserGroupCodes` and `HasGroupCode` let other plugins check membership server-side, for example a site-admin check on the group code `admin`. No user API route reads or writes groups, and the user payload still answers `"groups":[]`. Membership is written in one place only: the `groups` field of the admin user form. Apart from that, rows leave `users_groups` only when a user or a group is deleted for good. The admin Users list can filter by group.
|
||||||
- **Admin screens.** The plugin registers the Users screen with the framework's admin (`pact.HasAdminControllers`, controller ID `golem15.user.users`), the port of the WinterCMS `Users` controller: a list with search, the group, registration date and activated filters and row states (deactivated, banned, not activated); a read-only preview with a status hint; and a form with name, email, a password with confirmation, an optional invitation mail, the user's groups, the organisation, the avatar and the user's frontend permissions. Bulk actions activate, deactivate, restore, ban and unban users; the preview offers activate, unban and unsuspend while they apply. Deactivating is the soft delete, and deactivate and ban both end the user's earlier sessions and personal API tokens (see Deactivation and bans); the delete button and the bulk delete remove a user for good, together with the throttle rows, group memberships and attachments. A user created in the admin starts not activated. There is no impersonation and no guest account.
|
- **Admin screens.** The plugin registers the Users screen with the framework's admin (`pact.HasAdminControllers`, controller ID `golem15.user.users`), the port of the WinterCMS `Users` controller: a list with search, the group, registration date and activated filters and row states (deactivated, banned, not activated); a read-only preview with a status hint; and a form with name, email, a password with confirmation, an optional invitation mail, the user's groups, the organisation, the avatar and the user's frontend permissions. Bulk actions activate, deactivate, restore, ban and unban users; the preview offers activate, unban and unsuspend while they apply. Deactivating is the soft delete, and deactivate and ban both end the user's earlier sessions and personal API tokens (see Deactivation and bans); the delete button and the bulk delete remove a user for good, together with the throttle rows, group memberships and attachments. A user created in the admin starts not activated. There is no impersonation and no guest account.
|
||||||
- **User Groups screen.** Controller ID `golem15.user.usergroups`, the port of the WinterCMS `UserGroups` controller, behind `golem15.users.access_groups`: a list with the name, code, creation date and number of members, and a form with the name, the code (letters, digits, underscore and hyphen; unique), a description and the group's frontend permissions as checkboxes, stored in `user_groups.permissions` as a JSON object of code to `1`. A group can be deleted from its form; its memberships go with it and its members stay. The screen never changes who is in a group.
|
- **User Groups screen.** Controller ID `golem15.user.usergroups`, the port of the WinterCMS `UserGroups` controller, behind `golem15.users.access_groups`: a list with the name, code, creation date and number of members, and a form with the name, the code (letters, digits, underscore and hyphen; unique), a description and the group's frontend permissions as checkboxes, stored in `user_groups.permissions` as a JSON object of code to `1`. A group can be deleted from its form; its memberships go with it and its members stay. The screen never changes who is in a group.
|
||||||
- **Organisations screen.** Controller ID `golem15.user.organisations`, the port of the WinterCMS `Organisations` controller, behind `golem15.users.access_users`: a list and a form with the name, slug, description and avatar, and on an existing organisation the Members tab. Adding a member sets that user's `organisation_id` and removing one clears it; a user is never deleted. Only users without an organisation can be added, so a user moves by being removed from one organisation and added to the other (or through the organisation field of the user form). Deleting an organisation clears `organisation_id` and `organisation_role` of its members first.
|
- **Organisations screen.** Controller ID `golem15.user.organisations`, the port of the WinterCMS `Organisations` controller, behind `golem15.users.access_users`: a list and a form with the name, slug, description and avatar, and on an existing organisation the Members tab. Adding a member sets that user's `organisation_id` and removing one clears it; both also clear the user's `organisation_role`, so a role never moves to another organisation or outlives the membership. A user is never deleted. Only users without an organisation can be added, so a user moves by being removed from one organisation and added to the other (or through the organisation field of the user form, where a save that changes the organisation, to another one or to none, clears `organisation_role` unless the same save writes it). Deleting an organisation clears `organisation_id` and `organisation_role` of its members first.
|
||||||
- **Privileged groups.** The groups whose code is listed in `golem15.user.privileged_groups` (default `admin`) are privileged: an application may treat their members as site administrators. Three things therefore need the backend permission `golem15.users.manage_privileged_groups` on top of the screen's own permission, and answer 403 without it, saving nothing. First, membership: adding a privileged group to a user or removing it, on create and on update of the user form. An administrator without the permission sees those groups locked in the field and can still change the user's other groups. Second, the code: creating a group with a privileged code, changing a group's code to or from a privileged one, and deleting a privileged group. Its name, description and frontend permissions need only `golem15.users.access_groups`. Codes compare case-sensitively, and a group without a code is never privileged. Third, the member's account, which is protected against takeover: changing that user's email or password, and deleting them for good, needs the backend permission `golem15.users.manage_privileged_groups` on top of `golem15.users.access_users`. Without it the request answers 403 and nothing is saved; a bulk delete that contains such a user deletes none of the selected users. Everything else on such a user (name, organisation, avatar, frontend permissions, activate, deactivate, restore, ban, unban, unsuspend) needs only `golem15.users.access_users`. `PrivilegedGroupCodes`, `IsPrivilegedCode`, `PrivilegedGroupIDs` and `IsPrivilegedMember` expose the rule to other code.
|
- **Privileged groups.** The groups whose code is listed in `golem15.user.privileged_groups` (default `admin`) are privileged: an application may treat their members as site administrators. Three things therefore need the backend permission `golem15.users.manage_privileged_groups` on top of the screen's own permission, and answer 403 without it, saving nothing. First, membership: adding a privileged group to a user or removing it, on create and on update of the user form. An administrator without the permission sees those groups locked in the field and can still change the user's other groups. Second, the code: creating a group with a privileged code, changing a group's code to or from a privileged one, and deleting a privileged group. Its name, description and frontend permissions need only `golem15.users.access_groups`. Codes compare case-sensitively, and a group without a code is never privileged. Third, the member's account, which is protected against takeover: changing that user's email or password, and deleting them for good, needs the backend permission `golem15.users.manage_privileged_groups` on top of `golem15.users.access_users`. Without it the request answers 403 and nothing is saved; a bulk delete that contains such a user deletes none of the selected users. Everything else on such a user (name, organisation, avatar, frontend permissions, activate, deactivate, restore, ban, unban, unsuspend) needs only `golem15.users.access_users`. `PrivilegedGroupCodes`, `IsPrivilegedCode`, `PrivilegedGroupIDs` and `IsPrivilegedMember` expose the rule to other code.
|
||||||
- **Frontend permissions.** `golem15_user_frontend_permissions` is the catalogue of permissions a site defines for its users (rows come from the application's migrations or seeds). A user's own choices are stored in `users.permissions` and a group's in `user_groups.permissions`, as a JSON object of code to `1` (allow) or `-1` (deny). `MergedPermissions` combines them as PHP `getMergedPermissions` does: among a user's groups the most positive value wins, then the user's own value replaces the groups'. `HasPermission` and `UserHasPermission` answer whether a code is held: only at exactly `1`, with Winter's `*` wildcards. Neither value appears in the user payload, whose `permissions` key stays `null`.
|
- **Frontend permissions.** `golem15_user_frontend_permissions` is the catalogue of permissions a site defines for its users (rows come from the application's migrations or seeds). A user's own choices are stored in `users.permissions` and a group's in `user_groups.permissions`, as a JSON object of code to `1` (allow) or `-1` (deny). `MergedPermissions` combines them as PHP `getMergedPermissions` does: among a user's groups the most positive value wins, then the user's own value replaces the groups'. `HasPermission` and `UserHasPermission` answer whether a code is held: only at exactly `1`, with Winter's `*` wildcards. Neither value appears in the user payload, whose `permissions` key stays `null`.
|
||||||
- **Last seen.** `users.last_seen` is stamped by `POST /login` and a successful `POST /refresh` through `TouchLastSeen`, at most once per five minutes per user. A failed write is logged and never fails authentication. It is shown in the admin list and is not part of any user payload.
|
- **Last seen.** `users.last_seen` is stamped by `POST /login` and a successful `POST /refresh` through `TouchLastSeen`, at most once per five minutes per user. A failed write is logged and never fails authentication. It is shown in the admin list and is not part of any user payload.
|
||||||
@@ -186,7 +186,8 @@ Packages:
|
|||||||
- `RevokeUserAccess(ctx, db, userIDs)` ends every session JWT issued before the current second (it stamps `users.tokens_valid_after`, deactivated rows included) and revokes every personal API token of the users. `DeactivateUsers` and `BanUsers` call it; an application may call it for its own offboarding and after writing a ban directly to `user_throttle`.
|
- `RevokeUserAccess(ctx, db, userIDs)` ends every session JWT issued before the current second (it stamps `users.tokens_valid_after`, deactivated rows included) and revokes every personal API token of the users. `DeactivateUsers` and `BanUsers` call it; an application may call it for its own offboarding and after writing a ban directly to `user_throttle`.
|
||||||
- `TouchLastSeen(ctx, db, userID)`.
|
- `TouchLastSeen(ctx, db, userID)`.
|
||||||
- `OAuthProvider` (`Name`, `Label`) and `OAuthProviderSource` (`EnabledOAuthProviders(ctx)`, `KnownOAuthProviders()`), the seam a social-login plugin publishes with an explicit type argument, `app.Publish[classes.OAuthProviderSource](src)`, so the lookup finds it. `GET /oauth-providers` lists its enabled providers in order; the unlink routes accept its known names.
|
- `OAuthProvider` (`Name`, `Label`) and `OAuthProviderSource` (`EnabledOAuthProviders(ctx)`, `KnownOAuthProviders()`), the seam a social-login plugin publishes with an explicit type argument, `app.Publish[classes.OAuthProviderSource](src)`, so the lookup finds it. `GET /oauth-providers` lists its enabled providers in order; the unlink routes accept its known names.
|
||||||
- `RequestUser(ctx, app, r)` and `EndRequestSession(ctx, app, w, r)`, for handlers that serve signed-in and anonymous browsers on one route (an OAuth provider's authorize page). `RequestUser` reads and checks the session JWT exactly as the `jwt` guard does (bearer header, then the `token` and `auth_token` cookies, the blacklist, `tokens_valid_after`) and returns the user, or `nil` for an anonymous, invalid, expired or blacklisted request and for a soft-deleted user; only an infrastructure failure is an error. `EndRequestSession` blacklists the request's JWT until it expires (as `POST /logout` does) and writes the forget cookie of `bouncer.LoadCookieConfig`, best effort: a blacklist failure is logged, never returned.
|
- `EndSession(ctx, app, w, r)` is what `POST /logout` runs: it blacklists every session JWT the request carries (bearer header, `token` and `auth_token` cookies) that verifies, an expired one too while its refresh window is open, until that window closes, writes the forget cookies described under JWT sessions, and returns the subject of the token the guard would read (`""` when there is none or it does not verify); only a failing blacklist write is an error.
|
||||||
|
- `RequestUser(ctx, app, r)` and `EndRequestSession(ctx, app, w, r)`, for handlers that serve signed-in and anonymous browsers on one route (an OAuth provider's authorize page). `RequestUser` reads and checks the session JWT exactly as the `jwt` guard does (bearer header, then the `token` and `auth_token` cookies, the blacklist, `tokens_valid_after`) and returns the user, or `nil` for an anonymous, invalid, expired or blacklisted request and for a soft-deleted user; only an infrastructure failure is an error. `EndRequestSession` is the best-effort `EndSession`: it revokes and forgets the same way (the forget cookie of `bouncer.LoadCookieConfig`), but a blacklist failure is logged, never returned.
|
||||||
- `AvatarURL(ctx, app, user, size)`, the display picture rule of the user payload at any size: the avatar thumbnail (size by size, mode auto) when the user has an avatar and a file bucket is published, the file path when the thumbnail fails, otherwise the gravatar URL. The URL may be protocol-relative or relative. The payload's `avatar_url` comes from it at 128.
|
- `AvatarURL(ctx, app, user, size)`, the display picture rule of the user payload at any size: the avatar thumbnail (size by size, mode auto) when the user has an avatar and a file bucket is published, the file path when the thumbnail fails, otherwise the gravatar URL. The URL may be protocol-relative or relative. The payload's `avatar_url` comes from it at 128.
|
||||||
- `HandleGenerator`, `AssignHandle(ctx, db, user)`, `CreatedEvent` / `CreatedEventName`, `DeletingEvent` / `DeletingEventName`, `DeactivatingEvent` / `DeactivatingEventName`, `AuthorizeUser` and `RegisterUserAuthorizer`.
|
- `HandleGenerator`, `AssignHandle(ctx, db, user)`, `CreatedEvent` / `CreatedEventName`, `DeletingEvent` / `DeletingEventName`, `DeactivatingEvent` / `DeactivatingEventName`, `AuthorizeUser` and `RegisterUserAuthorizer`.
|
||||||
- `middleware`: `APITokenGuard`, `Scope`, `Permission` and `BearerToken`.
|
- `middleware`: `APITokenGuard`, `Scope`, `Permission` and `BearerToken`.
|
||||||
@@ -235,7 +236,8 @@ Each command uses the database the serve command published or, run from the cons
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- The SummerCMS framework v0.4.0, `git.golem15.com/golem15/summercms` (modules `backpack`, `bonfire`, `bouncer`, `diary`, `pact`, `party`, `surf` and others).
|
- The SummerCMS framework v0.4.3, `git.golem15.com/golem15/summercms` (modules `backpack`, `bonfire`, `bouncer`, `diary`, `pact`, `party`, `surf` and others).
|
||||||
|
- The organisation role cleanup of the admin (members manager and user form) uses cabana's `ClearOnChange`, added in SummerCMS v0.4.3.
|
||||||
- gormigrate, GORM, golang-jwt and gocloud.dev, as pinned in `go.mod`.
|
- gormigrate, GORM, golang-jwt and gocloud.dev, as pinned in `go.mod`.
|
||||||
- testcontainers-go for the Postgres-backed tests.
|
- testcontainers-go for the Postgres-backed tests.
|
||||||
|
|
||||||
@@ -254,4 +256,8 @@ go test ./... # full run, starts Postgres with testcontainers (needs D
|
|||||||
|
|
||||||
`TestOffboarding` runs the admin deactivate and ban bulk actions and checks that the user's older session JWT and personal API token stop working, that a password login restores a deactivated account with a working token while the old credentials stay dead, and that unban revives nothing; `TestRefreshSubjectChecks` covers the `/refresh` subject checks; `TestRevokeUserAccess` (in `classes`) covers the revocation writes.
|
`TestOffboarding` runs the admin deactivate and ban bulk actions and checks that the user's older session JWT and personal API token stop working, that a password login restores a deactivated account with a working token while the old credentials stay dead, and that unban revives nothing; `TestRefreshSubjectChecks` covers the `/refresh` subject checks; `TestRevokeUserAccess` (in `classes`) covers the revocation writes.
|
||||||
|
|
||||||
|
`TestLogoutEndsTheSession` signs in through `POST /login` and logs out with the bearer header, with only the `token` or `auth_token` cookie, and with both a bearer and a different cookie token, then checks that the token is refused through every carrier on a `jwt.auth` route, at `/fetch` and at `/refresh`, that the forget cookies match the token cookie's attributes (also with a configured domain and SameSite), that the blacklist row lasts for the refresh window so `/refresh` stays refused after the sweep that follows the access token's expiry, that an expired but refreshable token is revoked, and which tokens a logout refuses with 401.
|
||||||
|
|
||||||
|
`TestAdminOrganisationMembershipClearsRole` checks that the members manager's unlink and link and a Users form save that changes the organisation clear `organisation_role`, that a save keeping the organisation keeps it, and that deleting an organisation clears both columns.
|
||||||
|
|
||||||
The admin tests (`TestAdmin*`) boot the plugin with the admin API mounted on a database of their own and sign in backend administrators with a chosen permission set; the helpers are in `admin_harness_test.go`.
|
The admin tests (`TestAdmin*`) boot the plugin with the admin API mounted on a database of their own and sign in backend administrators with a chosen permission set; the helpers are in `admin_harness_test.go`.
|
||||||
|
|||||||
@@ -162,13 +162,13 @@ func TestAdminOrganisationsEdge(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestAdminOrganisationRoleOutlivesMembership pins a known gap
|
// TestAdminOrganisationMembershipClearsRole: a role belongs to one
|
||||||
// (12.1-SECURITY-REVIEW.md, open item 6): removing a member through the
|
// organisation (12.1-SECURITY-REVIEW.md open item 6, closed). Removing a
|
||||||
// members manager clears organisation_id and nothing else, so the user keeps
|
// member through the members manager clears organisation_id and
|
||||||
// organisation_role and carries it into the next organisation they are
|
// organisation_role, adding one clears a leftover role, and changing the
|
||||||
// added to. Deleting the organisation clears both. When the unlink learns to
|
// organisation in the Users form clears the role while a save that keeps the
|
||||||
// clear the role, this test changes with it.
|
// organisation keeps it. Deleting the organisation clears both.
|
||||||
func TestAdminOrganisationRoleOutlivesMembership(t *testing.T) {
|
func TestAdminOrganisationMembershipClearsRole(t *testing.T) {
|
||||||
env := newAdminEnv(t)
|
env := newAdminEnv(t)
|
||||||
token := env.admin(t, permAccessUsers)
|
token := env.admin(t, permAccessUsers)
|
||||||
stamp := adminStamp()
|
stamp := adminStamp()
|
||||||
@@ -182,18 +182,49 @@ func TestAdminOrganisationRoleOutlivesMembership(t *testing.T) {
|
|||||||
|
|
||||||
env.expect(t, http.StatusOK, http.MethodPost, organisationPath(first.ID, "/relations/members/unlink"), token, ids)
|
env.expect(t, http.StatusOK, http.MethodPost, organisationPath(first.ID, "/relations/members/unlink"), token, ids)
|
||||||
got := env.reload(t, member.ID)
|
got := env.reload(t, member.ID)
|
||||||
if got.OrganisationID != nil {
|
if got.OrganisationID != nil || got.OrganisationRole != nil {
|
||||||
t.Fatalf("organisation_id after the unlink = %d", *got.OrganisationID)
|
t.Fatalf("after the unlink: organisation %v role %v, want both NULL", got.OrganisationID, got.OrganisationRole)
|
||||||
}
|
|
||||||
if got.OrganisationRole == nil || *got.OrganisationRole != "owner" {
|
|
||||||
t.Fatalf("organisation_role after the unlink = %v; the known gap is closed, update this test and the review", got.OrganisationRole)
|
|
||||||
}
|
}
|
||||||
env.expect(t, http.StatusOK, http.MethodPost, organisationPath(second.ID, "/relations/members/link"), token, ids)
|
env.expect(t, http.StatusOK, http.MethodPost, organisationPath(second.ID, "/relations/members/link"), token, ids)
|
||||||
got = env.reload(t, member.ID)
|
got = env.reload(t, member.ID)
|
||||||
if got.OrganisationID == nil || *got.OrganisationID != second.ID || got.OrganisationRole == nil || *got.OrganisationRole != "owner" {
|
if got.OrganisationID == nil || *got.OrganisationID != second.ID || got.OrganisationRole != nil {
|
||||||
t.Fatalf("after the link elsewhere: organisation %v role %v", got.OrganisationID, got.OrganisationRole)
|
t.Fatalf("after the link elsewhere: organisation %v role %v", got.OrganisationID, got.OrganisationRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An organisation-less user with a leftover role loses it when added.
|
||||||
|
leftover := env.seedUser(t, "role-leftover-"+stamp, func(u *models.User) { u.OrganisationRole = &owner })
|
||||||
|
env.expect(t, http.StatusOK, http.MethodPost, organisationPath(first.ID, "/relations/members/link"), token, map[string]any{"ids": []uint{leftover.ID}})
|
||||||
|
if got := env.reload(t, leftover.ID); got.OrganisationID == nil || *got.OrganisationID != first.ID || got.OrganisationRole != nil {
|
||||||
|
t.Fatalf("linked leftover: organisation %v role %v", got.OrganisationID, got.OrganisationRole)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Users form: keeping the organisation keeps the role, changing it
|
||||||
|
// (to another organisation or to none) clears it.
|
||||||
|
formUser := env.seedUser(t, "role-form-"+stamp, func(u *models.User) { u.OrganisationID, u.OrganisationRole = &first.ID, &owner })
|
||||||
|
setRole := func(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
if err := env.gdb.Model(&models.User{}).Where("id = ?", formUser.ID).UpdateColumn("organisation_role", owner).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveForm := func(t *testing.T, organisation any) *models.User {
|
||||||
|
t.Helper()
|
||||||
|
env.expect(t, http.StatusOK, http.MethodPut, userPath(formUser.ID, ""), token, map[string]any{
|
||||||
|
"name": "role-form", "email": formUser.Email, "organisation": organisation,
|
||||||
|
})
|
||||||
|
return env.reload(t, formUser.ID)
|
||||||
|
}
|
||||||
|
if got := saveForm(t, first.ID); got.OrganisationRole == nil || *got.OrganisationRole != owner {
|
||||||
|
t.Fatalf("a save that keeps the organisation dropped the role: %v", got.OrganisationRole)
|
||||||
|
}
|
||||||
|
if got := saveForm(t, second.ID); got.OrganisationID == nil || *got.OrganisationID != second.ID || got.OrganisationRole != nil {
|
||||||
|
t.Fatalf("after moving to another organisation: organisation %v role %v", got.OrganisationID, got.OrganisationRole)
|
||||||
|
}
|
||||||
|
setRole(t)
|
||||||
|
if got := saveForm(t, nil); got.OrganisationID != nil || got.OrganisationRole != nil {
|
||||||
|
t.Fatalf("after clearing the organisation: organisation %v role %v", got.OrganisationID, got.OrganisationRole)
|
||||||
|
}
|
||||||
|
|
||||||
// The delete of an organisation releases its members completely.
|
// The delete of an organisation releases its members completely.
|
||||||
env.expect(t, http.StatusOK, http.MethodDelete, organisationPath(doomed.ID, ""), token, nil)
|
env.expect(t, http.StatusOK, http.MethodDelete, organisationPath(doomed.ID, ""), token, nil)
|
||||||
if got := env.reload(t, other.ID); got == nil || got.OrganisationID != nil || got.OrganisationRole != nil {
|
if got := env.reload(t, other.ID); got == nil || got.OrganisationID != nil || got.OrganisationRole != nil {
|
||||||
|
|||||||
@@ -475,6 +475,11 @@ func TestAdminOrganisationMembers(t *testing.T) {
|
|||||||
if rec := mutate(there, "unlink", foreign); rec.Code != http.StatusOK {
|
if rec := mutate(there, "unlink", foreign); rec.Code != http.StatusOK {
|
||||||
t.Fatalf("unlink there = %d %s", rec.Code, rec.Body.String())
|
t.Fatalf("unlink there = %d %s", rec.Code, rec.Body.String())
|
||||||
}
|
}
|
||||||
|
// The role belonged to the organisation left: the unlink cleared it.
|
||||||
|
if got := env.reload(t, foreign.ID); got.OrganisationRole != nil {
|
||||||
|
t.Fatalf("organisation_role after leaving = %q", *got.OrganisationRole)
|
||||||
|
}
|
||||||
|
stored[foreign.ID].OrganisationRole = nil
|
||||||
if rec := mutate(here, "link", foreign); rec.Code != http.StatusOK || organisationOf(foreign) != here.ID {
|
if rec := mutate(here, "link", foreign); rec.Code != http.StatusOK || organisationOf(foreign) != here.ID {
|
||||||
t.Fatalf("link after the release = %d %s", rec.Code, rec.Body.String())
|
t.Fatalf("link after the release = %d %s", rec.Code, rec.Body.String())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -77,23 +78,77 @@ func RequestUser(ctx context.Context, app *backpack.App, r *http.Request) (*mode
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndRequestSession signs the request's user out the way Logout does and
|
// EndSession signs the request out; POST /logout runs it. Every session JWT
|
||||||
// forgets the token cookie. When r carries a valid session JWT its jti is
|
// r carries (the Authorization bearer header and the token and auth_token
|
||||||
// added to the published bouncer.BlacklistStore until the token expires;
|
// cookies the "jwt" guard reads) that verifies is added to the published
|
||||||
// the response always gets the forget cookie of
|
// bouncer.BlacklistStore, so the guard, RequestUser and POST /refresh refuse
|
||||||
// bouncer.LoadCookieConfig(app.Config), so its Domain and Path match the
|
// it from then on. A token verifies while it is unexpired, and a token with
|
||||||
// cookie the login wrote. It is best effort, as in the PHP provider: a
|
// the user audience also after its access lifetime while its refresh window
|
||||||
// blacklist failure is logged and never returned, and the function writes
|
// is open (it could still be refreshed). The row is kept until the later of
|
||||||
// no status or body.
|
// the token's exp and its iat plus the refresh window
|
||||||
|
// (golem15.user.jwt.refresh_ttl), plus one minute, as bouncer.Refresh keeps
|
||||||
|
// a rotated jti: a row that ended at exp would let /refresh revive the
|
||||||
|
// logged-out token for the rest of its window.
|
||||||
|
//
|
||||||
|
// When w is not nil the response gets the forget cookie of
|
||||||
|
// bouncer.LoadCookieConfig(app.Config), with the name, path, domain,
|
||||||
|
// SameSite and Secure of the token cookie a login writes, and one with the
|
||||||
|
// same attributes for each other session cookie r carries. It writes no
|
||||||
|
// status or body.
|
||||||
|
//
|
||||||
|
// It returns the subject of the token the guard would read (the bearer
|
||||||
|
// header first, then the cookies in order), or "" when r carries none or it
|
||||||
|
// does not verify. Only a failing blacklist write is an error; the cookies
|
||||||
|
// are forgotten and the other tokens revoked in any case. Without a
|
||||||
|
// published blacklist nothing is revoked.
|
||||||
|
func EndSession(ctx context.Context, app *backpack.App, w http.ResponseWriter, r *http.Request) (string, error) {
|
||||||
|
if w != nil {
|
||||||
|
forgetSessionCookies(app, w, r)
|
||||||
|
}
|
||||||
|
if r == nil || app == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
secret, err := JWTSecret(app)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
bl, _ := app.Lookup[bouncer.BlacklistStore]()
|
||||||
|
window := refreshWindow(app)
|
||||||
|
subject := ""
|
||||||
|
var firstErr error
|
||||||
|
for i, raw := range sessionTokens(r) {
|
||||||
|
sub, iat, exp, jti, ok := verifySessionToken(raw, secret, window)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if i == 0 {
|
||||||
|
subject = sub
|
||||||
|
}
|
||||||
|
if bl == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := bl.Add(ctx, jti, revokedUntil(iat, exp, window), time.Now()); err != nil && firstErr == nil {
|
||||||
|
firstErr = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return subject, firstErr
|
||||||
|
}
|
||||||
|
|
||||||
|
// EndRequestSession is the best-effort EndSession, as in the PHP provider:
|
||||||
|
// it revokes the session JWTs r carries and forgets the session cookies the
|
||||||
|
// same way, logs a blacklist failure instead of returning it, and always
|
||||||
|
// returns nil. It writes no status or body.
|
||||||
func EndRequestSession(ctx context.Context, app *backpack.App, w http.ResponseWriter, r *http.Request) error {
|
func EndRequestSession(ctx context.Context, app *backpack.App, w http.ResponseWriter, r *http.Request) error {
|
||||||
if r != nil {
|
if _, err := EndSession(ctx, app, w, r); err != nil {
|
||||||
if raw := sessionToken(r); raw != "" {
|
pluginLog.Warn("golem15.user: end session: blacklist token", "err", err)
|
||||||
revokeSessionToken(ctx, app, raw)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if w == nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// forgetSessionCookies expires the token cookie of
|
||||||
|
// bouncer.LoadCookieConfig(app.Config) and, with the same path, domain,
|
||||||
|
// SameSite and Secure, each other session cookie r carries.
|
||||||
|
func forgetSessionCookies(app *backpack.App, w http.ResponseWriter, r *http.Request) {
|
||||||
cfg := bouncer.CookieConfig{Name: bouncer.DefaultCookieName, Path: "/", SameSite: http.SameSiteLaxMode}
|
cfg := bouncer.CookieConfig{Name: bouncer.DefaultCookieName, Path: "/", SameSite: http.SameSiteLaxMode}
|
||||||
if app != nil && app.Config != nil {
|
if app != nil && app.Config != nil {
|
||||||
loaded, err := bouncer.LoadCookieConfig(app.Config)
|
loaded, err := bouncer.LoadCookieConfig(app.Config)
|
||||||
@@ -104,48 +159,83 @@ func EndRequestSession(ctx context.Context, app *backpack.App, w http.ResponseWr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
http.SetCookie(w, cfg.ForgetTokenCookie())
|
http.SetCookie(w, cfg.ForgetTokenCookie())
|
||||||
return nil
|
if r == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, name := range sessionCookieNames {
|
||||||
|
if name == cfg.Name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err := r.Cookie(name); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
other := cfg
|
||||||
|
other.Name = name
|
||||||
|
http.SetCookie(w, other.ForgetTokenCookie())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// revokeSessionToken blacklists raw's jti until its expiry (best effort).
|
// verifySessionToken accepts raw when it is a token the "jwt" guard accepts
|
||||||
func revokeSessionToken(ctx context.Context, app *backpack.App, raw string) {
|
// or POST /refresh still rotates: a user-audience token whose refresh window
|
||||||
if app == nil {
|
// is open (its exp may have passed), or an unexpired token, which also
|
||||||
return
|
// covers one without an audience (issued by the PHP backend). A token
|
||||||
}
|
// without a jti cannot be revoked and is refused.
|
||||||
secret, err := JWTSecret(app)
|
func verifySessionToken(raw, secret string, window time.Duration) (sub string, iat, exp time.Time, jti string, ok bool) {
|
||||||
|
sub, iat, exp, jti, err := bouncer.VerifyRefreshableClaimsAudience(raw, secret, bouncer.AudienceUser, window)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
sub, iat, exp, jti, err = bouncer.VerifyClaims(raw, secret)
|
||||||
}
|
}
|
||||||
_, _, exp, jti, err := bouncer.VerifyClaims(raw, secret)
|
return sub, iat, exp, jti, err == nil && jti != ""
|
||||||
if err != nil || jti == "" {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
bl, ok := app.Lookup[bouncer.BlacklistStore]()
|
|
||||||
if !ok || bl == nil {
|
// revokedUntil is the storage expiry of a revoked session jti: the later of
|
||||||
return
|
// exp and iat plus the refresh window, plus one minute (PHP jwt-auth's
|
||||||
|
// Blacklist::getMinutesUntilExpired, which bouncer.Refresh follows).
|
||||||
|
func revokedUntil(iat, exp time.Time, window time.Duration) time.Time {
|
||||||
|
until := iat.Add(window)
|
||||||
|
if exp.After(until) {
|
||||||
|
until = exp
|
||||||
}
|
}
|
||||||
if err := bl.Add(ctx, jti, exp, time.Now()); err != nil {
|
return until.Add(time.Minute)
|
||||||
pluginLog.Warn("golem15.user: end session: blacklist token", "err", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refreshWindow is golem15.user.jwt.refresh_ttl minutes, default 20160: the
|
||||||
|
// window POST /refresh accepts (controllers.RefreshTTL reads the same key).
|
||||||
|
func refreshWindow(app *backpack.App) time.Duration {
|
||||||
|
mins := 20160
|
||||||
|
if app != nil && app.Config != nil && app.Config.Int("golem15.user.jwt.refresh_ttl") > 0 {
|
||||||
|
mins = app.Config.Int("golem15.user.jwt.refresh_ttl")
|
||||||
|
}
|
||||||
|
return time.Duration(mins) * time.Minute
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionToken extracts the session JWT as the "jwt" guard does: the
|
// sessionToken extracts the session JWT as the "jwt" guard does: the
|
||||||
// Authorization bearer header, then each session cookie in order.
|
// Authorization bearer header, then each session cookie in order.
|
||||||
func sessionToken(r *http.Request) string {
|
func sessionToken(r *http.Request) string {
|
||||||
h := strings.TrimSpace(r.Header.Get("Authorization"))
|
if tokens := sessionTokens(r); len(tokens) > 0 {
|
||||||
if token, ok := strings.CutPrefix(h, "Bearer "); ok {
|
return tokens[0]
|
||||||
if token = strings.TrimSpace(token); token != "" {
|
|
||||||
return token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, name := range sessionCookieNames {
|
|
||||||
c, err := r.Cookie(name)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if v := strings.TrimSpace(c.Value); v != "" {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sessionTokens returns every distinct session JWT r carries, in the order
|
||||||
|
// the "jwt" guard tries them: the Authorization bearer header, then each
|
||||||
|
// session cookie. Empty values are skipped.
|
||||||
|
func sessionTokens(r *http.Request) []string {
|
||||||
|
var out []string
|
||||||
|
add := func(v string) {
|
||||||
|
if v = strings.TrimSpace(v); v != "" && !slices.Contains(out, v) {
|
||||||
|
out = append(out, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h := strings.TrimSpace(r.Header.Get("Authorization"))
|
||||||
|
if token, ok := strings.CutPrefix(h, "Bearer "); ok {
|
||||||
|
add(token)
|
||||||
|
}
|
||||||
|
for _, name := range sessionCookieNames {
|
||||||
|
if c, err := r.Cookie(name); err == nil {
|
||||||
|
add(c.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|||||||
@@ -126,17 +126,22 @@ func Login(app *backpack.App) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logout forever-blacklists the presented bearer token.
|
// Logout ends the request's session through classes.EndSession: every
|
||||||
|
// session token it carries (the bearer header, or the token and auth_token
|
||||||
|
// cookies the jwt guard also reads) is blacklisted for the rest of its
|
||||||
|
// refresh window, so the next request with it is refused and /refresh
|
||||||
|
// cannot revive it, and the session cookies are expired, on a 401 too.
|
||||||
|
// It answers 200 {"message":"Logged out"} when the token the guard reads
|
||||||
|
// verifies (an expired one too while it can still be refreshed) and names a
|
||||||
|
// user, 401 otherwise, and 500 when the blacklist write fails.
|
||||||
func Logout(app *backpack.App) http.HandlerFunc {
|
func Logout(app *backpack.App) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
_, secret, ok := sessionDeps(w, app)
|
if _, _, ok := sessionDeps(w, app); !ok {
|
||||||
if !ok {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
raw := bearerToken(r)
|
sub, err := classes.EndSession(r.Context(), app, w, r)
|
||||||
sub, _, exp, jti, err := bouncer.VerifyClaims(raw, secret)
|
if err != nil {
|
||||||
if err != nil || jti == "" {
|
writeOpaque500(w)
|
||||||
writeUnauthorized(w)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id, err := strconv.ParseUint(sub, 10, 64)
|
id, err := strconv.ParseUint(sub, 10, 64)
|
||||||
@@ -149,12 +154,6 @@ func Logout(app *backpack.App) http.HandlerFunc {
|
|||||||
writeUnauthorized(w)
|
writeUnauthorized(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if bl, ok := app.Lookup[bouncer.BlacklistStore](); ok && bl != nil {
|
|
||||||
if err := bl.Add(r.Context(), jti, exp, time.Now()); err != nil {
|
|
||||||
writeOpaque500(w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeJSON(w, http.StatusOK, map[string]any{"message": "Logged out"})
|
writeJSON(w, http.StatusOK, map[string]any{"message": "Logged out"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ const membersRelation = "members"
|
|||||||
// manager. The screen and every write need golem15.users.access_users, as in
|
// manager. The screen and every write need golem15.users.access_users, as in
|
||||||
// PHP.
|
// PHP.
|
||||||
//
|
//
|
||||||
// The members manager sets and clears users.organisation_id and nothing
|
// The members manager sets and clears users.organisation_id, and clears
|
||||||
// else. It never writes users_groups.
|
// users.organisation_role with it (a role belongs to one organisation). It
|
||||||
|
// never writes users_groups.
|
||||||
type organisationsAdminController struct {
|
type organisationsAdminController struct {
|
||||||
app appAccess
|
app appAccess
|
||||||
}
|
}
|
||||||
@@ -73,12 +74,15 @@ func (c organisationsAdminController) requireSlugFormat(ctx context.Context, mod
|
|||||||
// AdminRelationContracts declares the members relation manager: the users
|
// AdminRelationContracts declares the members relation manager: the users
|
||||||
// whose organisation_id is the organisation. Linking sets the column and
|
// whose organisation_id is the organisation. Linking sets the column and
|
||||||
// unlinking clears it; the column is nullable, so a user is never deleted.
|
// unlinking clears it; the column is nullable, so a user is never deleted.
|
||||||
|
// Both also clear organisation_role (ClearOnChange), so a role never moves
|
||||||
|
// to another organisation or outlives the membership.
|
||||||
func (organisationsAdminController) AdminRelationContracts() []cabana.RelationContract {
|
func (organisationsAdminController) AdminRelationContracts() []cabana.RelationContract {
|
||||||
return []cabana.RelationContract{{
|
return []cabana.RelationContract{{
|
||||||
Name: membersRelation,
|
Name: membersRelation,
|
||||||
Kind: cabana.RelationHasMany,
|
Kind: cabana.RelationHasMany,
|
||||||
NewRelated: func() any { return &models.User{} },
|
NewRelated: func() any { return &models.User{} },
|
||||||
ForeignKey: "organisation_id",
|
ForeignKey: "organisation_id",
|
||||||
|
ClearOnChange: []string{"organisation_role"},
|
||||||
Columns: map[string]string{
|
Columns: map[string]string{
|
||||||
"name": "name",
|
"name": "name",
|
||||||
"email": "email",
|
"email": "email",
|
||||||
|
|||||||
@@ -364,7 +364,9 @@ const groupsField = "groups"
|
|||||||
// AdminFieldRelations binds the organisation picker and the groups field.
|
// AdminFieldRelations binds the organisation picker and the groups field.
|
||||||
// organisation_id is a protected column, so the contract opts in to writing
|
// organisation_id is a protected column, so the contract opts in to writing
|
||||||
// it through this one field; the submitted id is still checked against the
|
// it through this one field; the submitted id is still checked against the
|
||||||
// options. groups is the users_groups pivot: a save that carries the field
|
// options. A save that changes the organisation (to another one or to none)
|
||||||
|
// clears organisation_role (ClearOnChange) unless the same save writes it.
|
||||||
|
// groups is the users_groups pivot: a save that carries the field
|
||||||
// replaces the user's memberships, and AdminRelationLocks decides which of
|
// replaces the user's memberships, and AdminRelationLocks decides which of
|
||||||
// them the administrator may change.
|
// them the administrator may change.
|
||||||
func (usersAdminController) AdminFieldRelations() []cabana.FieldRelationContract {
|
func (usersAdminController) AdminFieldRelations() []cabana.FieldRelationContract {
|
||||||
@@ -376,6 +378,7 @@ func (usersAdminController) AdminFieldRelations() []cabana.FieldRelationContract
|
|||||||
ForeignKey: "organisation_id",
|
ForeignKey: "organisation_id",
|
||||||
LabelColumn: "name",
|
LabelColumn: "name",
|
||||||
WritableForeignKey: true,
|
WritableForeignKey: true,
|
||||||
|
ClearOnChange: []string{"organisation_role"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Field: groupsField,
|
Field: groupsField,
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.golem15.com/golem15/sm-user-plugin
|
|||||||
go 1.27.0
|
go 1.27.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.golem15.com/golem15/summercms v0.4.0
|
git.golem15.com/golem15/summercms v0.4.3
|
||||||
github.com/go-gormigrate/gormigrate/v2 v2.1.7
|
github.com/go-gormigrate/gormigrate/v2 v2.1.7
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||||
github.com/jackc/pgx/v5 v5.10.0
|
github.com/jackc/pgx/v5 v5.10.0
|
||||||
|
|||||||
297
logout_test.go
Normal file
297
logout_test.go
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.golem15.com/golem15/sm-user-plugin/controllers"
|
||||||
|
"git.golem15.com/golem15/summercms/modules/bouncer"
|
||||||
|
"git.golem15.com/golem15/summercms/modules/compass"
|
||||||
|
"github.com/golang-jwt/jwt/v5"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
loggedOutBody = `{"message":"Logged out"}`
|
||||||
|
unauthorizedRaw = `{"error":true,"message":"Unauthorized"}`
|
||||||
|
blacklistedBody = `{"error":"Could not refresh token","msg":"The token has been blacklisted"}`
|
||||||
|
userTokensPath = "/_user/api/v1/tokens"
|
||||||
|
userLogoutPath = "/_user/api/v1/logout"
|
||||||
|
userRefreshPath = "/_user/api/v1/refresh"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestLogoutEndsTheSession: POST /logout ends the session however the token
|
||||||
|
// travels (the bearer header, or only the token or auth_token cookie the
|
||||||
|
// jwt guard also reads), so the next request with the same token or cookie
|
||||||
|
// is 401 on the jwt.auth routes, at /fetch and at /refresh. It clears the
|
||||||
|
// session cookies with the attributes the token cookie is written with, and
|
||||||
|
// the revocation lasts for the token's refresh window: a logged-out token is
|
||||||
|
// not refreshable after its access lifetime, and an expired but still
|
||||||
|
// refreshable token is revoked by a logout too.
|
||||||
|
func TestLogoutEndsTheSession(t *testing.T) {
|
||||||
|
e := newAdminEnv(t)
|
||||||
|
|
||||||
|
t.Run("bearer", func(t *testing.T) {
|
||||||
|
token := e.sessionLogin(t, "logout-bearer")
|
||||||
|
if code := e.guarded(t, token, ""); code != http.StatusOK {
|
||||||
|
t.Fatalf("jwt.auth before logout = %d", code)
|
||||||
|
}
|
||||||
|
rec := e.call(t, http.MethodPost, userLogoutPath, token, nil)
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
e.assertSessionEnded(t, token)
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, name := range []string{"token", "auth_token"} {
|
||||||
|
t.Run("cookie "+name, func(t *testing.T) {
|
||||||
|
token := e.sessionLogin(t, "logout-"+name)
|
||||||
|
if code := e.guarded(t, token, name); code != http.StatusOK {
|
||||||
|
t.Fatalf("jwt.auth with the %s cookie before logout = %d", name, code)
|
||||||
|
}
|
||||||
|
rec := e.send(t, http.MethodPost, userLogoutPath, "", nil, "application/json", map[string]string{"Cookie": name + "=" + token})
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
e.assertSessionEnded(t, token)
|
||||||
|
want := e.cookieConfig(t)
|
||||||
|
assertForgets(t, rec, want, want.Name)
|
||||||
|
if name != want.Name {
|
||||||
|
assertForgets(t, rec, want, name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("bearer logout forgets the token cookie too", func(t *testing.T) {
|
||||||
|
token := e.sessionLogin(t, "logout-bearer-cookie")
|
||||||
|
rec := e.call(t, http.MethodPost, userLogoutPath, token, nil)
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
want := e.cookieConfig(t)
|
||||||
|
assertForgets(t, rec, want, want.Name)
|
||||||
|
for _, c := range rec.Result().Cookies() {
|
||||||
|
if c.Name == "auth_token" {
|
||||||
|
t.Fatalf("a request without the auth_token cookie got a forget cookie for it: %s", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("refused token still forgets the cookie", func(t *testing.T) {
|
||||||
|
rec := e.send(t, http.MethodPost, userLogoutPath, "", nil, "application/json", map[string]string{"Cookie": "token=not-a-token"})
|
||||||
|
if rec.Code != http.StatusUnauthorized || rec.Body.String() != unauthorizedRaw {
|
||||||
|
t.Fatalf("logout with a bad cookie = %d %s", rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
assertForgets(t, rec, e.cookieConfig(t), "token")
|
||||||
|
missing := e.call(t, http.MethodPost, userLogoutPath, "", nil)
|
||||||
|
if missing.Code != http.StatusUnauthorized || missing.Body.String() != unauthorizedRaw {
|
||||||
|
t.Fatalf("logout without a token = %d %s", missing.Code, missing.Body.String())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("revocation outlives the access token", func(t *testing.T) {
|
||||||
|
token := e.sessionLogin(t, "logout-window")
|
||||||
|
claims := parseToken(t, token)
|
||||||
|
jti, _ := claims["jti"].(string)
|
||||||
|
iat, _ := claims.GetIssuedAt()
|
||||||
|
exp, _ := claims.GetExpirationTime()
|
||||||
|
assertLoggedOut(t, e.call(t, http.MethodPost, userLogoutPath, token, nil))
|
||||||
|
var expiresAt time.Time
|
||||||
|
if err := e.gdb.Raw(`SELECT expires_at FROM jwt_blacklist WHERE jti = ?`, jti).Scan(&expiresAt).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// The later of exp and iat plus the refresh window, plus a minute.
|
||||||
|
want := iat.Add(controllers.RefreshTTL(e.app)).Add(time.Minute)
|
||||||
|
if d := expiresAt.Sub(want); d < -time.Second || d > time.Second {
|
||||||
|
t.Fatalf("blacklist row expires at %v, want %v (refresh window plus a minute)", expiresAt, want)
|
||||||
|
}
|
||||||
|
// The sweep that runs once the access token has expired: the same
|
||||||
|
// predicate as bouncer.PostgresBlacklist.Sweep, limited to this jti
|
||||||
|
// so other tests' rows stay.
|
||||||
|
if err := e.gdb.Exec(`DELETE FROM jwt_blacklist WHERE jti = ? AND expires_at < ?`, jti, exp.Add(2*time.Minute)).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
rec := e.refresh(t, token)
|
||||||
|
if rec.Code != http.StatusUnauthorized || rec.Body.String() != blacklistedBody {
|
||||||
|
t.Fatalf("refresh of a logged-out token after its access lifetime = %d %s", rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("expired but refreshable token", func(t *testing.T) {
|
||||||
|
user := e.seedUser(t, "logout-expired", nil)
|
||||||
|
iat := time.Now().Add(-2 * time.Hour)
|
||||||
|
token := userAudienceToken(t, strconv.FormatUint(uint64(user.ID), 10), "logout-expired-"+adminStamp(), iat, iat.Add(time.Hour))
|
||||||
|
rec := e.call(t, http.MethodPost, userLogoutPath, token, nil)
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
if refreshed := e.refresh(t, token); refreshed.Code != http.StatusUnauthorized || refreshed.Body.String() != blacklistedBody {
|
||||||
|
t.Fatalf("refresh after logging out an expired token = %d %s", refreshed.Code, refreshed.Body.String())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("every token the request carries", func(t *testing.T) {
|
||||||
|
bearerToken := e.sessionLogin(t, "logout-both-bearer")
|
||||||
|
cookieToken := e.sessionLogin(t, "logout-both-cookie")
|
||||||
|
rec := e.send(t, http.MethodPost, userLogoutPath, bearerToken, nil, "application/json", map[string]string{"Cookie": "token=" + cookieToken})
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
e.assertSessionEnded(t, bearerToken)
|
||||||
|
e.assertSessionEnded(t, cookieToken)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("refused tokens", func(t *testing.T) {
|
||||||
|
user := e.seedUser(t, "logout-refused", nil)
|
||||||
|
sub := strconv.FormatUint(uint64(user.ID), 10)
|
||||||
|
closedAt := time.Now().Add(-controllers.RefreshTTL(e.app) - time.Hour)
|
||||||
|
for name, token := range map[string]string{
|
||||||
|
// The refresh window closed: nothing left to revoke.
|
||||||
|
"closed window": userAudienceToken(t, sub, "logout-closed-"+adminStamp(), closedAt, closedAt.Add(time.Hour)),
|
||||||
|
// No audience (a PHP token) is accepted only while unexpired.
|
||||||
|
"expired without audience": craftToken(t, sub, "logout-legacy-old-"+adminStamp(), time.Now().Add(-2*time.Hour), time.Now().Add(-time.Hour)),
|
||||||
|
// No jti: it cannot be blacklisted.
|
||||||
|
"no jti": userAudienceToken(t, sub, "", time.Now(), time.Now().Add(time.Hour)),
|
||||||
|
// A user that does not exist.
|
||||||
|
"unknown user": userAudienceToken(t, "999999999", "logout-ghost-"+adminStamp(), time.Now(), time.Now().Add(time.Hour)),
|
||||||
|
} {
|
||||||
|
rec := e.call(t, http.MethodPost, userLogoutPath, token, nil)
|
||||||
|
if rec.Code != http.StatusUnauthorized || rec.Body.String() != unauthorizedRaw {
|
||||||
|
t.Fatalf("%s: logout = %d %s", name, rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
assertForgets(t, rec, e.cookieConfig(t), "token")
|
||||||
|
}
|
||||||
|
legacy := craftToken(t, sub, "logout-legacy-"+adminStamp(), time.Now().Add(-time.Minute), time.Now().Add(time.Hour))
|
||||||
|
if code := e.guarded(t, legacy, ""); code != http.StatusOK {
|
||||||
|
t.Fatalf("jwt.auth with an unexpired token without audience = %d", code)
|
||||||
|
}
|
||||||
|
assertLoggedOut(t, e.call(t, http.MethodPost, userLogoutPath, legacy, nil))
|
||||||
|
if code := e.guarded(t, legacy, ""); code != http.StatusUnauthorized {
|
||||||
|
t.Fatalf("jwt.auth after logging out a token without audience = %d", code)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("configured cookie attributes and refresh window", func(t *testing.T) {
|
||||||
|
custom := newAdminEnv(t, func(c *compass.Config) {
|
||||||
|
for key, value := range map[string]any{
|
||||||
|
"auth.cookie.domain": "example.com",
|
||||||
|
"auth.cookie.same_site": "strict",
|
||||||
|
"auth.cookie.path": "/",
|
||||||
|
"golem15.user.jwt.refresh_ttl": 120,
|
||||||
|
} {
|
||||||
|
if err := c.Set(key, value); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
token := custom.sessionLogin(t, "logout-custom")
|
||||||
|
rec := custom.send(t, http.MethodPost, userLogoutPath, "", nil, "application/json", map[string]string{"Cookie": "token=" + token})
|
||||||
|
assertLoggedOut(t, rec)
|
||||||
|
want := custom.cookieConfig(t)
|
||||||
|
if want.Domain != "example.com" || want.SameSite != http.SameSiteStrictMode {
|
||||||
|
t.Fatalf("config not applied: %+v", want)
|
||||||
|
}
|
||||||
|
assertForgets(t, rec, want, "token")
|
||||||
|
custom.assertSessionEnded(t, token)
|
||||||
|
// Logout keeps the row for the window /refresh uses.
|
||||||
|
claims := parseToken(t, token)
|
||||||
|
jti, _ := claims["jti"].(string)
|
||||||
|
iat, _ := claims.GetIssuedAt()
|
||||||
|
var expiresAt time.Time
|
||||||
|
if err := custom.gdb.Raw(`SELECT expires_at FROM jwt_blacklist WHERE jti = ?`, jti).Scan(&expiresAt).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if window := controllers.RefreshTTL(custom.app); window != 120*time.Minute {
|
||||||
|
t.Fatalf("refresh window = %v", window)
|
||||||
|
}
|
||||||
|
if d := expiresAt.Sub(iat.Add(121 * time.Minute)); d < -time.Second || d > time.Second {
|
||||||
|
t.Fatalf("blacklist row expires at %v, want iat plus 121 minutes", expiresAt)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// sessionLogin seeds a frontend user, signs in through POST /login and
|
||||||
|
// returns the session token.
|
||||||
|
func (e *adminEnv) sessionLogin(t *testing.T, label string) string {
|
||||||
|
t.Helper()
|
||||||
|
user := e.seedUser(t, label, nil)
|
||||||
|
code, token := e.userLogin(t, user.Email, "correct-horse")
|
||||||
|
if code != http.StatusOK || token == "" {
|
||||||
|
t.Fatalf("login %s = %d", label, code)
|
||||||
|
}
|
||||||
|
return token
|
||||||
|
}
|
||||||
|
|
||||||
|
// guarded calls GET /tokens, a jwt.auth route, with token as the bearer
|
||||||
|
// header (cookie "") or only in the named cookie, and returns the status.
|
||||||
|
func (e *adminEnv) guarded(t *testing.T, token, cookie string) int {
|
||||||
|
t.Helper()
|
||||||
|
if cookie == "" {
|
||||||
|
return e.call(t, http.MethodGet, userTokensPath, token, nil).Code
|
||||||
|
}
|
||||||
|
return e.send(t, http.MethodGet, userTokensPath, "", nil, "application/json", map[string]string{"Cookie": cookie + "=" + token}).Code
|
||||||
|
}
|
||||||
|
|
||||||
|
// assertSessionEnded: token no longer authenticates, through any carrier,
|
||||||
|
// and cannot be refreshed.
|
||||||
|
func (e *adminEnv) assertSessionEnded(t *testing.T, token string) {
|
||||||
|
t.Helper()
|
||||||
|
for _, carrier := range []string{"", "token", "auth_token"} {
|
||||||
|
if code := e.guarded(t, token, carrier); code != http.StatusUnauthorized {
|
||||||
|
t.Fatalf("jwt.auth after logout (cookie %q) = %d", carrier, code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if code := e.fetchCode(t, token); code != http.StatusUnauthorized {
|
||||||
|
t.Fatalf("fetch after logout = %d", code)
|
||||||
|
}
|
||||||
|
if rec := e.refresh(t, token); rec.Code != http.StatusUnauthorized || rec.Body.String() != blacklistedBody {
|
||||||
|
t.Fatalf("refresh after logout = %d %s", rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *adminEnv) cookieConfig(t *testing.T) bouncer.CookieConfig {
|
||||||
|
t.Helper()
|
||||||
|
cfg, err := bouncer.LoadCookieConfig(e.app.Config)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
func assertLoggedOut(t *testing.T, rec *httptest.ResponseRecorder) {
|
||||||
|
t.Helper()
|
||||||
|
if rec.Code != http.StatusOK || rec.Body.String() != loggedOutBody {
|
||||||
|
t.Fatalf("logout = %d %s", rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// assertForgets: the response deletes the cookie name with the path,
|
||||||
|
// domain, SameSite, Secure and HttpOnly of the token cookie cfg writes.
|
||||||
|
func assertForgets(t *testing.T, rec *httptest.ResponseRecorder, cfg bouncer.CookieConfig, name string) {
|
||||||
|
t.Helper()
|
||||||
|
set := cfg.TokenCookie("x", time.Hour)
|
||||||
|
for _, c := range rec.Result().Cookies() {
|
||||||
|
if c.Name != name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if c.Value != "" || c.MaxAge >= 0 || c.Path != set.Path || c.Domain != set.Domain ||
|
||||||
|
c.SameSite != set.SameSite || c.Secure != set.Secure || c.HttpOnly != set.HttpOnly {
|
||||||
|
t.Fatalf("forget cookie %s does not match the token cookie %s", c, set)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Fatalf("no forget cookie for %s in %v", name, rec.Result().Header.Values("Set-Cookie"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// userAudienceToken signs a session token the way bouncer.Mint does (user
|
||||||
|
// audience, prv), with a chosen iat and exp.
|
||||||
|
func userAudienceToken(t *testing.T, sub, jti string, iat, exp time.Time) string {
|
||||||
|
t.Helper()
|
||||||
|
claims := jwt.MapClaims{
|
||||||
|
"sub": sub,
|
||||||
|
"aud": []string{bouncer.AudienceUser},
|
||||||
|
"iss": "http://example.com/_user/api/v1/login",
|
||||||
|
"iat": iat.Unix(),
|
||||||
|
"nbf": iat.Unix(),
|
||||||
|
"exp": exp.Unix(),
|
||||||
|
"jti": jti,
|
||||||
|
"prv": prvHash,
|
||||||
|
}
|
||||||
|
signed, err := jwt.NewWithClaims(jwt.SigningMethodHS256, claims).SignedString([]byte(sessionSecret))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return signed
|
||||||
|
}
|
||||||
@@ -189,10 +189,11 @@ func TestRequestUser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestEndRequestSession pins classes.EndRequestSession (D-04, D-05) without
|
// TestEndRequestSession pins classes.EndRequestSession (D-04, D-05) without
|
||||||
// a database: the session's jti is blacklisted until the token expires, the
|
// a database: the session's jti is blacklisted until its refresh window
|
||||||
// forget cookie carries the configured Domain and Path, a request without a
|
// closes (not only until the access token expires, or /refresh could revive
|
||||||
// token still forgets the cookie, and a blacklist failure never fails the
|
// it), the forget cookie carries the configured Domain and Path, a request
|
||||||
// call.
|
// without a token still forgets the cookie, and a blacklist failure never
|
||||||
|
// fails the call.
|
||||||
func TestEndRequestSession(t *testing.T) {
|
func TestEndRequestSession(t *testing.T) {
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
app := sessionUserApp(t,
|
app := sessionUserApp(t,
|
||||||
@@ -234,14 +235,15 @@ func TestEndRequestSession(t *testing.T) {
|
|||||||
if blocked, _ := bl.IsBlacklisted(ctx, jti); !blocked {
|
if blocked, _ := bl.IsBlacklisted(ctx, jti); !blocked {
|
||||||
t.Fatalf("%s: the jti is not blacklisted", kind)
|
t.Fatalf("%s: the jti is not blacklisted", kind)
|
||||||
}
|
}
|
||||||
// Until the token's expiry, and no longer.
|
// Past the token's expiry, until its refresh window closes, and no
|
||||||
_ = bl.Sweep(ctx, time.Now())
|
// longer.
|
||||||
|
_ = bl.Sweep(ctx, time.Now().Add(time.Hour+2*time.Minute))
|
||||||
if blocked, _ := bl.IsBlacklisted(ctx, jti); !blocked {
|
if blocked, _ := bl.IsBlacklisted(ctx, jti); !blocked {
|
||||||
t.Fatalf("%s: the entry left before the token expired", kind)
|
t.Fatalf("%s: the entry left when the access token expired", kind)
|
||||||
}
|
}
|
||||||
_ = bl.Sweep(ctx, time.Now().Add(time.Hour+time.Minute))
|
_ = bl.Sweep(ctx, time.Now().Add(controllers.RefreshTTL(app)+2*time.Minute))
|
||||||
if blocked, _ := bl.IsBlacklisted(ctx, jti); blocked {
|
if blocked, _ := bl.IsBlacklisted(ctx, jti); blocked {
|
||||||
t.Fatalf("%s: the entry outlived the token", kind)
|
t.Fatalf("%s: the entry outlived the refresh window", kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user