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

Function ListClient

pkg/auth/rights/list.go:57–85  ·  view source on GitHub ↗

ListClient lists the rights for the given client ID in the context.

(ctx context.Context, id *ttnpb.ClientIdentifiers)

Source from the content-addressed store, hash-verified

55
56// ListClient lists the rights for the given client ID in the context.
57func ListClient(ctx context.Context, id *ttnpb.ClientIdentifiers) (rights *ttnpb.Rights, err error) {
58 uid := unique.ID(ctx, id)
59 if inCtx, ok := fromContext(ctx); ok {
60 r, _ := inCtx.ClientRights.GetRights(uid)
61 return r, nil
62 }
63 if inCtx, ok := cacheFromContext(ctx); ok {
64 if r, ok := inCtx.ClientRights.GetRights(uid); ok {
65 return r, nil
66 }
67 }
68 defer func() {
69 if err == nil {
70 cacheInContext(ctx, func(r *Rights) { r.setClientRights(uid, rights) })
71 }
72 }()
73 fetcher, ok := fetcherFromContext(ctx)
74 if !ok {
75 panic(errNoFetcher)
76 }
77 rights, err = fetcher.ClientRights(ctx, id)
78 if err != nil {
79 if errors.IsPermissionDenied(err) {
80 return &ttnpb.Rights{}, nil
81 }
82 return nil, err
83 }
84 return rights, nil
85}
86
87// ListGateway lists the rights for the given gateway ID in the context.
88func ListGateway(ctx context.Context, id *ttnpb.GatewayIdentifiers) (rights *ttnpb.Rights, err error) {

Callers 4

EventIsVisibleFunction · 0.92
listClientRightsMethod · 0.92
RequireClientFunction · 0.85
RequireAnyFunction · 0.85

Calls 9

IDFunction · 0.92
IsPermissionDeniedFunction · 0.92
fromContextFunction · 0.85
cacheFromContextFunction · 0.85
cacheInContextFunction · 0.85
setClientRightsMethod · 0.80
fetcherFromContextFunction · 0.70
ClientRightsMethod · 0.65
GetRightsMethod · 0.45

Tested by

no test coverage detected