auth

package
v0.51.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BearerPrefix = "Bearer "
)

Variables

This section is empty.

Functions

func CheckInternal

func CheckInternal(ctx context.Context) bool

TODO: Remove as soon an authentification is implemented

func CheckUserAuthorization

func CheckUserAuthorization(ctx context.Context, req interface{}, token, orgID string, verifier TokenVerifier, authConfig *Config, requiredAuthOption Option) (context.Context, error)

func ExistsPerm added in v0.20.0

func ExistsPerm(existing []string, perm string) bool

func GetPermissionCtxIDs

func GetPermissionCtxIDs(perms []string) []string

func GetPermissionsFromCtx

func GetPermissionsFromCtx(ctx context.Context) []string

func HasGlobalPermission

func HasGlobalPermission(perms []string) bool

func NewMockContext

func NewMockContext(orgID, userID string) context.Context

func SetCtxData added in v0.15.0

func SetCtxData(ctx context.Context, ctxData CtxData) context.Context

func SplitPermission

func SplitPermission(perm string) (string, string)

func VerifyTokenAndWriteCtxData

func VerifyTokenAndWriteCtxData(ctx context.Context, token, orgID string, t TokenVerifier) (_ context.Context, err error)

Types

type Config

type Config struct {
	RolePermissionMappings []RoleMapping
}

type CtxData

type CtxData struct {
	UserID            string
	OrgID             string
	ProjectID         string
	AgentID           string
	PreferredLanguage string
}

func GetCtxData

func GetCtxData(ctx context.Context) CtxData

func (CtxData) IsZero

func (ctxData CtxData) IsZero() bool

type Grant

type Grant struct {
	OrgID string
	Roles []string
}

type Grants

type Grants []*Grant

type MethodMapping

type MethodMapping map[string]Option

type Option

type Option struct {
	Permission string
	CheckParam string
}

type RoleMapping

type RoleMapping struct {
	Role        string
	Permissions []string
}

type TokenVerifier

type TokenVerifier interface {
	VerifyAccessToken(ctx context.Context, token string) (string, string, string, error)
	ResolveGrant(ctx context.Context) (*Grant, error)
	GetProjectIDByClientID(ctx context.Context, clientID string) (string, error)
}

Jump to

Keyboard shortcuts

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