jojo/services/actions
Mathieu Fenniak 9b88e77c19 feat: expose immutable identifiers in Forgejo Actions JWTs (#12355)
Protect OIDC tokens generated by Forgejo Actions from threats arising when users or repositories are renamed or deleted, freeing their names up for reuse by another user.  In this threat environment, relying on the name of users and repositories in validating JWT claims is unsafe because they can change.

Adds three new claims to Actions' OIDC tokens:
- `actor_id` -- the immutable identifier of the actor who triggered an Action run
- `repository_id` -- the immutable identifier of the repository on which the Action is running
- `repository_owner_id` -- the immutable identifier of the owner of the repository on which the Action is running

Repositories will change their subject (`sub`) OIDC claims to include these immutable identifiers.  Existing repositories will not change, in order to maintain compatibility with existing JWT usage.  The new format will be applied to new repositories, or can be applied by disabling and enabling the Actions unit.  The new format embeds the identifiers:
- **Existing repos:** `repo:my-org/my-repo:ref:refs/heads/main`
- **New repos:** `repo:my-org-123456/my-repo-456789:ref:refs/heads/main`

Fixes #12244.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests for Go changes

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Documentation

- [x] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
    - New fields will be added to documentation soon.
- [ ] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12355
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
2026-05-03 15:46:58 +02:00
..
Test_checkJobsOfRun fix: newly expanded dynamic matrix jobs can become stuck in a 'blocked' state (#11184) 2026-02-07 14:36:49 +01:00
Test_tryHandleIncompleteMatrix fix: empty dynamic matrix can leave action run hanging incomplete (#11063) 2026-01-27 17:10:59 +01:00
Test_tryHandleWorkflowCallOuterJob fix: superfluous increment of ActionTask attempt breaks job view (#11956) 2026-04-03 16:05:09 +02:00
TestActions_CancelOrApproveRun refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
TestActions_consistencyCheckRun fix: prevent jobs with unknown needs from running (#12046) 2026-04-10 15:40:08 +02:00
TestActionsNotifier_IsTrusted chore(refactor): replace ifNeedApproval with trust management 2025-11-06 11:07:39 +01:00
TestActionsTrust_GetPullRequestUserIsTrustedWithActions feat: trust management for runs created from a forked pull request 2025-11-06 11:07:38 +01:00
TestCancelAbandonedJobs fix: don't abandon Action jobs waiting for approval (#11145) 2026-02-04 16:00:18 +01:00
TestCancelPreviousJobs refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
TestCancelPreviousWithConcurrencyGroup refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
TestCreateCommitStatus fix: don't duplicate commit status records on workflows with empty name (#10678) 2026-01-02 19:02:10 +01:00
TestExpandLocalReusableWorkflows feat: expand reusable workflow calls into their inner jobs (#10525) 2025-12-24 20:47:21 +01:00
TestGetSecretsOfJob feat: support jobs.<job_id>.secrets with reusable workflow expansion (#10627) 2025-12-30 17:33:21 +01:00
TestRerun_RerunAllJobs refactor: move rerun logic to services (#12141) 2026-04-19 22:08:00 +02:00
TestRerun_RerunJob refactor: move rerun logic to services (#12141) 2026-04-19 22:08:00 +02:00
TestServiceActions_startTask feat: support timezone in scheduled workflows (#11851) 2026-04-04 18:23:06 +02:00
TestServicesActions_TransferLingeringLogs refactor: migrate from lib/pq to jackc/pgx (#10219) 2025-11-30 17:47:45 +01:00
auth.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
auth_test.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
cleanup.go feat: implement ephemeral runners (#9962) 2026-02-16 18:56:56 +01:00
cleanup_test.go feat: implement ephemeral runners (#9962) 2026-02-16 18:56:56 +01:00
clear_tasks.go Revert "fix: ensure actions logs are transferred when a task is done (#10008)" (#11462) 2026-03-02 15:34:09 +01:00
clear_tasks_test.go fix: don't abandon Action jobs waiting for approval (#11145) 2026-02-04 16:00:18 +01:00
commit_status.go fix: retain Forgejo Action's commit_status entries with distinct descriptions (#10696) 2026-01-05 14:47:27 +01:00
commit_status_test.go fix: retain Forgejo Action's commit_status entries with distinct descriptions (#10696) 2026-01-05 14:47:27 +01:00
context.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
context_test.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
download.go chore: make use of go1.26 features (#12369) 2026-05-01 22:51:48 +02:00
init.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
interface.go feat: add HTTP API endpoint for runner registration (#10677) 2026-01-05 04:59:04 +01:00
job_emitter.go fix: resolve outer workflow call to success, not failure, on inner job skip (#12224) 2026-04-22 13:41:25 +02:00
job_emitter_test.go fix: resolve outer workflow call to success, not failure, on inner job skip (#12224) 2026-04-22 13:41:25 +02:00
log.go fix: garbage collect lingering actions logs (#10009) 2025-11-18 18:59:01 +01:00
log_test.go chore: fix typos throughout the codebase (#10753) 2026-01-26 22:57:33 +01:00
main_test.go chore: move all test blank imports in a single package (#10662) 2026-01-02 05:32:32 +01:00
notifier.go fix: cancel runs pending approval when a PR is closed (#11134) 2026-02-02 23:20:41 +01:00
notifier_helper.go feat: support timezone in scheduled workflows (#11851) 2026-04-04 18:23:06 +02:00
notifier_helper_test.go feat: expand reusable workflow calls into their inner jobs (#10525) 2025-12-24 20:47:21 +01:00
rerun.go refactor: move rerun logic to services (#12141) 2026-04-19 22:08:00 +02:00
rerun_test.go refactor: move rerun logic to services (#12141) 2026-04-19 22:08:00 +02:00
reusable_workflows.go feat: expand reusable workflow calls into their inner jobs (#10525) 2025-12-24 20:47:21 +01:00
reusable_workflows_test.go feat: expand reusable workflow calls into their inner jobs (#10525) 2025-12-24 20:47:21 +01:00
run.go refactor: delegate to service for run cancellation (#12142) 2026-04-24 04:36:42 +02:00
run_test.go fix: prevent jobs with unknown needs from running (#12046) 2026-04-10 15:40:08 +02:00
schedule_tasks.go chore: replace github.com/robfig/cron/v3 (#12365) 2026-05-01 22:07:22 +02:00
schedule_tasks_test.go feat: support timezone in scheduled workflows (#11851) 2026-04-04 18:23:06 +02:00
secret.go feat: support jobs.<job_id>.secrets with reusable workflow expansion (#10627) 2025-12-30 17:33:21 +01:00
secret_test.go feat: support jobs.<job_id>.secrets with reusable workflow expansion (#10627) 2025-12-30 17:33:21 +01:00
task.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
task_test.go feat: expose immutable identifiers in Forgejo Actions JWTs (#12355) 2026-05-03 15:46:58 +02:00
trust.go fix: cancel runs pending approval when a PR is closed (#11134) 2026-02-02 23:20:41 +01:00
trust_test.go fix: cancel runs pending approval when a PR is closed (#11134) 2026-02-02 23:20:41 +01:00
variables.go feat: allow renaming and replacing secrets (#11732) 2026-03-23 03:30:02 +01:00
variables_test.go fix: allow Forgejo Actions environment variables starting with CI (#8850) 2025-08-10 22:56:16 +02:00
workflows.go feat: expand reusable workflow calls into their inner jobs (#10525) 2025-12-24 20:47:21 +01:00
workflows_test.go Update module code.forgejo.org/forgejo/runner/v11 to v12 (forgejo) (#10213) 2025-11-23 15:58:57 +01:00