user

package
v0.0.0-...-d74ee84 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

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"
)
View Source
const (
	ErrNoOrgID               = errors.Error("no org id")
	ErrDifferentOrgIDPresent = errors.Error("different org ID already present")
	ErrTooManyOrgIDs         = errors.Error("multiple org IDs present")

	ErrNoUserID               = errors.Error("no user id")
	ErrDifferentUserIDPresent = errors.Error("different user ID already present")
	ErrTooManyUserIDs         = errors.Error("multiple user IDs present")
)

Errors that we return

Variables

This section is empty.

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

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