Documentation
¶
Index ¶
- func NewAuthentication(logger logger.Logger, clientFactory oidc.FactoryClient, ...) *authentication
- func NewAuthenticator(logger logger.Logger, authentication Authentication) *authenticator
- type AuthOptions
- type AuthResult
- type AuthenticateInput
- type AuthenticateLogoutInput
- type Authentication
- type Authenticator
- type LoginInput
- type LogoutInput
- type MockAuthentication
- func (_m *MockAuthentication) Authenticate(ctx context.Context, in AuthenticateInput) (*AuthResult, error)
- func (_m *MockAuthentication) EXPECT() *MockAuthentication_Expecter
- func (_m *MockAuthentication) Logout(ctx context.Context, in AuthenticateLogoutInput) error
- func (_m *MockAuthentication) SetLogger(_a0 logger.Logger)
- type MockAuthentication_Authenticate_Call
- func (_c *MockAuthentication_Authenticate_Call) Return(_a0 *AuthResult, _a1 error) *MockAuthentication_Authenticate_Call
- func (_c *MockAuthentication_Authenticate_Call) Run(run func(ctx context.Context, in AuthenticateInput)) *MockAuthentication_Authenticate_Call
- func (_c *MockAuthentication_Authenticate_Call) RunAndReturn(run func(context.Context, AuthenticateInput) (*AuthResult, error)) *MockAuthentication_Authenticate_Call
- type MockAuthentication_Expecter
- func (_e *MockAuthentication_Expecter) Authenticate(ctx interface{}, in interface{}) *MockAuthentication_Authenticate_Call
- func (_e *MockAuthentication_Expecter) Logout(ctx interface{}, in interface{}) *MockAuthentication_Logout_Call
- func (_e *MockAuthentication_Expecter) SetLogger(_a0 interface{}) *MockAuthentication_SetLogger_Call
- type MockAuthentication_Logout_Call
- func (_c *MockAuthentication_Logout_Call) Return(_a0 error) *MockAuthentication_Logout_Call
- func (_c *MockAuthentication_Logout_Call) Run(run func(ctx context.Context, in AuthenticateLogoutInput)) *MockAuthentication_Logout_Call
- func (_c *MockAuthentication_Logout_Call) RunAndReturn(run func(context.Context, AuthenticateLogoutInput) error) *MockAuthentication_Logout_Call
- type MockAuthentication_SetLogger_Call
- func (_c *MockAuthentication_SetLogger_Call) Return() *MockAuthentication_SetLogger_Call
- func (_c *MockAuthentication_SetLogger_Call) Run(run func(_a0 logger.Logger)) *MockAuthentication_SetLogger_Call
- func (_c *MockAuthentication_SetLogger_Call) RunAndReturn(run func(logger.Logger)) *MockAuthentication_SetLogger_Call
- type MockAuthenticator
- type MockAuthenticator_Expecter
- func (_e *MockAuthenticator_Expecter) Login(ctx interface{}, in interface{}) *MockAuthenticator_Login_Call
- func (_e *MockAuthenticator_Expecter) Logout(ctx interface{}, in interface{}) *MockAuthenticator_Logout_Call
- func (_e *MockAuthenticator_Expecter) SetLogger(_a0 interface{}) *MockAuthenticator_SetLogger_Call
- type MockAuthenticator_Login_Call
- func (_c *MockAuthenticator_Login_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockAuthenticator_Login_Call
- func (_c *MockAuthenticator_Login_Call) Run(run func(ctx context.Context, in LoginInput)) *MockAuthenticator_Login_Call
- func (_c *MockAuthenticator_Login_Call) RunAndReturn(run func(context.Context, LoginInput) (*oidc.TokenSet, error)) *MockAuthenticator_Login_Call
- type MockAuthenticator_Logout_Call
- func (_c *MockAuthenticator_Logout_Call) Return(_a0 error) *MockAuthenticator_Logout_Call
- func (_c *MockAuthenticator_Logout_Call) Run(run func(ctx context.Context, in LogoutInput)) *MockAuthenticator_Logout_Call
- func (_c *MockAuthenticator_Logout_Call) RunAndReturn(run func(context.Context, LogoutInput) error) *MockAuthenticator_Logout_Call
- type MockAuthenticator_SetLogger_Call
- func (_c *MockAuthenticator_SetLogger_Call) Return() *MockAuthenticator_SetLogger_Call
- func (_c *MockAuthenticator_SetLogger_Call) Run(run func(_a0 logger.Logger)) *MockAuthenticator_SetLogger_Call
- func (_c *MockAuthenticator_SetLogger_Call) RunAndReturn(run func(logger.Logger)) *MockAuthenticator_SetLogger_Call
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthentication ¶
func NewAuthentication(logger logger.Logger, clientFactory oidc.FactoryClient, authCodeBrowser *authcode.Browser, authCodeKeyboard *authcode.Keyboard) *authentication
NewAuthentication creates a new authentication
func NewAuthenticator ¶
func NewAuthenticator(logger logger.Logger, authentication Authentication) *authenticator
NewAuthenticator creates a new Authenticator
Types ¶
type AuthOptions ¶
type AuthOptions struct { AuthCodeBrowser *authcode.BrowserLoginInput AuthCodeKeyboard *authcode.KeyboardLoginInput }
AuthOptions is authentication options used by Authenticate
type AuthResult ¶
type AuthResult struct { // UsingCachedToken is true if authentication is using a cached token UsingCachedToken bool // TokenSet is the TokenSet used for authentication TokenSet oidc.TokenSet }
AuthResult is the result of an authentication
type AuthenticateInput ¶
type AuthenticateInput struct { // Provider represents an OIDC provider configuration Provider oidc.Provider // CachedTokenSet is a TokenSet with cached credentials CachedTokenSet *oidc.TokenSet // AuthOptions are the options used for authentication AuthOptions AuthOptions }
AuthenticateInput is the input given to Authenticate
type AuthenticateLogoutInput ¶
type AuthenticateLogoutInput struct { // Provider represents an OIDC provider configuration Provider oidc.Provider // CachedTokenSet is a TokenSet with cached credentials CachedTokenSet *oidc.TokenSet }
AuthenticateLogoutInput is the input given to Logout
type Authentication ¶
type Authentication interface { // Authenticate performs the OIDC authentication using the configuration given by AuthenticateInput Authenticate(ctx context.Context, in AuthenticateInput) (*AuthResult, error) // Logout logs out of the OIDC provider Logout(ctx context.Context, in AuthenticateLogoutInput) error // SetLogger sets the logger used for authentication SetLogger(logger.Logger) }
type Authenticator ¶
type Authenticator interface { // Login performs OIDC login in three steps: // // 1. fetching a cached token // 2. authenticating using the cached token or if not present performing OIDC authentication using the grant type provided // 3. caching the token obtained from the auth flow Login(ctx context.Context, in LoginInput) (*oidc.TokenSet, error) // Logout performs OIDC logout by: // // 1. fetching a cached token // 2. using the logout url to log out of the OIDC provider // 3. removing the cached token Logout(ctx context.Context, in LogoutInput) error // SetLogger sets the logger used for authentication SetLogger(logger.Logger) }
Authenticator represents an Authenticator
type LoginInput ¶
type LoginInput struct { // Provider represents an OIDC provider configuration Provider oidc.Provider // TokenCache is the interface used for caching tokens TokenCache tokencache.Cache // AuthOptions are the options used for authentication AuthOptions AuthOptions }
LoginInput is the input given to Login
type LogoutInput ¶
type LogoutInput struct { // Provider represents an OIDC provider configuration Provider oidc.Provider // TokenCache is the interface used for caching tokens TokenCache tokencache.Cache }
LogoutInput is the input given to Logout
type MockAuthentication ¶
MockAuthentication is an autogenerated mock type for the Authentication type
func NewMockAuthentication ¶
func NewMockAuthentication(t interface { mock.TestingT Cleanup(func()) }) *MockAuthentication
NewMockAuthentication creates a new instance of MockAuthentication. 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 (*MockAuthentication) Authenticate ¶
func (_m *MockAuthentication) Authenticate(ctx context.Context, in AuthenticateInput) (*AuthResult, error)
Authenticate provides a mock function with given fields: ctx, in
func (*MockAuthentication) EXPECT ¶
func (_m *MockAuthentication) EXPECT() *MockAuthentication_Expecter
func (*MockAuthentication) Logout ¶
func (_m *MockAuthentication) Logout(ctx context.Context, in AuthenticateLogoutInput) error
Logout provides a mock function with given fields: ctx, in
func (*MockAuthentication) SetLogger ¶
func (_m *MockAuthentication) SetLogger(_a0 logger.Logger)
SetLogger provides a mock function with given fields: _a0
type MockAuthentication_Authenticate_Call ¶
MockAuthentication_Authenticate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Authenticate'
func (*MockAuthentication_Authenticate_Call) Return ¶
func (_c *MockAuthentication_Authenticate_Call) Return(_a0 *AuthResult, _a1 error) *MockAuthentication_Authenticate_Call
func (*MockAuthentication_Authenticate_Call) Run ¶
func (_c *MockAuthentication_Authenticate_Call) Run(run func(ctx context.Context, in AuthenticateInput)) *MockAuthentication_Authenticate_Call
func (*MockAuthentication_Authenticate_Call) RunAndReturn ¶
func (_c *MockAuthentication_Authenticate_Call) RunAndReturn(run func(context.Context, AuthenticateInput) (*AuthResult, error)) *MockAuthentication_Authenticate_Call
type MockAuthentication_Expecter ¶
type MockAuthentication_Expecter struct {
// contains filtered or unexported fields
}
func (*MockAuthentication_Expecter) Authenticate ¶
func (_e *MockAuthentication_Expecter) Authenticate(ctx interface{}, in interface{}) *MockAuthentication_Authenticate_Call
Authenticate is a helper method to define mock.On call
- ctx context.Context
- in AuthenticateInput
func (*MockAuthentication_Expecter) Logout ¶
func (_e *MockAuthentication_Expecter) Logout(ctx interface{}, in interface{}) *MockAuthentication_Logout_Call
Logout is a helper method to define mock.On call
- ctx context.Context
- in AuthenticateLogoutInput
func (*MockAuthentication_Expecter) SetLogger ¶
func (_e *MockAuthentication_Expecter) SetLogger(_a0 interface{}) *MockAuthentication_SetLogger_Call
SetLogger is a helper method to define mock.On call
- _a0 logger.Logger
type MockAuthentication_Logout_Call ¶
MockAuthentication_Logout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logout'
func (*MockAuthentication_Logout_Call) Return ¶
func (_c *MockAuthentication_Logout_Call) Return(_a0 error) *MockAuthentication_Logout_Call
func (*MockAuthentication_Logout_Call) Run ¶
func (_c *MockAuthentication_Logout_Call) Run(run func(ctx context.Context, in AuthenticateLogoutInput)) *MockAuthentication_Logout_Call
func (*MockAuthentication_Logout_Call) RunAndReturn ¶
func (_c *MockAuthentication_Logout_Call) RunAndReturn(run func(context.Context, AuthenticateLogoutInput) error) *MockAuthentication_Logout_Call
type MockAuthentication_SetLogger_Call ¶
MockAuthentication_SetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLogger'
func (*MockAuthentication_SetLogger_Call) Return ¶
func (_c *MockAuthentication_SetLogger_Call) Return() *MockAuthentication_SetLogger_Call
func (*MockAuthentication_SetLogger_Call) Run ¶
func (_c *MockAuthentication_SetLogger_Call) Run(run func(_a0 logger.Logger)) *MockAuthentication_SetLogger_Call
func (*MockAuthentication_SetLogger_Call) RunAndReturn ¶
func (_c *MockAuthentication_SetLogger_Call) RunAndReturn(run func(logger.Logger)) *MockAuthentication_SetLogger_Call
type MockAuthenticator ¶
MockAuthenticator is an autogenerated mock type for the Authenticator type
func NewMockAuthenticator ¶
func NewMockAuthenticator(t interface { mock.TestingT Cleanup(func()) }) *MockAuthenticator
NewMockAuthenticator creates a new instance of MockAuthenticator. 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 (*MockAuthenticator) EXPECT ¶
func (_m *MockAuthenticator) EXPECT() *MockAuthenticator_Expecter
func (*MockAuthenticator) Login ¶
func (_m *MockAuthenticator) Login(ctx context.Context, in LoginInput) (*oidc.TokenSet, error)
Login provides a mock function with given fields: ctx, in
func (*MockAuthenticator) Logout ¶
func (_m *MockAuthenticator) Logout(ctx context.Context, in LogoutInput) error
Logout provides a mock function with given fields: ctx, in
func (*MockAuthenticator) SetLogger ¶
func (_m *MockAuthenticator) SetLogger(_a0 logger.Logger)
SetLogger provides a mock function with given fields: _a0
type MockAuthenticator_Expecter ¶
type MockAuthenticator_Expecter struct {
// contains filtered or unexported fields
}
func (*MockAuthenticator_Expecter) Login ¶
func (_e *MockAuthenticator_Expecter) Login(ctx interface{}, in interface{}) *MockAuthenticator_Login_Call
Login is a helper method to define mock.On call
- ctx context.Context
- in LoginInput
func (*MockAuthenticator_Expecter) Logout ¶
func (_e *MockAuthenticator_Expecter) Logout(ctx interface{}, in interface{}) *MockAuthenticator_Logout_Call
Logout is a helper method to define mock.On call
- ctx context.Context
- in LogoutInput
func (*MockAuthenticator_Expecter) SetLogger ¶
func (_e *MockAuthenticator_Expecter) SetLogger(_a0 interface{}) *MockAuthenticator_SetLogger_Call
SetLogger is a helper method to define mock.On call
- _a0 logger.Logger
type MockAuthenticator_Login_Call ¶
MockAuthenticator_Login_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Login'
func (*MockAuthenticator_Login_Call) Return ¶
func (_c *MockAuthenticator_Login_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockAuthenticator_Login_Call
func (*MockAuthenticator_Login_Call) Run ¶
func (_c *MockAuthenticator_Login_Call) Run(run func(ctx context.Context, in LoginInput)) *MockAuthenticator_Login_Call
func (*MockAuthenticator_Login_Call) RunAndReturn ¶
func (_c *MockAuthenticator_Login_Call) RunAndReturn(run func(context.Context, LoginInput) (*oidc.TokenSet, error)) *MockAuthenticator_Login_Call
type MockAuthenticator_Logout_Call ¶
MockAuthenticator_Logout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logout'
func (*MockAuthenticator_Logout_Call) Return ¶
func (_c *MockAuthenticator_Logout_Call) Return(_a0 error) *MockAuthenticator_Logout_Call
func (*MockAuthenticator_Logout_Call) Run ¶
func (_c *MockAuthenticator_Logout_Call) Run(run func(ctx context.Context, in LogoutInput)) *MockAuthenticator_Logout_Call
func (*MockAuthenticator_Logout_Call) RunAndReturn ¶
func (_c *MockAuthenticator_Logout_Call) RunAndReturn(run func(context.Context, LogoutInput) error) *MockAuthenticator_Logout_Call
type MockAuthenticator_SetLogger_Call ¶
MockAuthenticator_SetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLogger'
func (*MockAuthenticator_SetLogger_Call) Return ¶
func (_c *MockAuthenticator_SetLogger_Call) Return() *MockAuthenticator_SetLogger_Call
func (*MockAuthenticator_SetLogger_Call) Run ¶
func (_c *MockAuthenticator_SetLogger_Call) Run(run func(_a0 logger.Logger)) *MockAuthenticator_SetLogger_Call
func (*MockAuthenticator_SetLogger_Call) RunAndReturn ¶
func (_c *MockAuthenticator_SetLogger_Call) RunAndReturn(run func(logger.Logger)) *MockAuthenticator_SetLogger_Call