0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-17 19:25:28 +02:00
ChristopherHX f65df2a69b
Refactor Nuget Auth to reuse Basic Auth Token Validation (#36558)
* Implicitly handle Actions Task Token for Nuget Api Keys
* Support same tokens as Basic Auth in Nuget Api Key Header

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-02-08 14:43:05 +00:00

27 lines
664 B
Go

// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package nuget
import (
"net/http"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/services/auth"
)
var _ auth.Method = &Auth{}
type Auth struct {
basicAuth auth.Basic
}
func (a *Auth) Name() string {
return "nuget"
}
func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataStore, sess auth.SessionStore) (*user_model.User, error) {
// ref: https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#request-parameters
return a.basicAuth.VerifyAuthToken(req, w, store, sess, req.Header.Get("X-NuGet-ApiKey"))
}