Documentation
¶
Index ¶
- Constants
- Variables
- func MockDevice() *pb.Device
- func NewSessionStore(db database.Database) *sessionStore
- type Authenticator
- type LegacySessionInfo
- type MockSessionStore
- func (_mock *MockSessionStore) All() []*pb.Session
- func (_m *MockSessionStore) EXPECT() *MockSessionStore_Expecter
- func (_mock *MockSessionStore) Get(context1 context.Context, s string) (*pb.Session, error)
- func (_mock *MockSessionStore) RefreshDevice(device *pb.Device)
- func (_mock *MockSessionStore) Set(context1 context.Context, session *pb.Session) error
- type MockSessionStore_All_Call
- type MockSessionStore_Expecter
- func (_e *MockSessionStore_Expecter) All() *MockSessionStore_All_Call
- func (_e *MockSessionStore_Expecter) Get(context1 interface{}, s interface{}) *MockSessionStore_Get_Call
- func (_e *MockSessionStore_Expecter) RefreshDevice(device interface{}) *MockSessionStore_RefreshDevice_Call
- func (_e *MockSessionStore_Expecter) Set(context1 interface{}, session interface{}) *MockSessionStore_Set_Call
- type MockSessionStore_Get_Call
- func (_c *MockSessionStore_Get_Call) Return(session *pb.Session, err error) *MockSessionStore_Get_Call
- func (_c *MockSessionStore_Get_Call) Run(run func(context1 context.Context, s string)) *MockSessionStore_Get_Call
- func (_c *MockSessionStore_Get_Call) RunAndReturn(run func(context1 context.Context, s string) (*pb.Session, error)) *MockSessionStore_Get_Call
- type MockSessionStore_RefreshDevice_Call
- func (_c *MockSessionStore_RefreshDevice_Call) Return() *MockSessionStore_RefreshDevice_Call
- func (_c *MockSessionStore_RefreshDevice_Call) Run(run func(device *pb.Device)) *MockSessionStore_RefreshDevice_Call
- func (_c *MockSessionStore_RefreshDevice_Call) RunAndReturn(run func(device *pb.Device)) *MockSessionStore_RefreshDevice_Call
- type MockSessionStore_Set_Call
- func (_c *MockSessionStore_Set_Call) Return(err error) *MockSessionStore_Set_Call
- func (_c *MockSessionStore_Set_Call) Run(run func(context1 context.Context, session *pb.Session)) *MockSessionStore_Set_Call
- func (_c *MockSessionStore_Set_Call) RunAndReturn(run func(context1 context.Context, session *pb.Session) error) *MockSessionStore_Set_Call
- type ParseTokenError
- type SessionStore
- type UsernamePasswordAuthenticator
Constants ¶
const (
SessionDuration = time.Hour * 10
)
Variables ¶
var ErrInvalidAuth = errors.New("invalid username or password")
var ErrNoSession = errors.New("no active session")
var ErrTermsNotAccepted = errors.New("do's and don'ts not accepted, visit: https://naisdevice-approval.external.prod-gcp.nav.cloud.nais.io/ to read and accept")
Functions ¶
func MockDevice ¶
func NewSessionStore ¶
Types ¶
type Authenticator ¶
type Authenticator interface {
Login(ctx context.Context, token, serial, platform string) (*pb.Session, error)
}
func NewAuthenticator ¶
func NewAuthenticator(azureConfig *auth.Azure, db database.Database, store SessionStore, log logrus.FieldLogger) Authenticator
func NewGoogleAuthenticator ¶
func NewGoogleAuthenticator(googleConfig *auth.Google, db database.Database, store SessionStore) Authenticator
func NewMockAuthenticator ¶
func NewMockAuthenticator(store SessionStore) Authenticator
type LegacySessionInfo ¶
func LegacySessionFromProtobuf ¶
func LegacySessionFromProtobuf(s *pb.Session) *LegacySessionInfo
func (*LegacySessionInfo) ToProtobuf ¶
func (s *LegacySessionInfo) ToProtobuf() *pb.Session
type MockSessionStore ¶
MockSessionStore is an autogenerated mock type for the SessionStore type
func NewMockSessionStore ¶
func NewMockSessionStore(t interface {
mock.TestingT
Cleanup(func())
},
) *MockSessionStore
NewMockSessionStore creates a new instance of MockSessionStore. 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 (*MockSessionStore) All ¶
func (_mock *MockSessionStore) All() []*pb.Session
All provides a mock function for the type MockSessionStore
func (*MockSessionStore) EXPECT ¶
func (_m *MockSessionStore) EXPECT() *MockSessionStore_Expecter
func (*MockSessionStore) RefreshDevice ¶
func (_mock *MockSessionStore) RefreshDevice(device *pb.Device)
RefreshDevice provides a mock function for the type MockSessionStore
type MockSessionStore_All_Call ¶
MockSessionStore_All_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'All'
func (*MockSessionStore_All_Call) Return ¶
func (_c *MockSessionStore_All_Call) Return(sessions []*pb.Session) *MockSessionStore_All_Call
func (*MockSessionStore_All_Call) Run ¶
func (_c *MockSessionStore_All_Call) Run(run func()) *MockSessionStore_All_Call
func (*MockSessionStore_All_Call) RunAndReturn ¶
func (_c *MockSessionStore_All_Call) RunAndReturn(run func() []*pb.Session) *MockSessionStore_All_Call
type MockSessionStore_Expecter ¶
type MockSessionStore_Expecter struct {
// contains filtered or unexported fields
}
func (*MockSessionStore_Expecter) All ¶
func (_e *MockSessionStore_Expecter) All() *MockSessionStore_All_Call
All is a helper method to define mock.On call
func (*MockSessionStore_Expecter) Get ¶
func (_e *MockSessionStore_Expecter) Get(context1 interface{}, s interface{}) *MockSessionStore_Get_Call
Get is a helper method to define mock.On call
- context1 context.Context
- s string
func (*MockSessionStore_Expecter) RefreshDevice ¶
func (_e *MockSessionStore_Expecter) RefreshDevice(device interface{}) *MockSessionStore_RefreshDevice_Call
RefreshDevice is a helper method to define mock.On call
- device *pb.Device
func (*MockSessionStore_Expecter) Set ¶
func (_e *MockSessionStore_Expecter) Set(context1 interface{}, session interface{}) *MockSessionStore_Set_Call
Set is a helper method to define mock.On call
- context1 context.Context
- session *pb.Session
type MockSessionStore_Get_Call ¶
MockSessionStore_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
func (*MockSessionStore_Get_Call) Return ¶
func (_c *MockSessionStore_Get_Call) Return(session *pb.Session, err error) *MockSessionStore_Get_Call
func (*MockSessionStore_Get_Call) Run ¶
func (_c *MockSessionStore_Get_Call) Run(run func(context1 context.Context, s string)) *MockSessionStore_Get_Call
func (*MockSessionStore_Get_Call) RunAndReturn ¶
func (_c *MockSessionStore_Get_Call) RunAndReturn(run func(context1 context.Context, s string) (*pb.Session, error)) *MockSessionStore_Get_Call
type MockSessionStore_RefreshDevice_Call ¶
MockSessionStore_RefreshDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefreshDevice'
func (*MockSessionStore_RefreshDevice_Call) Return ¶
func (_c *MockSessionStore_RefreshDevice_Call) Return() *MockSessionStore_RefreshDevice_Call
func (*MockSessionStore_RefreshDevice_Call) Run ¶
func (_c *MockSessionStore_RefreshDevice_Call) Run(run func(device *pb.Device)) *MockSessionStore_RefreshDevice_Call
func (*MockSessionStore_RefreshDevice_Call) RunAndReturn ¶
func (_c *MockSessionStore_RefreshDevice_Call) RunAndReturn(run func(device *pb.Device)) *MockSessionStore_RefreshDevice_Call
type MockSessionStore_Set_Call ¶
MockSessionStore_Set_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Set'
func (*MockSessionStore_Set_Call) Return ¶
func (_c *MockSessionStore_Set_Call) Return(err error) *MockSessionStore_Set_Call
func (*MockSessionStore_Set_Call) Run ¶
func (_c *MockSessionStore_Set_Call) Run(run func(context1 context.Context, session *pb.Session)) *MockSessionStore_Set_Call
func (*MockSessionStore_Set_Call) RunAndReturn ¶
func (_c *MockSessionStore_Set_Call) RunAndReturn(run func(context1 context.Context, session *pb.Session) error) *MockSessionStore_Set_Call
type ParseTokenError ¶
type ParseTokenError struct {
// contains filtered or unexported fields
}
JWT token parsing errors. The token library does not have any standardised error types, so we need one here to accurately represent this type of error.
func (ParseTokenError) Error ¶
func (t ParseTokenError) Error() string
type SessionStore ¶
type UsernamePasswordAuthenticator ¶
type UsernamePasswordAuthenticator interface {
Authenticate(ctx context.Context, username, password string) error
}
func NewAPIKeyAuthenticator ¶
func NewAPIKeyAuthenticator(users map[string]string) UsernamePasswordAuthenticator
func NewGatewayAuthenticator ¶
func NewGatewayAuthenticator(db database.Database) UsernamePasswordAuthenticator
func NewMockAPIKeyAuthenticator ¶
func NewMockAPIKeyAuthenticator() UsernamePasswordAuthenticator