Documentation ¶
Index ¶
Constants ¶
const (
USER_CONTEXT_KEY types.ContextKey = "user"
)
Variables ¶
var ( ErrInvalidCredentials = errors.New("invalid credentials") ErrUserAlreadyExists = errors.New("user already exists with given email") ErrUserNotFound = errors.New("user not found") ErrInvalidGoogleToken = errors.New("google id token is invalid") ErrGoogleClietIdNotSet = errors.New("google client id not configured") ErrInvalidRefreshToken = errors.New("refresh token is invalid") )
Functions ¶
This section is empty.
Types ¶
type AuthenticationService ¶
type AuthenticationService interface { ValidateSignIn(dto *dtos.Login) (*dtos.LoginSuccess, error) ValidateSignUp(dto *dtos.Register) (string, error) CheckUser(id string) (*dtos.LoginUser, error) ValidateRefresh(refreshToken string) (*string, error) AttachRefreshTokenCookie(w http.ResponseWriter, userId string) error }
AuthenticationService for signing up and logging in users.
func NewJsonWebTokenAuthenticationService ¶
func NewJsonWebTokenAuthenticationService(userRepo repository.UserRepository, jwtService JsonWebTokenService, lw logging.LogWriter, config *AuthenticationServiceConfiguration) AuthenticationService
NewJsonWebTokenAuthenticationService create a JWT flavoured AuthenticationService.
type AuthenticationServiceConfiguration ¶
type AuthenticationServiceConfiguration struct {
IsProduction bool
}
type GoogleAuthenicationService ¶
type GoogleAuthenicationService interface { ValidateGoogleSignUp(dto *dtos.GoogleSignUpRequest) (*dtos.LoginSuccess, error) ValidateGoogleSignIn(string) (*dtos.LoginSuccess, error) }
GoogleAuthenicationService for signing up and logging in users using googles authentication
func NewGoogleAuthenticationService ¶
func NewGoogleAuthenticationService(config *GoogleAuthenticationConfiguration, userRepo repository.UserRepository, jwtService JsonWebTokenService, lw logging.LogWriter) GoogleAuthenicationService
type GoogleAuthenticationConfiguration ¶
type GoogleAuthenticationConfiguration struct {
ClientId string
}
type GoogleJsonWebTokenAuthenticationService ¶
type GoogleJsonWebTokenAuthenticationService struct {
// contains filtered or unexported fields
}
func (*GoogleJsonWebTokenAuthenticationService) ValidateGoogleSignIn ¶
func (svc *GoogleJsonWebTokenAuthenticationService) ValidateGoogleSignIn(idToken string) (*dtos.LoginSuccess, error)
validates google ID token and logs in google user
func (*GoogleJsonWebTokenAuthenticationService) ValidateGoogleSignUp ¶
func (svc *GoogleJsonWebTokenAuthenticationService) ValidateGoogleSignUp(dto *dtos.GoogleSignUpRequest) (*dtos.LoginSuccess, error)
validates google ID token and registeres google user
type JsonWebTokenConfiguration ¶
JsonWebTokenConfiguration settings for the json web token service.
type JsonWebTokenService ¶
type JsonWebTokenService interface { SignAccessToken(JwtPayload) (*string, error) ParseAccessToken(string) (*JwtPayload, error) SignRefreshToken(RefreshTokenPayload) (*string, error) ParseRefreshToken(string) (*RefreshTokenPayload, error) }
JsonWebTokenService for signing and parsing json web tokens.
func NewJsonWebTokenService ¶
func NewJsonWebTokenService(config *JsonWebTokenConfiguration, lw logging.LogWriter) JsonWebTokenService
NewJsonWebTokenService creates a new implementation of the JsonWebTokenService.
type JwtPayload ¶
JwtPayload represents the json web token claims to be signed or that have been parsed.
type RefreshTokenPayload ¶
type RefreshTokenPayload struct {
Id string
}
RefreshTokenPayload represents json web token claims to be signed or that have been parsed.