mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-13 14:30:25 +00:00
**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>
20 lines
451 B
Go
20 lines
451 B
Go
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package method
|
|
|
|
import (
|
|
user_model "forgejo.org/models/user"
|
|
"forgejo.org/services/auth"
|
|
)
|
|
|
|
var _ auth.AuthenticationResult = &httpSignAuthenticationResult{}
|
|
|
|
type httpSignAuthenticationResult struct {
|
|
*auth.BaseAuthenticationResult
|
|
user *user_model.User
|
|
}
|
|
|
|
func (r *httpSignAuthenticationResult) User() *user_model.User {
|
|
return r.user
|
|
}
|