authentication

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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

type MockAuthentication struct {
	mock.Mock
}

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 (*MockAuthentication) Logout

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

type MockAuthentication_Authenticate_Call struct {
	*mock.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 (*MockAuthentication_Authenticate_Call) Run

func (*MockAuthentication_Authenticate_Call) RunAndReturn

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

type MockAuthentication_Logout_Call struct {
	*mock.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 (*MockAuthentication_Logout_Call) Run

func (*MockAuthentication_Logout_Call) RunAndReturn

type MockAuthentication_SetLogger_Call

type MockAuthentication_SetLogger_Call struct {
	*mock.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 (*MockAuthentication_SetLogger_Call) Run

func (*MockAuthentication_SetLogger_Call) RunAndReturn

type MockAuthenticator

type MockAuthenticator struct {
	mock.Mock
}

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 (*MockAuthenticator) Login

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

type MockAuthenticator_Login_Call struct {
	*mock.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 (*MockAuthenticator_Login_Call) Run

func (*MockAuthenticator_Login_Call) RunAndReturn

type MockAuthenticator_Logout_Call

type MockAuthenticator_Logout_Call struct {
	*mock.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 (*MockAuthenticator_Logout_Call) Run

func (*MockAuthenticator_Logout_Call) RunAndReturn

type MockAuthenticator_SetLogger_Call

type MockAuthenticator_SetLogger_Call struct {
	*mock.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 (*MockAuthenticator_SetLogger_Call) Run

func (*MockAuthenticator_SetLogger_Call) RunAndReturn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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