fix(auth): enforce Sentinel authorization boundaries - #131
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2782f5b91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| RequestTokenHasAudience(c, "sentinel"), | ||
| RequestTokenHasScope(c, "sentinel:all"), | ||
| )) | ||
| Require(c, RequestTokenHasResourceScope(c, authz.UserReadScope)) |
There was a problem hiding this comment.
Restrict bulk user reads to trusted callers
When a third-party OAuth app is granted user:read, RequestTokenHasResourceScope succeeds without checking the audience or subject, so GET /users now returns every user. GetAllUsers populates fields including email, phone number, birthday, clothing sizes, and SAE registration number, even though the consent UI describes this scope as reading “your profile”; before this change the collection was limited to Sentinel callers. Keep the bulk directory first-party/admin/internal-only or return an appropriately sanitized directory response.
Useful? React with 👍 / 👎.
| RequestTokenHasEntityID(c, entityID), | ||
| RequestUserIsAdmin(c), | ||
| )) | ||
| Require(c, RequestTokenHasResourceScope(c, authz.UserReadScope)) |
There was a problem hiding this comment.
Retain subject checks on entity reads
For a third-party token with user:read, this gate now permits requesting any entityID, rather than only the token subject. service.GetEntityByID populates email and phone authentication records plus EntityExternalAuth rows whose JSON includes provider access_token and refresh_token fields, so a known entity ID—obtainable from the newly exposed /users collection—can disclose another user's PII and stored provider credentials. Preserve the previous self/admin/internal restriction or expose a sanitized profile DTO for scoped reads.
Useful? React with 👍 / 👎.
sentinel:internalfor allowlisted Sentinel service accounts and rotate existing internal credentials at startupsentinel:allas the first-party user scope while requiring self, owner, or Admins authorization for writesgroups:writeOAuth scope and keep both Sentinel-only scopes out of third-party consent