mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-05 08:46:24 +00:00
Initial working authentication with SigV4
This commit is contained in:
23
auth/context.go
Normal file
23
auth/context.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package auth
|
||||
|
||||
import "context"
|
||||
|
||||
type RequestContext struct {
|
||||
Authenticated bool
|
||||
AccessKeyID string
|
||||
AuthType string
|
||||
}
|
||||
|
||||
type contextKey int
|
||||
|
||||
const requestContextKey contextKey = iota
|
||||
|
||||
func WithRequestContext(ctx context.Context, authCtx RequestContext) context.Context {
|
||||
return context.WithValue(ctx, requestContextKey, authCtx)
|
||||
}
|
||||
|
||||
func GetRequestContext(ctx context.Context) (RequestContext, bool) {
|
||||
value := ctx.Value(requestContextKey)
|
||||
authCtx, ok := value.(RequestContext)
|
||||
return authCtx, ok
|
||||
}
|
||||
Reference in New Issue
Block a user