auth

package
v1.31.5-0...-ff97089 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(cfg *config.Config, db *pg.DB) (echo.MiddlewareFunc, echo.MiddlewareFunc)

func RegisterRoutes

func RegisterRoutes(e *echo.Echo, cfg *config.Config, db *pg.DB, nonEnforceAuth echo.MiddlewareFunc)

RegisterRoutes takes in an Echo router and registers routes onto it.

Types

type RetrieveSessionOptions

type RetrieveSessionOptions struct {
	Username *string
}

type Service

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

func NewService

func NewService(cfg *config.Config, db *pg.DB) *Service

func (*Service) ParseToken

func (svc *Service) ParseToken(_ context.Context, signed string) (*Session, error)

func (*Service) RetrieveSession

func (svc *Service) RetrieveSession(ctx context.Context, opts RetrieveSessionOptions) (*Session, error)

func (*Service) SignSession

func (svc *Service) SignSession(_ context.Context, session *Session) (string, error)

func (*Service) UpdateSession

func (svc *Service) UpdateSession(ctx context.Context, session *Session, opts UpdateSessionOptions) error

type Session

type Session struct {
	ID               int        `json:"id"`
	Username         string     `json:"username"`
	FriendCode3DS    *string    `pg:"friend_code_3ds" json:"friend_code_3ds"`
	FriendCodeSwitch *string    `json:"friend_code_switch"`
	Password         string     `json:"-"`
	LastIP           *string    `json:"-"`
	LastLogin        *time.Time `json:"-"`
	DateCreated      time.Time  `json:"date_created"`
	DateModified     time.Time  `json:"date_modified"`

	// This is so that we can use this struct as a Claims struct, and we can sign it as a payload.
	jwt.RegisteredClaims `pg:"-"`
	// contains filtered or unexported fields
}

func FromContext

func FromContext(c echo.Context) *Session

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

MarshalJSON is just needed for parity testing. Once we're actually using this in production, we can remove it.

type UpdateSessionOptions

type UpdateSessionOptions struct {
	Columns []string
}

Jump to

Keyboard shortcuts

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