jojo/services/context
forgejo-backport-action 0aa1b45956 [v15.0/forgejo] refactor: change authentication to return structured data (#12462)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/12202

Currently authentication methods return information in two forms: they return who was authenticated as a `*user_model.User`, and then they insert key-values into `ctx.Data` which has critical impact on how the authenticated request is treated.  This PR changes the authentication methods to return structured data in the form of an `AuthenticationResult`, with all the key-value information in `ctx.Data` being moved into methods on the `AuthenticationResult` interface.

Authentication workflows in Forgejo are a real mess.  This is the first step in trying to clean it up and make the code predictable and reasonable, and is both follow-up work that was identified from the repo-specific access tokens (where the `"ApiTokenReducer"` key-value was added), and is pre-requisite work to future JWT enhancements that are [being discussed](https://codeberg.org/forgejo/forgejo/issues/3571#issuecomment-13268004).

Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12462
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2026-05-08 04:07:32 +02:00
..
upload [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
access_log.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
api.go [v15.0/forgejo] refactor: change authentication to return structured data (#12462) 2026-05-08 04:07:32 +02:00
api_org.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
api_test.go feat: remove admin-level permissions from repo-specific & public-only access tokens (#11468) 2026-03-04 16:17:41 +01:00
base.go fix: omit Content-Length on 307 redirects when serving direct manifest for containers (#8037) 2025-06-09 08:43:41 +02:00
base_test.go branding!: make cookies brand independent (#10645) 2026-03-19 04:34:27 +01:00
captcha.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
context.go [v15.0/forgejo] refactor: change authentication to return structured data (#12462) 2026-05-08 04:07:32 +02:00
context_cookie.go branding!: make cookies brand independent (#10645) 2026-03-19 04:34:27 +01:00
context_model.go [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
context_request.go fix: return bad request on malformed packages upload input (#10954) 2026-02-13 18:04:19 +01:00
context_response.go chore: handle error types consistently (#9873) 2026-03-06 00:48:06 +01:00
context_test.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
org.go fix: do visibility check for user redirect lookup 2025-08-30 09:37:25 +02:00
package.go feat: Global 2FA enforcement (#8753) 2025-08-15 10:56:45 +02:00
pagination.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
permission.go [v15.0/forgejo] refactor: change authentication to return structured data (#12462) 2026-05-08 04:07:32 +02:00
private.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
quota.go Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367) 2025-03-28 22:22:21 +00:00
repo.go [v15.0/forgejo]: chore: add modernizer linter (#11949) 2026-04-02 16:54:46 +02:00
repository.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
response.go chore: branding import path (#7337) 2025-03-27 19:40:14 +00:00
user.go fix: do visibility check for user redirect lookup 2025-08-30 09:37:25 +02:00
utils.go Move context from modules to services (#29440) 2024-03-06 12:10:43 +08:00