Documentation ¶
Index ¶
- Variables
- type AccessToken
- type AccessTokenGenerator
- type Auth
- type CheckAccessToken
- type CheckAccessTokenHandler
- type CreateInvitationHandler
- type CryptoStringGenerator
- type Invitation
- type InvitationRepository
- type InvitationToken
- type LastSeenUpdater
- type ListHandler
- type Login
- type LoginHandler
- type Logout
- type LogoutHandler
- type PasswordHash
- type PasswordHasher
- type ReadSession
- type ReadUser
- type Register
- type RegisterHandler
- type RegisterInitial
- type RegisterInitialHandler
- type Remove
- type RemoveHandler
- type Session
- type SetPassword
- type SetPasswordHandler
- type TransactableRepositories
- type TransactionHandler
- type TransactionProvider
- type User
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrUsernameTaken = errors.New("username taken")
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken string
type AccessTokenGenerator ¶
type AccessTokenGenerator interface { Generate(username string) (AccessToken, error) GetUsername(token AccessToken) (string, error) }
type Auth ¶
type Auth struct { RegisterInitial *RegisterInitialHandler Register *RegisterHandler Login *LoginHandler Logout *LogoutHandler CheckAccessToken *CheckAccessTokenHandler List *ListHandler CreateInvitation *CreateInvitationHandler Remove *RemoveHandler SetPassword *SetPasswordHandler }
type CheckAccessToken ¶
type CheckAccessToken struct {
Token AccessToken
}
type CheckAccessTokenHandler ¶
type CheckAccessTokenHandler struct {
// contains filtered or unexported fields
}
func NewCheckAccessTokenHandler ¶
func NewCheckAccessTokenHandler( transactionProvider TransactionProvider, accessTokenGenerator AccessTokenGenerator, lastSeenUpdater LastSeenUpdater, ) *CheckAccessTokenHandler
func (*CheckAccessTokenHandler) Execute ¶
func (h *CheckAccessTokenHandler) Execute(cmd CheckAccessToken) (*ReadUser, error)
type CreateInvitationHandler ¶
type CreateInvitationHandler struct {
// contains filtered or unexported fields
}
func NewCreateInvitationHandler ¶
func NewCreateInvitationHandler( cryptoStringGenerator CryptoStringGenerator, transactionProvider TransactionProvider, ) *CreateInvitationHandler
func (*CreateInvitationHandler) Execute ¶
func (h *CreateInvitationHandler) Execute() (InvitationToken, error)
type CryptoStringGenerator ¶
type Invitation ¶
type Invitation struct { Token InvitationToken `json:"invitation"` Created time.Time `json:"created"` }
type InvitationRepository ¶
type InvitationRepository interface { // Put inserts the invitation into the repository. The previous entry // with this token is overwriten. Put(invitation Invitation) error // Get returns an invitation with the provided token, if the invitation // doesn't exist ErrNotFound is returned. Get(token InvitationToken) (*Invitation, error) // Remove removes an invitation. If the invitation doesn't exist this // function returns nil. Remove(token InvitationToken) error }
type InvitationToken ¶
type InvitationToken string
type LastSeenUpdater ¶
type LastSeenUpdater interface {
Update(username string, token AccessToken, t time.Time)
}
type ListHandler ¶
type ListHandler struct {
// contains filtered or unexported fields
}
func NewListHandler ¶
func NewListHandler(transactionProvider TransactionProvider) *ListHandler
func (*ListHandler) Execute ¶
func (h *ListHandler) Execute() ([]ReadUser, error)
type LoginHandler ¶
type LoginHandler struct {
// contains filtered or unexported fields
}
func NewLoginHandler ¶
func NewLoginHandler( passwordHasher PasswordHasher, transactionProvider TransactionProvider, accessTokenGenerator AccessTokenGenerator, ) *LoginHandler
func (*LoginHandler) Execute ¶
func (h *LoginHandler) Execute(cmd Login) (AccessToken, error)
type Logout ¶
type Logout struct {
Token AccessToken
}
type LogoutHandler ¶
type LogoutHandler struct {
// contains filtered or unexported fields
}
func NewLogoutHandler ¶
func NewLogoutHandler( transactionProvider TransactionProvider, accessTokenGenerator AccessTokenGenerator, ) *LogoutHandler
func (*LogoutHandler) Execute ¶
func (h *LogoutHandler) Execute(cmd Logout) error
type PasswordHash ¶
type PasswordHash []byte
type PasswordHasher ¶
type PasswordHasher interface { Hash(password string) (PasswordHash, error) Compare(hashedPassword PasswordHash, password string) error }
type ReadSession ¶
type Register ¶
type Register struct { Username string Password string Token InvitationToken }
type RegisterHandler ¶
type RegisterHandler struct {
// contains filtered or unexported fields
}
func NewRegisterHandler ¶
func NewRegisterHandler( passwordHasher PasswordHasher, transactionProvider TransactionProvider, ) *RegisterHandler
func (*RegisterHandler) Execute ¶
func (h *RegisterHandler) Execute(cmd Register) error
type RegisterInitial ¶
type RegisterInitialHandler ¶
type RegisterInitialHandler struct {
// contains filtered or unexported fields
}
func NewRegisterInitialHandler ¶
func NewRegisterInitialHandler( passwordHasher PasswordHasher, transactionProvider TransactionProvider, ) *RegisterInitialHandler
func (*RegisterInitialHandler) Execute ¶
func (h *RegisterInitialHandler) Execute(cmd RegisterInitial) error
type RemoveHandler ¶
type RemoveHandler struct {
// contains filtered or unexported fields
}
func NewRemoveHandler ¶
func NewRemoveHandler(transactionProvider TransactionProvider) *RemoveHandler
func (*RemoveHandler) Execute ¶
func (h *RemoveHandler) Execute(cmd Remove) error
type Session ¶
type Session struct { Token AccessToken `json:"token"` LastSeen time.Time `json:"lastSeen"` }
type SetPassword ¶
type SetPasswordHandler ¶
type SetPasswordHandler struct {
// contains filtered or unexported fields
}
func NewSetPasswordHandler ¶
func NewSetPasswordHandler( passwordHasher PasswordHasher, transactionProvider TransactionProvider, ) *SetPasswordHandler
func (*SetPasswordHandler) Execute ¶
func (h *SetPasswordHandler) Execute(cmd SetPassword) error
type TransactableRepositories ¶
type TransactableRepositories struct { Invitations InvitationRepository Users UserRepository }
type TransactionHandler ¶
type TransactionHandler func(repositories *TransactableRepositories) error
type TransactionProvider ¶
type TransactionProvider interface { Read(handler TransactionHandler) error Write(handler TransactionHandler) error }
type UserRepository ¶
type UserRepository interface { // Put inserts the user into the repository. The previous entry with // this username is overwriten. Put(user User) error // Get returns the user with the provided username. If the user doesn't // exist ErrNotFound is returned. Get(username string) (*User, error) // Remove should remove a user. Remove(username string) error // List should return a list of all users. List() ([]User, error) // Count returns the number of users. Count() (int, error) }
Click to show internal directories.
Click to hide internal directories.