Skip to content

Api tokens#1965

Merged
jessevz merged 14 commits intodevfrom
api-tokens
Mar 16, 2026
Merged

Api tokens#1965
jessevz merged 14 commits intodevfrom
api-tokens

Conversation

@jessevz
Copy link
Copy Markdown
Contributor

@jessevz jessevz commented Mar 11, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class JWT “API token” support to API v2 by introducing a persisted JwtApiKey model/table, a new /api/v2/ui/apiTokens endpoint for managing tokens, and changes to permission evaluation to use the JWT scope claim.

Changes:

  • Add JwtApiKey DBA model/factory and register it with the API factory/router.
  • Add MySQL/Postgres migrations for the JwtApiKey table and utilities/endpoints for creating/deleting tokens.
  • Update API v2 permission handling (validatePermissions) and aggregateData to be instance-based.

Reviewed changes

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

Show a summary per file
File Description
src/migrations/postgres/20260309164000_api-key.sql Adds Postgres table for persisted JWT API keys.
src/migrations/mysql/20260309164000_api-key.sql Adds MySQL table for persisted JWT API keys.
src/inc/utils/UserUtils.php Revokes a user’s API keys during user deletion.
src/inc/utils/JwtTokenUtils.php Utility for creating/deleting persisted API keys.
src/inc/apiv2/model/ApiTokenAPI.php New API v2 model for managing API tokens and returning the encoded JWT on creation.
src/inc/apiv2/common/AbstractBaseAPI.php Switches permission validation to use JWT scope attribute; makes aggregateData non-static; extends json2db for array(string).
src/inc/apiv2/auth/token.routes.php Adjusts JWT issuance to pull scopes from the user’s right group.
src/inc/apiv2/model/TaskAPI.php Updates aggregateData signature to instance method.
src/inc/apiv2/model/PreTaskAPI.php Updates aggregateData signature to instance method.
src/inc/apiv2/model/AgentAPI.php Updates aggregateData signature to instance method.
src/dba/models/generator.php Registers JwtApiKey for model generation metadata.
src/dba/models/JwtApiKey.php Adds new DBA model representing persisted JWT API keys.
src/dba/models/JwtApiKeyFactory.php Adds factory for JwtApiKey.
src/dba/Factory.php Registers JwtApiKeyFactory accessor.
src/api/v2/index.php Registers ApiTokenAPI routes.

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

Comment thread src/migrations/mysql/20260309164000_api-key.sql Outdated
Comment thread src/migrations/postgres/20260309164000_api-key.sql Outdated
Comment thread src/inc/apiv2/model/ApiTokenAPI.php
Comment thread src/inc/apiv2/model/ApiTokenAPI.php Outdated
Comment thread src/inc/apiv2/common/AbstractBaseAPI.php Outdated
Comment thread src/dba/models/JwtApiKey.php Outdated
Comment thread src/inc/utils/UserUtils.php Outdated
Comment thread src/inc/apiv2/model/ApiTokenAPI.php Outdated
Comment thread src/inc/apiv2/common/AbstractBaseAPI.php
Comment thread src/api/v2/index.php
@jessevz jessevz requested a review from Copilot March 12, 2026 09:32
@jessevz jessevz marked this pull request as ready for review March 12, 2026 09:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/migrations/postgres/20260309164000_api-key.sql Outdated
Comment thread src/inc/utils/UserUtils.php Outdated
Comment thread src/dba/models/JwtApiKey.php Outdated
Comment thread src/migrations/mysql/20260309164000_api-key.sql
Comment thread src/migrations/mysql/20260309164000_api-key.sql Outdated
Comment thread src/migrations/postgres/20260309164000_api-key.sql
Comment thread src/migrations/mysql/20260309164000_api-key.sql Outdated
Comment thread src/dba/models/generator.php
Comment thread src/inc/apiv2/auth/JWTBeforeHandler.php Outdated
Comment thread src/inc/utils/JwtTokenUtils.php Outdated
Comment thread src/migrations/mysql/20260309164000_api-key.sql
Comment thread src/migrations/postgres/20260309164000_api-key.sql
Comment thread src/migrations/mysql/20260309164000_api-key.sql Outdated
Comment thread src/migrations/postgres/20260309164000_api-key.sql Outdated
Comment thread src/dba/models/generator.php
@jessevz jessevz requested a review from s3inlc March 12, 2026 12:12
Comment thread src/migrations/mysql/20260309164000_api-key.sql Outdated
Comment thread src/migrations/postgres/20260309164000_api-key.sql
Comment thread src/migrations/postgres/20260309164000_api-key.sql Outdated
@jessevz jessevz requested a review from s3inlc March 12, 2026 14:24
@jessevz jessevz merged commit 792b996 into dev Mar 16, 2026
4 checks passed
@jessevz jessevz deleted the api-tokens branch March 16, 2026 07:01
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