auth

package
v0.0.0-...-e5673ba Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package auth provides authentication and authorization support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthError

func IsAuthError(err error) bool

IsAuthError checks if an error of type AuthError exists.

func NewAuthError

func NewAuthError(format string, args ...any) error

NewAuthError creates an AuthError for the provided message.

func SetClaims

func SetClaims(ctx context.Context, claims Claims) context.Context

SetClaims stores the claims in the context.

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims

	BusinessID string `json:"business_id" validate:"required,uuid"`
	PersonID   string `json:"person_id" validate:"uuid"`
	AppID      string `json:"azp" validate:"required"`
}

Claims represents the authorization claims transmitted via a JWT.

func Authenticate

func Authenticate(ctx context.Context, bearerToken string) (Claims, error)

Authenticate processes the token to validate the sender's token is valid.

func GetClaims

func GetClaims(ctx context.Context) Claims

GetClaims returns the claims from the context.

func (*Claims) Validate

func (c *Claims) Validate() error

Validate validates claims.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is used to pass an error during the request through the application with auth specific context.

func (*Error) Error

func (ae *Error) Error() string

Error implements the error interface. It uses the default message of the wrapped error. This is what will be shown in the services' logs.

Jump to

Keyboard shortcuts

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