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

Method ClientRights

pkg/identityserver/rights.go:123–141  ·  view source on GitHub ↗

ClientRights returns the rights the caller has on the given client.

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

Source from the content-addressed store, hash-verified

121
122// ClientRights returns the rights the caller has on the given client.
123func (is *IdentityServer) ClientRights(ctx context.Context, cliIDs *ttnpb.ClientIdentifiers) (*ttnpb.Rights, error) {
124 entity, universal, err := is.getRights(ctx, cliIDs.GetEntityIdentifiers())
125 if err != nil {
126 return nil, err
127 }
128 err = is.store.Transact(ctx, func(ctx context.Context, st store.Store) error {
129 _, err := st.GetClient(ctx, cliIDs, []string{"ids"})
130 return err
131 })
132 if errors.IsNotFound(err) {
133 if is.IsAdmin(ctx) {
134 return nil, err
135 }
136 return &ttnpb.Rights{}, nil
137 } else if err != nil {
138 return nil, err
139 }
140 return entity.Union(universal), nil
141}
142
143// GatewayRights returns the rights the caller has on the given gateway.
144// The query for the gateway only considers the Gateway ID and not the EUI (if provided).

Callers

nothing calls this directly

Implementers 5

mockInteroppkg/component/interop_test.go
interopServerpkg/joinserver/http_interop.go
noopServerpkg/interop/server.go
mockTargetpkg/interop/server_test.go
interopServerpkg/identityserver/http_interop.go

Calls 7

getRightsMethod · 0.95
IsAdminMethod · 0.95
IsNotFoundFunction · 0.92
UnionMethod · 0.80
GetEntityIdentifiersMethod · 0.65
TransactMethod · 0.65
GetClientMethod · 0.65

Tested by

no test coverage detected