Documentation
¶
Overview ¶
Package auth is a generated GoMock package.
Package auth is a generated GoMock package.
Index ¶
- func AdminAuthorizer(adminGroup string) func(next http.Handler) http.Handler
- func IsAdmin(ctx context.Context) bool
- func Middleware(authenticator Authenticator, db ddb.Storage, idp IdentitySyncer) func(next http.Handler) http.Handler
- func TestingSetIsAdmin(ctx context.Context, isAdmin bool) context.Context
- func TestingSetUser(ctx context.Context, user identity.User) context.Context
- func TestingSetUserID(ctx context.Context, userID string) context.Context
- func UserFromContext(ctx context.Context) *identity.User
- func UserIDFromContext(ctx context.Context) string
- type Authenticator
- type Claims
- type IdentitySyncer
- type LambdaAuthenticator
- type MockAuthenticator
- type MockAuthenticatorMockRecorder
- type MockIdentitySyncer
- type MockIdentitySyncerMockRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdminAuthorizer ¶
AdminAuthorizer only allows users belonging to adminGroup to access administrative endpoints. The middleware currently gates all endpoints in the format /api/v1/admin/*
func IsAdmin ¶
IsAdmin returns whether the user is an administrator or not. It requires that the AdminAuthorizer middleware has run.
func Middleware ¶
func Middleware(authenticator Authenticator, db ddb.Storage, idp IdentitySyncer) func(next http.Handler) http.Handler
Middleware is authentication middleware for the Common Fate API.
It takes an Authenticator which knows how to extract the user's identity from the incoming request. If the user doesn't exist in the database the middleware will attempt to sync it from the connected identity provider.
func TestingSetIsAdmin ¶
TestingSetIsAdmin allows the isAdmin to be set in the context for testing purposes.
func TestingSetUser ¶
TestingSetUserID allows the user ID to be set in the context for testing purposes.
func TestingSetUserID ¶
TestingSetUserID allows the user ID to be set in the context for testing purposes.
func UserFromContext ¶
UserIDFromContext returns the current user's ID. It requires that auth.Middleware has run.
func UserIDFromContext ¶
UserIDFromContext returns the current user's ID. It requires that auth.Middleware has run.
Types ¶
type Authenticator ¶
Authenticators can extract Claims representing a user's authentication from an incoming request.
type Claims ¶
Claims stores the relevant claims from a user's provided auth token. The identity token contains more claims, but we only parse the ones that we need.
type IdentitySyncer ¶
IdentitySyncer syncs the users with the external identity provider, like Okta or Google Workspaces.
type LambdaAuthenticator ¶
type LambdaAuthenticator struct{}
LambdaAuthenticator is an authenticator used in production. It reads the Claims from the API Gateway request context.
func (*LambdaAuthenticator) Authenticate ¶
func (a *LambdaAuthenticator) Authenticate(r *http.Request) (*Claims, error)
type MockAuthenticator ¶
type MockAuthenticator struct {
// contains filtered or unexported fields
}
MockAuthenticator is a mock of Authenticator interface.
func NewMockAuthenticator ¶
func NewMockAuthenticator(ctrl *gomock.Controller) *MockAuthenticator
NewMockAuthenticator creates a new mock instance.
func (*MockAuthenticator) Authenticate ¶
func (m *MockAuthenticator) Authenticate(arg0 *http.Request) (*Claims, error)
Authenticate mocks base method.
func (*MockAuthenticator) EXPECT ¶
func (m *MockAuthenticator) EXPECT() *MockAuthenticatorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockAuthenticatorMockRecorder ¶
type MockAuthenticatorMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthenticatorMockRecorder is the mock recorder for MockAuthenticator.
func (*MockAuthenticatorMockRecorder) Authenticate ¶
func (mr *MockAuthenticatorMockRecorder) Authenticate(arg0 interface{}) *gomock.Call
Authenticate indicates an expected call of Authenticate.
type MockIdentitySyncer ¶
type MockIdentitySyncer struct {
// contains filtered or unexported fields
}
MockIdentitySyncer is a mock of IdentitySyncer interface.
func NewMockIdentitySyncer ¶
func NewMockIdentitySyncer(ctrl *gomock.Controller) *MockIdentitySyncer
NewMockIdentitySyncer creates a new mock instance.
func (*MockIdentitySyncer) EXPECT ¶
func (m *MockIdentitySyncer) EXPECT() *MockIdentitySyncerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockIdentitySyncerMockRecorder ¶
type MockIdentitySyncerMockRecorder struct {
// contains filtered or unexported fields
}
MockIdentitySyncerMockRecorder is the mock recorder for MockIdentitySyncer.
func (*MockIdentitySyncerMockRecorder) Sync ¶
func (mr *MockIdentitySyncerMockRecorder) Sync(arg0 interface{}) *gomock.Call
Sync indicates an expected call of Sync.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package localauth contains authentication logic for use in local development.
|
Package localauth contains authentication logic for use in local development. |
Package nolocalauth contains authentication logic for use in local development when no auth is desired.
|
Package nolocalauth contains authentication logic for use in local development when no auth is desired. |