Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPassword(hashedPassword, password string) error
- func GeneratePasswordHash(password string) (string, error)
- func GetPrivateKey() (string, error)
- func IsDefaultUser(username, password string) bool
- func RegisterAuthenticatorFactory(name string, factory AuthenticatorFactory)
- func RegisterTokenFactory(name string, factory TokenFactory)
- func SetAuthConfigMapName(name string)
- type AuthenticatorContext
- type AuthenticatorFactory
- type DefaultStore
- type Request
- type Response
- func InternalServerErrorResponse(username string, message string) *Response
- func SuccessResetPasswordResponse(username string, token string) *Response
- func SuccessResponse(username string, message string) *Response
- func SuccessTokenResponse(username string, token string) *Response
- func UnauthenticatedResponse() *Response
- type Store
- type Token
- type TokenContext
- type TokenFactory
- type TokenGenerator
- type User
Constants ¶
View Source
const ( JWTTokenKey = "kstone-api-jwt" SignMethodRS256 = "RS256" DataSuccess = "success" UserUnknown = "unknown" DefaultKeyPath = "/app/certs/private.key" DefaultKstoneNamespace = "kstone" DefaultUsername = "admin" DefaultPassword = "adm1n@kstone.io" )
Variables ¶
View Source
var ( TokenProviders = make(map[string]TokenFactory) AuthenticatorProviders = make(map[string]AuthenticatorFactory) )
View Source
var DefaultConfigMapName = "kstone-api-user"
Functions ¶
func CheckPassword ¶
func GeneratePasswordHash ¶
func GetPrivateKey ¶
func IsDefaultUser ¶
func RegisterAuthenticatorFactory ¶
func RegisterAuthenticatorFactory(name string, factory AuthenticatorFactory)
RegisterAuthenticatorFactory registers the specified authenticator provider
func RegisterTokenFactory ¶
func RegisterTokenFactory(name string, factory TokenFactory)
RegisterTokenFactory registers the specified token provider
func SetAuthConfigMapName ¶
func SetAuthConfigMapName(name string)
Types ¶
type AuthenticatorContext ¶
type AuthenticatorContext struct{}
type AuthenticatorFactory ¶
type AuthenticatorFactory func(cfg *AuthenticatorContext) (Request, error)
type DefaultStore ¶
type DefaultStore struct {
// contains filtered or unexported fields
}
func GetDefaultStoreInstance ¶
func GetDefaultStoreInstance() *DefaultStore
func (*DefaultStore) UserAdd ¶
func (s *DefaultStore) UserAdd(user User) error
func (*DefaultStore) UserChangePassword ¶
func (s *DefaultStore) UserChangePassword(username, password string) error
func (*DefaultStore) UserDelete ¶
func (s *DefaultStore) UserDelete(username string) error
func (*DefaultStore) UserList ¶
func (s *DefaultStore) UserList() ([]*User, error)
type Request ¶
Request attempts to extract authentication information from a request and returns a Response or an error if the request could not be checked.
func GetAuthenticatorProvider ¶
func GetAuthenticatorProvider(name string, ctx *AuthenticatorContext) (Request, error)
GetAuthenticatorProvider gets the specified authenticator provider
type Response ¶
type Response struct { Username string `json:"username"` ResetPassword bool `json:"reset_password"` Token string `json:"token"` Message string `json:"message"` }
Response is the struct returned by authenticator interfaces
func SuccessResponse ¶
func SuccessTokenResponse ¶
func UnauthenticatedResponse ¶
func UnauthenticatedResponse() *Response
type Store ¶
type Store interface { // UserGet gets a user UserGet(username string) (*User, error) // UserAdd adds a user UserAdd(user User) error // UserDelete deletes a user UserDelete(username string) error // UserList lists users UserList() ([]*User, error) // UserChangePassword changes a password of a user UserChangePassword(username, password string) error }
Store gets and updates users
type Token ¶
type Token interface {
AuthenticateToken(ctx context.Context, token string) (*Response, bool, error)
}
Token checks a string value against a backing authentication store and returns a Response or an error if the token could not be checked.
func GetTokenProvider ¶
func GetTokenProvider(name string, ctx *TokenContext) (Token, error)
GetTokenProvider gets the specified token provider
type TokenContext ¶
type TokenFactory ¶
type TokenFactory func(cfg *TokenContext) (Token, error)
Click to show internal directories.
Click to hide internal directories.