auth_context

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Must match authz-service/../constants.go#AllProjectsExternalID
	AllProjectsKey = "*"
)
View Source
var (
	ErrParseAuthContext = errors.New("could not parse auth context")
)

Functions

func AllProjectsRequested

func AllProjectsRequested(projectsFilter []string) bool

AllProjectsRequested takes in the project filter list and returns true if the list is a single entry of *.

func ContextWithoutProjects

func ContextWithoutProjects(ctx context.Context) context.Context

ContextWithoutProjects removes previously added projects from the GRPC metadata for those system operations that must not be filtered by projects.

func FromIncomingMetadata

func FromIncomingMetadata(ctx context.Context) context.Context

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, pol string) context.Context

NewContext returns a new `context.Context` that holds a reference to the provided properties

func NewOutgoingContext

func NewOutgoingContext(ctx context.Context) context.Context

NewOutgoingContext translates previously injected auth_context info into GRPC metadata, to be consumed by the downstream service.

func NewOutgoingProjectsContext

func NewOutgoingProjectsContext(ctx context.Context) context.Context

NewOutgoingProjectsContext translates previously injected auth_context info into GRPC metadata, to be consumed by the downstream service, but only for projects.

func PolicyVersion

func PolicyVersion(ctx context.Context) (pol string)

PolicyVersion returns the auth policy version associated with `ctx`, or "" if it could not be found.

func ProjectsFromIncomingContext

func ProjectsFromIncomingContext(ctx context.Context) ([]string, error)

ProjectsFromIncomingContext parses the projects from the incoming request context. It throws an error if there is an issue parsing the context.

func Subjects

func Subjects(ctx context.Context) (subs []string)

Subjects returns the auth subjects associated with `ctx`, or `nil` if it could not be found.

Types

type Properties

type Properties struct {
	Subjects      []string
	Projects      []string
	Resource      string
	Action        string
	PolicyVersion 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.

Jump to

Keyboard shortcuts

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