service

package
v0.0.0-...-68e8b16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_CONTEXT_KEY types.ContextKey = "user"
)

Variables

View Source
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

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

validates google ID token and registeres google user

type JsonWebTokenConfiguration

type JsonWebTokenConfiguration struct {
	AccessTokenSecret  string
	RefreshTokenSecret string
}

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

type JwtPayload struct {
	Id   string
	Role types.Role
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL