MCPcopy Create free account
hub / github.com/pace/bricks / GetTokenFromContext

Function GetTokenFromContext

http/security/helper.go:46–53  ·  view source on GitHub ↗

GetTokenFromContext returns the token, if it is stored in the context, and true if the token is present.

(ctx context.Context)

Source from the content-addressed store, hash-verified

44
45// GetTokenFromContext returns the token, if it is stored in the context, and true if the token is present.
46func GetTokenFromContext(ctx context.Context) (Token, bool) {
47 val := ctx.Value(tokenKey)
48 if val == nil {
49 return nil, false
50 }
51 tok, ok := val.(Token)
52 return tok, ok
53}
54
55// GetAuthHeader creates the valid value for the authentication header
56func GetAuthHeader(tok Token) string {

Callers 15

AuthorizeUnaryMethod · 0.92
RequestFunction · 0.92
HasScopeFunction · 0.92
UserIDFunction · 0.92
AuthTimeFunction · 0.92
ScopesFunction · 0.92
AddScopeFunction · 0.92
ClientIDFunction · 0.92
BackendFunction · 0.92
ContextTransferFunction · 0.92
BearerTokenFunction · 0.92

Calls 1

ValueMethod · 0.80

Tested by 6

TestSuccessfulAccessorsFunction · 0.74
TestWithBearerTokenFunction · 0.74
TestAddScopeFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…