oauth

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidProvider = errors.New("not a valid Provider")

Functions

func AuthMiddleware

func AuthMiddleware(service Service) echo.MiddlewareFunc

func CheckCurrentSession

func CheckCurrentSession(res http.ResponseWriter, req *http.Request) (us session.UserSession, err error)

func GetUserFromCtx

func GetUserFromCtx(ctx context.Context) *user.User

func Module

func Module() fx.Option

func SetOAuthAPIRoutes

func SetOAuthAPIRoutes(server *echo.Echo, handler *OAuthHandler)

Types

type MiddlewareCtxKey

type MiddlewareCtxKey string
const (
	MiddlewareUserKey MiddlewareCtxKey = "user"
)

type OAuth

type OAuth struct {
	gorm.Model
	UserID     uint
	Provider   Provider
	Identifier string
}

func (OAuth) TableName

func (OAuth) TableName() string

type OAuthHandler

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

func NewOAuthHandler

func NewOAuthHandler(service Service) *OAuthHandler

func (*OAuthHandler) AuthCallback

func (h *OAuthHandler) AuthCallback(c echo.Context) (err error)

func (*OAuthHandler) AuthLogin

func (h *OAuthHandler) AuthLogin(c echo.Context) (err error)

func (*OAuthHandler) AuthLogout

func (h *OAuthHandler) AuthLogout(c echo.Context) (err error)

type OAuthService

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

func (*OAuthService) Auth

func (s *OAuthService) Auth(ctx context.Context, oauthUser goth.User) (authUser user.User, err error)

type Provider

type Provider int

ENUM(github)

const (
	// ProviderGithub is a Provider of type Github.
	ProviderGithub Provider = iota
)

func ParseProvider

func ParseProvider(name string) (Provider, error)

ParseProvider attempts to convert a string to a Provider.

func (Provider) IsValid

func (x Provider) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (Provider) MarshalText

func (x Provider) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (*Provider) Scan

func (x *Provider) Scan(value interface{}) (err error)

Scan implements the Scanner interface.

func (Provider) String

func (x Provider) String() string

String implements the Stringer interface.

func (*Provider) UnmarshalText

func (x *Provider) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

func (Provider) Value

func (x Provider) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Service

type Service interface {
	Auth(ctx context.Context, oauthUser goth.User) (user user.User, err error)
}

func NewOAuthService

func NewOAuthService(db *gorm.DB, userService user.Service) Service

Jump to

Keyboard shortcuts

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