auth: remove micro specific code (#1999)
This commit is contained in:
19
auth/auth.go
19
auth/auth.go
@@ -2,14 +2,11 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// BearerScheme used for Authorization header
|
|
||||||
BearerScheme = "Bearer "
|
|
||||||
// ScopePublic is the scope applied to a rule to allow access to the public
|
// ScopePublic is the scope applied to a rule to allow access to the public
|
||||||
ScopePublic = ""
|
ScopePublic = ""
|
||||||
// ScopeAccount is the scope applied to a rule to limit to users with any valid account
|
// ScopeAccount is the scope applied to a rule to limit to users with any valid account
|
||||||
@@ -117,19 +114,3 @@ type Rule struct {
|
|||||||
// rule will be applied
|
// rule will be applied
|
||||||
Priority int32
|
Priority int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type accountKey struct{}
|
|
||||||
|
|
||||||
// AccountFromContext gets the account from the context, which
|
|
||||||
// is set by the auth wrapper at the start of a call. If the account
|
|
||||||
// is not set, a nil account will be returned. The error is only returned
|
|
||||||
// when there was a problem retrieving an account
|
|
||||||
func AccountFromContext(ctx context.Context) (*Account, bool) {
|
|
||||||
acc, ok := ctx.Value(accountKey{}).(*Account)
|
|
||||||
return acc, ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContextWithAccount sets the account in the context
|
|
||||||
func ContextWithAccount(ctx context.Context, account *Account) context.Context {
|
|
||||||
return context.WithValue(ctx, accountKey{}, account)
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user