Documentation ¶
Index ¶
- Variables
- func AllProjectsRequested(projectsFilter []string) bool
- func ContextWithoutProjects(ctx context.Context) context.Context
- func FromIncomingMetadata(ctx context.Context) context.Context
- func NewContext(ctx context.Context, subs []string, projects []string, res, act string) context.Context
- func NewOutgoingContext(ctx context.Context) context.Context
- func NewOutgoingProjectsContext(ctx context.Context) context.Context
- func NewOutgoingRequestorInfoContext(ctx context.Context) context.Context
- func NewRequestorContext(ctx context.Context, requestorID string) context.Context
- func ProjectsFromIncomingContext(ctx context.Context) ([]string, error)
- func ProjectsFromMetadata(md metadata.MD) []string
- func RequestorFromIncomingContext(ctx context.Context) (string, error)
- func Subjects(ctx context.Context) (subs []string)
- type Properties
Constants ¶
This section is empty.
Variables ¶
var (
// Must match authz-service/../constants.go#AllProjectsExternalID
AllProjectsKey = "*"
)
var (
ErrParseAuthContext = errors.New("could not parse auth context")
)
Functions ¶
func AllProjectsRequested ¶
AllProjectsRequested takes in the project filter list and returns true if the list is a single entry of *.
func ContextWithoutProjects ¶
ContextWithoutProjects removes any projects from the incoming GRPC metadata attached to the context. Following attempts to read projects from incoming metadata will yield nothing -- so this can be used in handlers that should not do projects filtering, but would do that if the key was present.
func FromIncomingMetadata ¶
FromIncomingMetadata translates auth info provided by GRPC metadata into auth_context's representation, to be retrieved via auth_context.FromContext.
func NewContext ¶
func NewContext(ctx context.Context, subs []string, projects []string, res, act string) context.Context
NewContext returns a new `context.Context` that holds a reference to the provided properties
func NewOutgoingContext ¶
NewOutgoingContext translates previously injected auth_context info into GRPC metadata, to be consumed by the downstream service.
func NewOutgoingProjectsContext ¶
NewOutgoingProjectsContext translates previously injected auth_context info into GRPC metadata, to be consumed by the downstream service, but only for projects.
func NewRequestorContext ¶
func ProjectsFromIncomingContext ¶
ProjectsFromIncomingContext parses the projects from the incoming request context. It throws an error if there is an issue parsing the context.
func ProjectsFromMetadata ¶
ProjectsFromMetadata extracts the requested projects from (incoming) metadata as provided by grpc-gateway (so, it's expecting, and removing, grpc-gateway's key prefixes).
Types ¶
type Properties ¶
type Properties struct { Subjects []string Projects []string Resource string Action string RequestorID string }
Properties is a container for metadata available from the context.
func FromContext ¶
func FromContext(ctx context.Context) *Properties
FromContext returns the auth data previously associated with `ctx`, or `nil` or "" if a piece of the information could not be found.