auth

package
v0.0.0-...-3407765 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinEntropy     = 65
	BcryptCost     = 12
	BcryptCostWeak = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionAuthGinController

type SessionAuthGinController struct {

	// uris / cookies
	CookieName         string
	Domain             string
	PasswordResetURL   string
	VerifyEmailURLFull string
	URLPathPrefix      string

	AccountSessionDuration             time.Duration
	Verification_PasswordResetDuration time.Duration

	// repos
	Arepo repository.IAccount
	SRepo repository.ISession
	Hrepo repository.IHashVerificationAccount
	Tx    repository.ITransaction
	// email sender config
	MailValidation email.ISender
	BaseMailConfig email.Content

	// sso support
	SSOHandler sso.Handler

	// html templates here
	ResetPasswordTemplateHTML []byte
	VerifyAccountTemplateHTML []byte
}

SessionAuthGinController : a fully featured highly opinionated gin session authentication controller which has support for the following :

1) login regular user pwd / sso

2) logout

3) password change + password change if forgotten

4) account verification

5) password strength check

func NewGinSessionAuthGorm

func NewGinSessionAuthGorm(s *SessionConfig) *SessionAuthGinController

func (*SessionAuthGinController) ApplyRoutes

func (c *SessionAuthGinController) ApplyRoutes(e *gin.Engine) *gin.Engine

func (*SessionAuthGinController) DeleteCookie

func (c *SessionAuthGinController) DeleteCookie(ctx *gin.Context)

func (*SessionAuthGinController) GetAuthMiddleWare

func (c *SessionAuthGinController) GetAuthMiddleWare() gin.HandlerFunc

func (*SessionAuthGinController) IsLoggedIn

func (c *SessionAuthGinController) IsLoggedIn(ctx *gin.Context) bool

func (*SessionAuthGinController) IsPasswordSafe

func (c *SessionAuthGinController) IsPasswordSafe(p string) error

func (*SessionAuthGinController) SerializeSession

func (c *SessionAuthGinController) SerializeSession(accountID string, ctx *gin.Context, existingSession *entity.Session)

type SessionConfig

type SessionConfig struct {
	// DB : gorm data base this is required
	DB *gorm.DB
	// BasePathRoute : the base uri
	BasePathRoute string
	// CookieName : name of the cooke this is required
	CookieName string
	// LoginExpiryTime : the login expiry time default is 15m
	LoginExpiryTime time.Duration
	// Domain : host domain
	Domain string
	// SSOConfig : sso configuration , if you want /login/sso route working
	SSOConfig sso.Config
	// PasswordResetURLFull : password reset forgotten page
	PasswordResetURLFull string
	// VerifyEmailURLFull : email verifiaction page for your front end
	VerifyEmailURLFull string
	// PasswordResetLinkDuration : expiry time for the reset link
	PasswordResetLinkDuration time.Duration
	// Mailer : email client you want to use
	Mailer email.ISender
	// EmailSender : your app's official email for transactions (no reply email)
	EmailSender string
	// EmailSenderUserFriendly : your app's offical email , user friendly name (ie Password Reset <Your App Name>)
	EmailSenderUserFriendly string
	// ResetPasswordTemplateHTML : your app's html template for this operation as []byte , the file grabbing portion is your bit
	ResetPasswordTemplateHTML []byte
	// VerifyAccountTemplateHTML : your app's html template this operation as []byte , the file grabbing portion is your bit
	VerifyAccountTemplateHTML []byte
}

SessionConfig : Sesion Auth Config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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