user

package
v0.0.0-...-de40865 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 38

Documentation

Index

Constants

View Source
const (

	// OrgIDHeaderName denotes the OrgID the request has been authenticated as
	OrgIDHeaderName = "X-Scope-OrgID"
	// UserIDHeaderName denotes the UserID the request has been authenticated as
	UserIDHeaderName = "X-Scope-UserID"
)

Variables

View Source
var (
	ErrNoOrgID               = errors.New("no org id")
	ErrDifferentOrgIDPresent = errors.New("different org ID already present")
	ErrTooManyOrgIDs         = errors.New("multiple org IDs present")

	ErrNoUserID               = errors.New("no user id")
	ErrDifferentUserIDPresent = errors.New("different user ID already present")
)

Errors that we return

Functions

func ExtractFromGRPCRequest

func ExtractFromGRPCRequest(ctx context.Context) (string, context.Context, error)

ExtractFromGRPCRequest extracts the user ID from the request metadata and returns the user ID and a context with the user ID injected.

func ExtractOrgID

func ExtractOrgID(ctx context.Context) (string, error)

ExtractOrgID gets the org ID from the context.

func ExtractOrgIDFromHTTPRequest

func ExtractOrgIDFromHTTPRequest(r *http.Request) (string, context.Context, error)

ExtractOrgIDFromHTTPRequest extracts the org ID from the request headers and returns the org ID and a context with the org ID embedded.

func ExtractUserID

func ExtractUserID(ctx context.Context) (string, error)

ExtractUserID gets the user ID from the context.

func ExtractUserIDFromHTTPRequest

func ExtractUserIDFromHTTPRequest(r *http.Request) (string, context.Context, error)

ExtractUserIDFromHTTPRequest extracts the org ID from the request headers and returns the org ID and a context with the org ID embedded.

func InjectIntoGRPCRequest

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

InjectIntoGRPCRequest injects the orgID from the context into the request metadata.

func InjectOrgID

func InjectOrgID(ctx context.Context, orgID string) context.Context

InjectOrgID returns a derived context containing the org ID.

func InjectOrgIDIntoHTTPRequest

func InjectOrgIDIntoHTTPRequest(ctx context.Context, r *http.Request) error

InjectOrgIDIntoHTTPRequest injects the orgID from the context into the request headers.

func InjectUserID

func InjectUserID(ctx context.Context, userID string) context.Context

InjectUserID returns a derived context containing the user ID.

func InjectUserIDIntoHTTPRequest

func InjectUserIDIntoHTTPRequest(ctx context.Context, r *http.Request) error

InjectUserIDIntoHTTPRequest injects the userID from the context into the request headers.

func LogWith

func LogWith(ctx context.Context, logger log.Logger) log.Logger

LogWith returns user and org information from the context as log fields.

Types

This section is empty.

Jump to

Keyboard shortcuts

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