scope

package
v3.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const MachineScope = "machine"

MachineScope marks a token minted through machine authentication. Machine auth is otherwise indistinguishable from a normal owner-scoped user token, so this marker lets privileged internal RPCs (for example gateway PublishEvent) verify that the caller is a reva daemon holding the machine secret.

Variables

This section is empty.

Functions

func AddAdminScope added in v3.13.0

func AddAdminScope(scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddAdminScope adds the admin scope: a short-lived privilege satisfying Admin API requests and nothing else. The scope map carries "admin" and no "user" key, so the token cannot act on any user's data.

func AddCodeFlowOCMShareScope added in v3.9.0

func AddCodeFlowOCMShareScope(share *ocmv1beta1.Share, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddCodeFlowOCMShareScope adds a shareId/resource-only scope used by code-flow exchanged JWTs. Unlike AddOCMShareScope, it deliberately omits Token so the long-lived shared secret is never embedded in exchanged-token scopes.

func AddLightweightAccountScope

func AddLightweightAccountScope(role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddLightweightAccountScope adds the scope to allow access to lightweight user.

func AddMachineScope added in v3.12.0

func AddMachineScope(scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddMachineScope adds the machine-auth marker scope. It only records that the token was issued via machine auth; resource access still comes from the other scopes on the token.

func AddOCMShareScope

func AddOCMShareScope(share *ocmv1beta1.Share, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddOCMShareScope adds the scope to allow access to an OCM share and the share resource. It carries the share metadata needed to resolve authenticated DAV requests without a second repository lookup, including Token for backward compatibility with legacy direct-secret flows.

func AddOwnerScope

func AddOwnerScope(scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddOwnerScope adds the default owner scope with access to all resources.

func AddPublicShareScope

func AddPublicShareScope(share *link.PublicShare, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddPublicShareScope adds the scope to allow access to a public share and the shared resource.

func AddReceivedShareScope

func AddReceivedShareScope(share *collaboration.ReceivedShare, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddReceivedShareScope adds the scope to allow access to a received user/group share and the shared resource.

func AddResourceInfoScope

func AddResourceInfoScope(r *provider.ResourceInfo, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddResourceInfoScope adds the scope to allow access to a resource info object.

func AddShareScope

func AddShareScope(share *collaboration.Share, role authpb.Role, scopes map[string]*authpb.Scope) (map[string]*authpb.Scope, error)

AddShareScope adds the scope to allow access to a user/group share and the shared resource.

func ContextWithMachineScope added in v3.12.0

func ContextWithMachineScope(ctx context.Context) (context.Context, error)

ContextWithMachineScope re-signs the caller's token with the machine (reva daemon) scope added, keeping the acting user and any existing scopes unchanged. It lets a reva service call daemon-only RPCs as the real user in the context, without impersonating anyone. The new token is signed with the shared JWT secret, which only reva services hold, so an end user cannot mint one themselves. Returns a context carrying the re-signed token.

func FormatScope

func FormatScope(scopeType string, scope *authpb.Scope) (string, error)

FormatScope create a pretty print of the scope.

func GetOCMSharesFromScopes

func GetOCMSharesFromScopes(scopes map[string]*authpb.Scope) ([]*ocmv1beta1.Share, error)

GetOCMSharesFromScopes returns all OCM shares in the given scope.

func GetPublicSharesFromScopes

func GetPublicSharesFromScopes(scopes map[string]*authpb.Scope) ([]*link.PublicShare, error)

GetPublicSharesFromScopes returns all public shares in the given scope.

func HasAdminScope added in v3.13.0

func HasAdminScope(scopes map[string]*authpb.Scope) bool

HasAdminScope reports whether a token's scopes include the admin scope. Such a token authorizes admin/control resources by capability alone (isAdminResource) and never by the caller's group membership — so its bearer, which may be a synthetic local-root identity unknown to any user provider, must not be subjected to a user-group lookup during token validation.

func IsAdminMethod added in v3.13.0

func IsAdminMethod(method string) bool

IsAdminMethod reports whether a full gRPC method belongs to the Admin API or the control channel. Callers that must exclude these operational RPCs from per-request accounting (e.g. request-activity tracking) use it too.

func VerifyScope

func VerifyScope(ctx context.Context, scopeMap map[string]*authpb.Scope, resource any) (bool, error)

VerifyScope is the function to be called when dismantling tokens to check if the token has access to a particular resource.

Types

type MethodResource added in v3.13.0

type MethodResource string

MethodResource identifies a gRPC call by its full method name. The auth interceptor passes it for a server-streaming call, whose request message is not yet available to type-switch on.

type Verifier

type Verifier func(context.Context, *authpb.Scope, any, *zerolog.Logger) (bool, error)

Verifier is the function signature which every scope verifier should implement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL