Documentation ¶
Index ¶
- Variables
- func ContextWithActor(ctx context.Context, user AuthenticatedUser, roles []*role.Role) context.Context
- func RequireGlobalAdmin(ctx context.Context) error
- func RequireGlobalAuthorization(actor *Actor, requiredAuthzName role.Authorization) error
- func RequireTeamAuthorization(actor *Actor, requiredAuthzName role.Authorization, targetTeamSlug slug.Slug) error
- func RequireTeamAuthorizationCtx(ctx context.Context, requiredAuthzName role.Authorization, ...) error
- type Actor
- type AuthenticatedUser
- type ContextKey
- type ErrMissingAuthorization
- type MockAuthenticatedUser
- type MockAuthenticatedUser_Expecter
- type MockAuthenticatedUser_GetID_Call
- func (_c *MockAuthenticatedUser_GetID_Call) Return(_a0 uuid.UUID) *MockAuthenticatedUser_GetID_Call
- func (_c *MockAuthenticatedUser_GetID_Call) Run(run func()) *MockAuthenticatedUser_GetID_Call
- func (_c *MockAuthenticatedUser_GetID_Call) RunAndReturn(run func() uuid.UUID) *MockAuthenticatedUser_GetID_Call
- type MockAuthenticatedUser_Identity_Call
- func (_c *MockAuthenticatedUser_Identity_Call) Return(_a0 string) *MockAuthenticatedUser_Identity_Call
- func (_c *MockAuthenticatedUser_Identity_Call) Run(run func()) *MockAuthenticatedUser_Identity_Call
- func (_c *MockAuthenticatedUser_Identity_Call) RunAndReturn(run func() string) *MockAuthenticatedUser_Identity_Call
- type MockAuthenticatedUser_IsServiceAccount_Call
- func (_c *MockAuthenticatedUser_IsServiceAccount_Call) Return(_a0 bool) *MockAuthenticatedUser_IsServiceAccount_Call
- func (_c *MockAuthenticatedUser_IsServiceAccount_Call) Run(run func()) *MockAuthenticatedUser_IsServiceAccount_Call
- func (_c *MockAuthenticatedUser_IsServiceAccount_Call) RunAndReturn(run func() bool) *MockAuthenticatedUser_IsServiceAccount_Call
Constants ¶
This section is empty.
Variables ¶
var ErrNotAuthenticated = errors.New("not authenticated")
Functions ¶
func ContextWithActor ¶
func ContextWithActor(ctx context.Context, user AuthenticatedUser, roles []*role.Role) context.Context
ContextWithActor Return a context with an actor attached to it.
func RequireGlobalAdmin ¶
func RequireGlobalAuthorization ¶
func RequireGlobalAuthorization(actor *Actor, requiredAuthzName role.Authorization) error
RequireGlobalAuthorization Require an actor to have a specific authorization through a globally assigned role.
func RequireTeamAuthorization ¶
func RequireTeamAuthorization(actor *Actor, requiredAuthzName role.Authorization, targetTeamSlug slug.Slug) error
RequireTeamAuthorization Require an actor to have a specific authorization through a globally assigned or a correctly targeted role.
func RequireTeamAuthorizationCtx ¶
func RequireTeamAuthorizationCtx(ctx context.Context, requiredAuthzName role.Authorization, targetTeamSlug slug.Slug) error
RequireTeamAuthorizationCtx fetches the actor from the context and checks if it has the required authorization.
Types ¶
type Actor ¶
type Actor struct { User AuthenticatedUser Roles []*role.Role }
func ActorFromContext ¶
ActorFromContext Get the actor stored in the context. Requires that a middleware has stored an actor in the first place.
func (*Actor) Authenticated ¶
type AuthenticatedUser ¶
type ContextKey ¶
type ContextKey string
type ErrMissingAuthorization ¶
type ErrMissingAuthorization struct {
// contains filtered or unexported fields
}
func (ErrMissingAuthorization) Error ¶
func (e ErrMissingAuthorization) Error() string
func (ErrMissingAuthorization) GraphError ¶
func (e ErrMissingAuthorization) GraphError() string
type MockAuthenticatedUser ¶
MockAuthenticatedUser is an autogenerated mock type for the AuthenticatedUser type
func NewMockAuthenticatedUser ¶
func NewMockAuthenticatedUser(t interface { mock.TestingT Cleanup(func()) }, ) *MockAuthenticatedUser
NewMockAuthenticatedUser creates a new instance of MockAuthenticatedUser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockAuthenticatedUser) EXPECT ¶
func (_m *MockAuthenticatedUser) EXPECT() *MockAuthenticatedUser_Expecter
func (*MockAuthenticatedUser) GetID ¶
func (_m *MockAuthenticatedUser) GetID() uuid.UUID
GetID provides a mock function with given fields:
func (*MockAuthenticatedUser) Identity ¶
func (_m *MockAuthenticatedUser) Identity() string
Identity provides a mock function with given fields:
func (*MockAuthenticatedUser) IsServiceAccount ¶
func (_m *MockAuthenticatedUser) IsServiceAccount() bool
IsServiceAccount provides a mock function with given fields:
type MockAuthenticatedUser_Expecter ¶
type MockAuthenticatedUser_Expecter struct {
// contains filtered or unexported fields
}
func (*MockAuthenticatedUser_Expecter) GetID ¶
func (_e *MockAuthenticatedUser_Expecter) GetID() *MockAuthenticatedUser_GetID_Call
GetID is a helper method to define mock.On call
func (*MockAuthenticatedUser_Expecter) Identity ¶
func (_e *MockAuthenticatedUser_Expecter) Identity() *MockAuthenticatedUser_Identity_Call
Identity is a helper method to define mock.On call
func (*MockAuthenticatedUser_Expecter) IsServiceAccount ¶
func (_e *MockAuthenticatedUser_Expecter) IsServiceAccount() *MockAuthenticatedUser_IsServiceAccount_Call
IsServiceAccount is a helper method to define mock.On call
type MockAuthenticatedUser_GetID_Call ¶
MockAuthenticatedUser_GetID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetID'
func (*MockAuthenticatedUser_GetID_Call) Return ¶
func (_c *MockAuthenticatedUser_GetID_Call) Return(_a0 uuid.UUID) *MockAuthenticatedUser_GetID_Call
func (*MockAuthenticatedUser_GetID_Call) Run ¶
func (_c *MockAuthenticatedUser_GetID_Call) Run(run func()) *MockAuthenticatedUser_GetID_Call
func (*MockAuthenticatedUser_GetID_Call) RunAndReturn ¶
func (_c *MockAuthenticatedUser_GetID_Call) RunAndReturn(run func() uuid.UUID) *MockAuthenticatedUser_GetID_Call
type MockAuthenticatedUser_Identity_Call ¶
MockAuthenticatedUser_Identity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Identity'
func (*MockAuthenticatedUser_Identity_Call) Return ¶
func (_c *MockAuthenticatedUser_Identity_Call) Return(_a0 string) *MockAuthenticatedUser_Identity_Call
func (*MockAuthenticatedUser_Identity_Call) Run ¶
func (_c *MockAuthenticatedUser_Identity_Call) Run(run func()) *MockAuthenticatedUser_Identity_Call
func (*MockAuthenticatedUser_Identity_Call) RunAndReturn ¶
func (_c *MockAuthenticatedUser_Identity_Call) RunAndReturn(run func() string) *MockAuthenticatedUser_Identity_Call
type MockAuthenticatedUser_IsServiceAccount_Call ¶
MockAuthenticatedUser_IsServiceAccount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsServiceAccount'
func (*MockAuthenticatedUser_IsServiceAccount_Call) Return ¶
func (_c *MockAuthenticatedUser_IsServiceAccount_Call) Return(_a0 bool) *MockAuthenticatedUser_IsServiceAccount_Call
func (*MockAuthenticatedUser_IsServiceAccount_Call) Run ¶
func (_c *MockAuthenticatedUser_IsServiceAccount_Call) Run(run func()) *MockAuthenticatedUser_IsServiceAccount_Call
func (*MockAuthenticatedUser_IsServiceAccount_Call) RunAndReturn ¶
func (_c *MockAuthenticatedUser_IsServiceAccount_Call) RunAndReturn(run func() bool) *MockAuthenticatedUser_IsServiceAccount_Call