auth

package
v0.0.0-...-87fd372 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AdminRole specified the admin role, with privileges to manage all Jobs.
	AdminRole = "admin"
	// UserRole specified the user role, with privileges to manage only owned Jobs.
	UserRole = "user"
)

Variables

This section is empty.

Functions

func GRPCStreamInterceptor

func GRPCStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

GRPCStreamInterceptor extracts user's information from the client certificates and put it in context.

func GRPCUnaryInterceptor

func GRPCUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

GRPCUnaryInterceptor extracts user's information from the client certificates and put it in context.

func NewContext

func NewContext(ctx context.Context, u *User) context.Context

NewContext returns a new Context with a given user.

func NewGRPCInvalidCertError

func NewGRPCInvalidCertError(err error) error

NewGRPCInvalidCertError returns error indicating that client certificate was present on gRPC call but it is incorrect.

func NewGRPCMissingCertError

func NewGRPCMissingCertError() error

NewGRPCMissingCertError returns error indicating that client certificate is missing on gRPC call.

func NewGRPCPermissionDeniedError

func NewGRPCPermissionDeniedError() error

NewGRPCPermissionDeniedError returns error indicating that client certificate was present on gRPC call, it was correct, but given user doesn't have enough permission to perform a given action.

Types

type User

type User struct {
	Name  string
	Roles map[string]struct{}
}

User represent Agent user entity.

func FromContext

func FromContext(ctx context.Context) (*User, error)

FromContext returns the User stored in ctx, or error if not available.

func NewUser

func NewUser(name string, roles []string) *User

NewUser returns new User instance.

func (*User) CheckAuthorized

func (u *User) CheckAuthorized(createdBy string) error

CheckAuthorized checks if a given user is authorized to work with a given resource.

func (*User) Validate

func (u *User) Validate() error

Validate validates if User has required properties.

Jump to

Keyboard shortcuts

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