auth

package
v0.0.0-...-a24ed69 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedSigningMethod = &api.Error{
		Code:    400,
		Message: "unexpected jwt signing method",
	}

	ErrUnauthorized = &api.Error{
		Code:    401,
		Message: "invalid or missing jwt",
	}

	ErrIncorrectLogin = &api.Error{
		Code:    401,
		Message: "invalid email or password",
	}
)
View Source
var (
	Middleware = jwtware.New(jwtware.Config{
		ErrorHandler: func(c *fiber.Ctx, err error) error {

			return ErrUnauthorized
		},

		SigningKey: jwtware.SigningKey{
			JWTAlg: "HS256",
			Key:    Secret,
		},
	})

	Secret = []byte(application.Env.Get("JWT_SECRET"))

	SigningMethod = jwt.SigningMethodHS256
)
View Source
var (
	DefaultHandler = &AuthHandler{
		Provider: DefaultService,
	}
)
View Source
var (
	DefaultService = &XJwt{
		UserService: *users.DefaultService,
	}
)

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct {
	Provider *XJwt
}

func NewHandler

func NewHandler(provider *XJwt) *AuthHandler

func (*AuthHandler) Route

func (h *AuthHandler) Route(r fiber.Router)

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Token       string      `json:"access_token"`
	UserDetails *users.User `json:"user_details"`
}

type XJwt

type XJwt struct {
	users.UserService
}

func (*XJwt) Generate

func (s *XJwt) Generate(claims jwt.Claims) (string, error)

func (*XJwt) Login

func (s *XJwt) Login(request LoginRequest) (*LoginResponse, error)

Jump to

Keyboard shortcuts

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