forked from TrueCloudLab/frostfs-s3-gw
*: drop old sdk dependecies, bump neofs-api-go version
I'm not sure it works, but it's enough code-wise for now. We're reusing some http-gw components here that are to be moved into sdk-go in future. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
dbe65ae602
commit
d19ce03072
15 changed files with 263 additions and 163 deletions
|
@ -1,14 +1,16 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
sdk "github.com/nspcc-dev/cdn-sdk"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/auth"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const BearerTokenKey = "__context_bearer_token_key"
|
||||
|
||||
// AttachUserAuth adds user authentication via center to router using log for logging.
|
||||
func AttachUserAuth(router *mux.Router, center auth.Center, log *zap.Logger) {
|
||||
router.Use(func(h http.Handler) http.Handler {
|
||||
|
@ -21,7 +23,7 @@ func AttachUserAuth(router *mux.Router, center auth.Center, log *zap.Logger) {
|
|||
}
|
||||
|
||||
h.ServeHTTP(w, r.WithContext(
|
||||
sdk.SetBearerToken(r.Context(), token)))
|
||||
context.WithValue(r.Context(), BearerTokenKey, token)))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue