MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / SplitToken

Function SplitToken

pkg/auth/auth.go:93–104  ·  view source on GitHub ↗

SplitToken splits the token from " . . ".

(token string)

Source from the content-addressed store, hash-verified

91
92// SplitToken splits the token from "<prefix>.<id>.<key>".
93func SplitToken(token string) (tokenType TokenType, id, key string, err error) {
94 parts := strings.Split(token, ".")
95 if len(parts) != 3 {
96 return "", "", "", errInvalidToken.New()
97 }
98 switch TokenType(parts[0]) {
99 case APIKey, AccessToken, RefreshToken, AuthorizationCode, SessionToken:
100 return TokenType(parts[0]), parts[1], parts[2], nil
101 default:
102 return "", "", "", errInvalidToken.New()
103 }
104}
105
106// JoinToken joins the token as "<prefix>.<id>.<key>".
107func JoinToken(tokenType TokenType, id, key string) string {

Callers 15

ProtocolAuthenticationFunction · 0.92
TestAuthFunction · 0.92
SaveAccessMethod · 0.92
RemoveAccessMethod · 0.92
LoadRefreshMethod · 0.92
RemoveRefreshMethod · 0.92
ErrorFunction · 0.92
canSkipCSRFMiddlewareFunction · 0.92
canSkipCSRFCheckFunction · 0.92
LogFunction · 0.92
rewriteAuthorizationFunction · 0.92
WithAuthFromContextFunction · 0.92

Calls 2

TokenTypeTypeAlias · 0.85
NewMethod · 0.65

Tested by 2

TestAuthFunction · 0.74
TestEntityAccessFunction · 0.74