Documentation ¶
Overview ¶
Package auth is a generated GoMock package.
Index ¶
- Constants
- Variables
- func LoginHandler(ctx *gin.Context, s *Service)
- func RefreshHandler(ctx *gin.Context, s *Service)
- func RevokeAllHandler(ctx *gin.Context, s *Service)
- func RevokeHandler(ctx *gin.Context, s *Service)
- func SignupHandler(ctx *gin.Context, s *Service)
- type CredentialsBody
- type DBAPI
- type Env
- type MockDBAPI
- func (m *MockDBAPI) BeginTx(arg0 context.Context) (*sql.Tx, error)
- func (m *MockDBAPI) Commit(arg0 *sql.Tx) error
- func (m *MockDBAPI) CreateProfile(arg0 context.Context, arg1 *sql.Tx, arg2 string, arg3 *dbmodels.User, ...) (*dbmodels.Profile, error)
- func (m *MockDBAPI) CreateUser(arg0 context.Context, arg1 *sql.Tx, arg2, arg3 string, arg4 []byte) (*dbmodels.User, error)
- func (m *MockDBAPI) DeleteAllTokens(arg0 context.Context, arg1 string) (int64, error)
- func (m *MockDBAPI) DeleteToken(arg0 context.Context, arg1 string) (int64, error)
- func (m *MockDBAPI) DeleteUser(arg0 context.Context, arg1 string) error
- func (m *MockDBAPI) EXPECT() *MockDBAPIMockRecorder
- func (m *MockDBAPI) FindUserByEmail(arg0 context.Context, arg1 string) (*dbmodels.User, error)
- func (m *MockDBAPI) GetInstance(arg0 context.Context, arg1 string) (*dbmodels.Instance, error)
- func (m *MockDBAPI) GetProfile(arg0 context.Context, arg1, arg2 string) (*dbmodels.Profile, error)
- func (m *MockDBAPI) GetUserAndProfile(arg0 context.Context, arg1, arg2 string) (*dbmodels.User, *dbmodels.Profile, error)
- func (m *MockDBAPI) HasToken(arg0 context.Context, arg1, arg2, arg3 string) (bool, error)
- func (m *MockDBAPI) Rollback(arg0 *sql.Tx) error
- func (m *MockDBAPI) SaveToken(arg0 context.Context, arg1 *dbmodels.Profile, arg2 string, arg3 time.Time) error
- type MockDBAPIMockRecorder
- func (mr *MockDBAPIMockRecorder) BeginTx(arg0 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) Commit(arg0 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) CreateProfile(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) CreateUser(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) DeleteAllTokens(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) DeleteToken(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) DeleteUser(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) FindUserByEmail(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) GetInstance(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) GetProfile(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) GetUserAndProfile(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) HasToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) Rollback(arg0 interface{}) *gomock.Call
- func (mr *MockDBAPIMockRecorder) SaveToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- type RefreshTokenBody
- type RevokeAllBody
- type RevokeBody
- type Service
- func (s *Service) Login(ctx *gin.Context) (accessToken, refreshToken, role string, err error)
- func (s *Service) Refresh(ctx *gin.Context) (string, error)
- func (s *Service) Revoke(ctx *gin.Context) error
- func (s *Service) RevokeAll(ctx *gin.Context) error
- func (s *Service) Run(ctx context.Context) (err error)
- func (s *Service) Signup(ctx *gin.Context) (userID string, err error)
- type SignupBody
Constants ¶
const ServiceName = "auth"
Variables ¶
var ( ErrMissingCredentials = errors.New("missing credentials, email and password have to be provided") ErrInvalidCredentials = errors.New("invalid credentials, email/password combination wrong") ErrMissingRefreshToken = errors.New("missing refresh token in JSON body") ErrTokenInvalid = errors.New("token invalid") ErrTokenNotFound = errors.New("token not found") ErrUserDoesNotExist = errors.New("user does not exist") ErrInstanceDoesNotExist = errors.New("instance does not exist") ErrProfileDoesNotExist = errors.New("profile does not exist") )
var ( ErrMissingRevokeEmail = errors.New("missing user id") ErrTokenRevoked = errors.New("refresh token was revoked and is no longer valid") )
var ( GitCommit string Version string )
Build Variables picked up by govvv go get github.com/ahmetb/govvv
var ( ErrInvalidEmail = errors.New("invalid user email provided") ErrInvalidPassword = errors.New("invalid user password provided") )
Functions ¶
func LoginHandler ¶
LoginHandler logs a user in and returs a fresh set of tokens.
func RefreshHandler ¶
RefreshHandler refreshes a user's access token.
func RevokeAllHandler ¶
RevokeAllHandler revokes a user's tokens for a specific instance or falls back to the authorization tokens instance.
func RevokeHandler ¶
RevokeHandler revokes a user's tokens for a specific instance or falls back to the authorization tokens instance.
func SignupHandler ¶
SignupHandler creates a new user.
Types ¶
type CredentialsBody ¶
type CredentialsBody struct { InstanceURL string `json:"instance"` Email string `json:"email"` Password string `json:"password"` }
CredentialsBody describes the login credentials
type DBAPI ¶
type DBAPI interface { BeginTx(ctx context.Context) (*sql.Tx, error) Commit(tx *sql.Tx) error Rollback(tx *sql.Tx) error FindUserByEmail(ctx context.Context, email string) (*m.User, error) GetInstance(ctx context.Context, instanceURL string) (instance *m.Instance, err error) GetProfile(ctx context.Context, userID, instanceID string) (profile *m.Profile, err error) GetUserAndProfile(ctx context.Context, userID string, instanceURL string) (user *m.User, profile *m.Profile, err error) CreateProfile(ctx context.Context, tx *sql.Tx, instanceID string, user *m.User, role string) (profile *m.Profile, err error) CreateUser(ctx context.Context, tx *sql.Tx, name, email string, passwordHash []byte) (user *m.User, err error) DeleteUser(ctx context.Context, userID string) error SaveToken(ctx context.Context, profile *m.Profile, token string, expiresAt time.Time) error HasToken(ctx context.Context, userID, profileID, token string) (bool, error) DeleteToken(ctx context.Context, profileID string) (int64, error) DeleteAllTokens(ctx context.Context, userID string) (int64, error) }
type Env ¶
type Env struct { service.DBEnv tokens.TokenEnv service.HTTPEnv AllowOrigins []string // contains filtered or unexported fields }
Env is a hierarchical environment configuration for the authentication service and it's API handlers.
type MockDBAPI ¶
type MockDBAPI struct {
// contains filtered or unexported fields
}
MockDBAPI is a mock of DBAPI interface.
func NewMockDBAPI ¶
func NewMockDBAPI(ctrl *gomock.Controller) *MockDBAPI
NewMockDBAPI creates a new mock instance.
func (*MockDBAPI) CreateProfile ¶
func (m *MockDBAPI) CreateProfile(arg0 context.Context, arg1 *sql.Tx, arg2 string, arg3 *dbmodels.User, arg4 string) (*dbmodels.Profile, error)
CreateProfile mocks base method.
func (*MockDBAPI) CreateUser ¶
func (m *MockDBAPI) CreateUser(arg0 context.Context, arg1 *sql.Tx, arg2, arg3 string, arg4 []byte) (*dbmodels.User, error)
CreateUser mocks base method.
func (*MockDBAPI) DeleteAllTokens ¶
DeleteAllTokens mocks base method.
func (*MockDBAPI) DeleteToken ¶
DeleteToken mocks base method.
func (*MockDBAPI) DeleteUser ¶
DeleteUser mocks base method.
func (*MockDBAPI) EXPECT ¶
func (m *MockDBAPI) EXPECT() *MockDBAPIMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDBAPI) FindUserByEmail ¶
FindUserByEmail mocks base method.
func (*MockDBAPI) GetInstance ¶
GetInstance mocks base method.
func (*MockDBAPI) GetProfile ¶
GetProfile mocks base method.
func (*MockDBAPI) GetUserAndProfile ¶
func (m *MockDBAPI) GetUserAndProfile(arg0 context.Context, arg1, arg2 string) (*dbmodels.User, *dbmodels.Profile, error)
GetUserAndProfile mocks base method.
type MockDBAPIMockRecorder ¶
type MockDBAPIMockRecorder struct {
// contains filtered or unexported fields
}
MockDBAPIMockRecorder is the mock recorder for MockDBAPI.
func (*MockDBAPIMockRecorder) BeginTx ¶
func (mr *MockDBAPIMockRecorder) BeginTx(arg0 interface{}) *gomock.Call
BeginTx indicates an expected call of BeginTx.
func (*MockDBAPIMockRecorder) Commit ¶
func (mr *MockDBAPIMockRecorder) Commit(arg0 interface{}) *gomock.Call
Commit indicates an expected call of Commit.
func (*MockDBAPIMockRecorder) CreateProfile ¶
func (mr *MockDBAPIMockRecorder) CreateProfile(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
CreateProfile indicates an expected call of CreateProfile.
func (*MockDBAPIMockRecorder) CreateUser ¶
func (mr *MockDBAPIMockRecorder) CreateUser(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call
CreateUser indicates an expected call of CreateUser.
func (*MockDBAPIMockRecorder) DeleteAllTokens ¶
func (mr *MockDBAPIMockRecorder) DeleteAllTokens(arg0, arg1 interface{}) *gomock.Call
DeleteAllTokens indicates an expected call of DeleteAllTokens.
func (*MockDBAPIMockRecorder) DeleteToken ¶
func (mr *MockDBAPIMockRecorder) DeleteToken(arg0, arg1 interface{}) *gomock.Call
DeleteToken indicates an expected call of DeleteToken.
func (*MockDBAPIMockRecorder) DeleteUser ¶
func (mr *MockDBAPIMockRecorder) DeleteUser(arg0, arg1 interface{}) *gomock.Call
DeleteUser indicates an expected call of DeleteUser.
func (*MockDBAPIMockRecorder) FindUserByEmail ¶
func (mr *MockDBAPIMockRecorder) FindUserByEmail(arg0, arg1 interface{}) *gomock.Call
FindUserByEmail indicates an expected call of FindUserByEmail.
func (*MockDBAPIMockRecorder) GetInstance ¶
func (mr *MockDBAPIMockRecorder) GetInstance(arg0, arg1 interface{}) *gomock.Call
GetInstance indicates an expected call of GetInstance.
func (*MockDBAPIMockRecorder) GetProfile ¶
func (mr *MockDBAPIMockRecorder) GetProfile(arg0, arg1, arg2 interface{}) *gomock.Call
GetProfile indicates an expected call of GetProfile.
func (*MockDBAPIMockRecorder) GetUserAndProfile ¶
func (mr *MockDBAPIMockRecorder) GetUserAndProfile(arg0, arg1, arg2 interface{}) *gomock.Call
GetUserAndProfile indicates an expected call of GetUserAndProfile.
func (*MockDBAPIMockRecorder) HasToken ¶
func (mr *MockDBAPIMockRecorder) HasToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
HasToken indicates an expected call of HasToken.
func (*MockDBAPIMockRecorder) Rollback ¶
func (mr *MockDBAPIMockRecorder) Rollback(arg0 interface{}) *gomock.Call
Rollback indicates an expected call of Rollback.
func (*MockDBAPIMockRecorder) SaveToken ¶
func (mr *MockDBAPIMockRecorder) SaveToken(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
SaveToken indicates an expected call of SaveToken.
type RefreshTokenBody ¶
type RefreshTokenBody struct {
RefreshToken string `json:"refreshToken"`
}
RefreshTokenBody describes the refresh body
type RevokeAllBody ¶
type RevokeAllBody struct {
Email string `json:"email"`
}
RevokeAllBody describes the user to revoke all tokens for
type RevokeBody ¶
RevokeBody describes the user/instance to revoke tokens for
type Service ¶
type Service struct { Env service.DBConn DBAPI DBAPI service.HTTPServer TokenAPI *tokens.TokenController AllowOrigins map[string]struct{} }
Service offers the APIs of the authentication service. This struct holds hierarchically structured state that is shared between requests.