auth

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchJWKS added in v1.0.8

func FetchJWKS() error

func GenerateTokensAndSetCookies

func GenerateTokensAndSetCookies(user *user.User, c echo.Context) error

GenerateTokensAndSetCookies generates jwt token and saves it to the http-only cookie.

func GetJWTRefreshSecret

func GetJWTRefreshSecret() string

func GetJWTSecret

func GetJWTSecret() string

func GetUserClaims

func GetUserClaims(c echo.Context) *ent.User

GetUserClaims - returns user's claims

func GetUserMiddleware

func GetUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc

func GuardMiddleware added in v1.0.8

func GuardMiddleware(next echo.HandlerFunc) echo.HandlerFunc

func JWTErrorChecker

func JWTErrorChecker(err error, c echo.Context) error

JWTErrorChecker will be executed when user try to access a protected path.

func UserRoleMiddleware

func UserRoleMiddleware(role utils.Role) echo.MiddlewareFunc

Types

type ChangePassword

type ChangePassword struct {
	OldPassword string `json:"old_password"`
	NewPassword string `json:"new_password"`
}

type Claims

type Claims struct {
	UserID   uuid.UUID  `json:"user_id"`
	Username string     `json:"username"`
	Role     utils.Role `json:"role"`
	jwt.RegisteredClaims
}

type CustomContext

type CustomContext struct {
	echo.Context
	User *ent.User
}

type OAuthClaims added in v1.0.8

type OAuthClaims struct {
	jwt.RegisteredClaims
	// contains filtered or unexported fields
}

type OAuthResponse added in v1.0.8

type OAuthResponse struct {
	OAuth2Token *oauth2.Token
	UserInfo    UserInfo
}

type Service

type Service struct {
	Store *database.Database
	OAuth struct {
		Provider *oidc.Provider
		Config   oauth2.Config
	}
}

func NewService

func NewService(store *database.Database) *Service

func (*Service) ChangePassword

func (s *Service) ChangePassword(c *CustomContext, passwordDto ChangePassword) error

func (*Service) Login

func (s *Service) Login(c echo.Context, uDto user.User) (*ent.User, error)

func (*Service) Me

func (s *Service) Me(c *CustomContext) (*ent.User, error)

func (*Service) OAuthCallback added in v1.0.8

func (s *Service) OAuthCallback(c echo.Context) error

func (*Service) OAuthLogout added in v1.0.8

func (s *Service) OAuthLogout(c echo.Context) error

func (*Service) OAuthRedirect added in v1.0.8

func (s *Service) OAuthRedirect(c echo.Context) error

func (*Service) OAuthTokenRefresh added in v1.0.8

func (s *Service) OAuthTokenRefresh(c echo.Context, refreshToken string) error

func (*Service) OAuthUserCheck added in v1.0.8

func (s *Service) OAuthUserCheck(c echo.Context, idTokenClaims UserInfo) error

func (*Service) Refresh

func (s *Service) Refresh(c echo.Context, refreshToken string) error

func (*Service) Register

func (s *Service) Register(c echo.Context, user user.User) (*ent.User, error)

type UserInfo added in v1.0.8

type UserInfo struct {
	Sub               string   `json:"sub"`
	Exp               int64    `json:"exp"`
	Iat               int64    `json:"iat"`
	Name              string   `json:"name"`
	GivenName         string   `json:"given_name"`
	FamilyName        string   `json:"family_name"`
	PreferredUsername string   `json:"preferred_username"`
	NickName          string   `json:"nickname"`
	Groups            []string `json:"groups"`
}

func CheckOAuthAccessToken added in v1.0.8

func CheckOAuthAccessToken(c echo.Context, accessToken string) (*UserInfo, error)

Jump to

Keyboard shortcuts

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