authz

package
v1.80.0-pref-login-name.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BearerPrefix = "Bearer "
)

Variables

This section is empty.

Functions

func CheckUserAuthorization

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

func ExistsPerm

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

func GetAllPermissionCtxIDs

func GetAllPermissionCtxIDs(perms []string) []string

func GetAllPermissionsFromCtx

func GetAllPermissionsFromCtx(ctx context.Context) []string

func GetExplicitPermissionCtxIDs

func GetExplicitPermissionCtxIDs(perms []string, searchPerm string) []string

func GetRequestPermissionsFromCtx

func GetRequestPermissionsFromCtx(ctx context.Context) []string

func HasGlobalExplicitPermission

func HasGlobalExplicitPermission(perms []string, permToCheck string) bool

func HasGlobalPermission

func HasGlobalPermission(perms []string) bool

func NewMockContext

func NewMockContext(instanceID, orgID, userID string) context.Context

func NewMockContextWithPermissions

func NewMockContextWithPermissions(instanceID, orgID, userID string, permissions []string) context.Context

func SetCtxData

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

func SplitPermission

func SplitPermission(perm string) (string, string)

func WithConsole

func WithConsole(ctx context.Context, projectID, appID string) context.Context

func WithInstance

func WithInstance(ctx context.Context, instance Instance) context.Context

func WithInstanceID

func WithInstanceID(ctx context.Context, id string) context.Context

func WithRequestedDomain

func WithRequestedDomain(ctx context.Context, domain string) context.Context

Types

type Config

type Config struct {
	RolePermissionMappings []RoleMapping
}

type CtxData

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

func GetCtxData

func GetCtxData(ctx context.Context) CtxData

func VerifyTokenAndCreateCtxData

func VerifyTokenAndCreateCtxData(ctx context.Context, token, orgID string, t *TokenVerifier, method string) (_ CtxData, err error)

func (CtxData) IsZero

func (ctxData CtxData) IsZero() bool

type Grant

type Grant struct {
	OrgID string
	Roles []string
}

type Grants

type Grants []*Grant

type Instance

type Instance interface {
	InstanceID() string
	ProjectID() string
	ConsoleClientID() string
	ConsoleApplicationID() string
	RequestedDomain() string
	RequestedHost() string
	DefaultLanguage() language.Tag
}

func GetInstance

func GetInstance(ctx context.Context) Instance

type InstanceVerifier

type InstanceVerifier interface {
	InstanceByHost(context.Context, string) (Instance, error)
}

type MemberType

type MemberType int32
const (
	MemberTypeUnspecified MemberType = iota
	MemberTypeOrganisation
	MemberTypeProject
	MemberTypeProjectGrant
	MemberTypeIam
)

type Membership

type Membership struct {
	MemberType  MemberType
	AggregateID string
	//ObjectID differs from aggregate id if object is sub of an aggregate
	ObjectID string

	Roles []string
}

type Memberships

type Memberships []*Membership

type MethodMapping

type MethodMapping map[string]Option

type Option

type Option struct {
	Permission string
	CheckParam string
	Feature    string
}

type RoleMapping

type RoleMapping struct {
	Role        string
	Permissions []string
}

type TokenVerifier

type TokenVerifier struct {
	// contains filtered or unexported fields
}

func Start

func Start(authZRepo authZRepo) (v *TokenVerifier)

func (*TokenVerifier) CheckAuthMethod

func (v *TokenVerifier) CheckAuthMethod(method string) (Option, bool)

func (*TokenVerifier) ExistsOrg

func (v *TokenVerifier) ExistsOrg(ctx context.Context, orgID string) (err error)

func (*TokenVerifier) ProjectIDAndOriginsByClientID

func (v *TokenVerifier) ProjectIDAndOriginsByClientID(ctx context.Context, clientID string) (_ string, _ []string, err error)

func (*TokenVerifier) RegisterServer

func (v *TokenVerifier) RegisterServer(appName, methodPrefix string, mappings MethodMapping)

func (*TokenVerifier) SearchMyMemberships

func (v *TokenVerifier) SearchMyMemberships(ctx context.Context) (_ []*Membership, err error)

func (*TokenVerifier) VerifyAccessToken

func (v *TokenVerifier) VerifyAccessToken(ctx context.Context, token string, method string) (userID, clientID, agentID, prefLang, resourceOwner string, err error)

Jump to

Keyboard shortcuts

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