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

Function rightsFromScope

pkg/oauth/oauth.go:59–68  ·  view source on GitHub ↗

rightsFromScope is the opposite of RightsToScope. It transforms the string "scope" back into a list of rights. This function is only used for compatibility with osin.

(scope string)

Source from the content-addressed store, hash-verified

57// rightsFromScope is the opposite of RightsToScope. It transforms the string "scope" back into a list of rights.
58// This function is only used for compatibility with osin.
59func rightsFromScope(scope string) []ttnpb.Right {
60 scopes := strings.Split(scope, " ")
61 rights := make([]ttnpb.Right, 0, len(scopes))
62 for _, scope := range scopes {
63 if right, ok := ttnpb.Right_value[scope]; ok {
64 rights = append(rights, ttnpb.Right(right))
65 }
66 }
67 return ttnpb.RightsFrom(rights...).Sorted().GetRights()
68}
69
70var (
71 errClientMissingGrant = errors.DefinePermissionDenied("client_missing_grant", "OAuth client does not have {grant} grant")

Callers 2

SaveAuthorizeMethod · 0.85
SaveAccessMethod · 0.85

Calls 4

RightTypeAlias · 0.92
RightsFromFunction · 0.92
SortedMethod · 0.80
GetRightsMethod · 0.45

Tested by

no test coverage detected