Skip to content

Fixed apitoken permission check by correctly parsing the permissions#2196

Merged
s3inlc merged 2 commits into
devfrom
fix-api-token-bug
Jun 3, 2026
Merged

Fixed apitoken permission check by correctly parsing the permissions#2196
s3inlc merged 2 commits into
devfrom
fix-api-token-bug

Conversation

@jessevz

@jessevz jessevz commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes API token permission validation by distinguishing between legacy user JWT scopes and modern API-token scopes, using the JWT aud claim to choose the correct parsing strategy.

Changes:

  • Pass JWT aud through the request lifecycle and into permission validation.
  • Update validatePermissions() to parse permissions differently for user_hashtopolis (legacy mapping) vs api_hashtopolis (modern boolean-permission dict).
  • Update callers to provide the new aud argument when validating permissions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/inc/apiv2/common/AbstractBaseAPI.php Extends permission validation to accept aud and parse legacy vs modern scopes appropriately.
src/inc/apiv2/auth/JWTBeforeHandler.php Adds aud to request attributes so downstream permission checks can interpret scopes correctly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inc/apiv2/auth/JWTBeforeHandler.php Outdated
Comment on lines +29 to +30
return $request->withAttribute("userId", $arguments["decoded"]["userId"])->withAttribute("scope", $arguments["decoded"]["scope"])
->withAttribute("aud", $arguments["decoded"]["aud"]);
Comment thread src/inc/apiv2/common/AbstractBaseAPI.php
@s3inlc s3inlc merged commit 714d55f into dev Jun 3, 2026
5 checks passed
@s3inlc s3inlc deleted the fix-api-token-bug branch June 3, 2026 07:43
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.

3 participants