Documentation
¶
Index ¶
- Variables
- func ComparePassword(password, hash string) error
- func GenerateAccessToken(userID string, roles []string, secret string, validity time.Duration) (string, error)
- func GenerateJWT(data map[string]interface{}, secret string) (string, error)
- func GenerateRefreshToken(sessionID string, createdAt, expiresAt time.Time, secret string) (string, error)
- func HashPassword(password string) (string, error)
- func ValidateAccessToken(token, secret string) (jwt.MapClaims, error)
- func ValidateEmail(email string) (bool, error)
- func ValidatePassword(password string) (bool, error)
- func ValidateRefreshToken(token, secret string) (jwt.MapClaims, error)
- type CreateEmailVerificationParams
- type CreatePasswordRecoveryParams
- type CreateSessionParams
- type CreateUserLoginDataParams
- type CreateUserParams
- type DBTX
- type Emailverification
- type Externalloginprovider
- type GetUserByIdRow
- type Hashalgorithm
- type IDTokens
- type Passwordrecovery
- type Queries
- func (q *Queries) CreateEmailVerification(ctx context.Context, arg CreateEmailVerificationParams) error
- func (q *Queries) CreatePasswordRecovery(ctx context.Context, arg CreatePasswordRecoveryParams) error
- func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (pgtype.UUID, error)
- func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (pgtype.UUID, error)
- func (q *Queries) CreateUserLoginData(ctx context.Context, arg CreateUserLoginDataParams) error
- func (q *Queries) DeleteSession(ctx context.Context, sessionID pgtype.UUID) error
- func (q *Queries) GetLoginDataByEmail(ctx context.Context, email string) (Userslogindatum, error)
- func (q *Queries) GetSessionById(ctx context.Context, sessionID pgtype.UUID) (Session, error)
- func (q *Queries) GetUserById(ctx context.Context, userID pgtype.UUID) (GetUserByIdRow, error)
- func (q *Queries) Test_UpdateSessionExpiresAt(ctx context.Context, arg Test_UpdateSessionExpiresAtParams) error
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type Router
- type ServerError
- type Session
- type Test_UpdateSessionExpiresAtParams
- type Usecases
- func (u *Usecases) LoginUser(ctx context.Context, email, password string) (*IDTokens, error)
- func (u *Usecases) RefreshAccessToken(ctx context.Context, refreshToken string) (*IDTokens, error)
- func (u *Usecases) RegisterUser(ctx context.Context, firstname, lastname, email, password string) error
- func (u *Usecases) ValidateAccessToken(ctx context.Context, accessToken string) (*UserData, error)
- type User
- type UserData
- type Userloginexternal
- type Userslogindatum
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // ExpiredTokenError is an error that represents an expired token ExpiredTokenError = &ValidationError{ Message: "Token has expired", } )
Functions ¶
func ComparePassword ¶
ComparePassword compares a password with a hash
func GenerateAccessToken ¶
func GenerateAccessToken(userID string, roles []string, secret string, validity time.Duration) (string, error)
GenerateAccessToken generates an access token with user-specific data
func GenerateJWT ¶
GenerateJWT generates a JWT token containing the provided data
func GenerateRefreshToken ¶ added in v0.2.0
func GenerateRefreshToken(sessionID string, createdAt, expiresAt time.Time, secret string) (string, error)
GenerateRefreshToken generates a refresh token
func HashPassword ¶
HashPassword hashes a password using bcrypt algorithm
func ValidateAccessToken ¶
ValidateAccessToken validates an access token
func ValidateEmail ¶
ValidateEmail validates an email address based on the following rules: - Must contain an @ symbol - Must contain a period - Must have at least 2 characters after the period
func ValidatePassword ¶
ValidatePassword validates a password based on the following rules: - Must be at least 8 characters long - Must contain at least one lowercase letter - Must contain at least one uppercase letter - Must contain at least one digit - Must contain at least one special character
func ValidateRefreshToken ¶ added in v0.2.0
ValidateRefreshToken validates a refresh token
Types ¶
type CreateSessionParams ¶ added in v0.2.0
type CreateSessionParams struct { UserID pgtype.UUID CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz }
type CreateUserParams ¶
type Emailverification ¶
type Externalloginprovider ¶
type GetUserByIdRow ¶
type Hashalgorithm ¶
type Hashalgorithm struct {
Hashalgorithm string
}
type Passwordrecovery ¶
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) CreateEmailVerification ¶
func (q *Queries) CreateEmailVerification(ctx context.Context, arg CreateEmailVerificationParams) error
func (*Queries) CreatePasswordRecovery ¶
func (q *Queries) CreatePasswordRecovery(ctx context.Context, arg CreatePasswordRecoveryParams) error
func (*Queries) CreateSession ¶ added in v0.2.0
func (*Queries) CreateUser ¶
func (*Queries) CreateUserLoginData ¶
func (q *Queries) CreateUserLoginData(ctx context.Context, arg CreateUserLoginDataParams) error
func (*Queries) DeleteSession ¶ added in v0.2.0
func (*Queries) GetLoginDataByEmail ¶
func (*Queries) GetSessionById ¶ added in v0.2.0
func (*Queries) GetUserById ¶
func (*Queries) Test_UpdateSessionExpiresAt ¶ added in v0.2.0
func (q *Queries) Test_UpdateSessionExpiresAt(ctx context.Context, arg Test_UpdateSessionExpiresAtParams) error
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is the http router for the auth service
type ServerError ¶
type ServerError struct {
Message string
}
ServerError is an error type that represents an internal server error
type Session ¶ added in v0.2.0
type Session struct { SessionID pgtype.UUID UserID pgtype.UUID CreatedAt pgtype.Timestamptz UpdatedAt pgtype.Timestamptz ExpiresAt pgtype.Timestamptz }
type Test_UpdateSessionExpiresAtParams ¶ added in v0.2.0
type Test_UpdateSessionExpiresAtParams struct { ExpiresAt pgtype.Timestamptz SessionID pgtype.UUID }
type Usecases ¶
type Usecases struct {
// contains filtered or unexported fields
}
Usecases is the usecases for the auth service
func NewUsecase ¶
func NewUsecase(logger *betalinklogger.Logger, queries *Queries) *Usecases
NewUsecase creates a new Usecases instance
func (*Usecases) RefreshAccessToken ¶ added in v0.2.0
type UserData ¶ added in v0.2.0
UserData represents the user information retrieved from the auth server
type Userloginexternal ¶
type Userslogindatum ¶
type ValidationError ¶
type ValidationError struct {
Message string
}
ValidationError is an error type that represents a validation error
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns the error message