Documentation
¶
Index ¶
- Constants
- Variables
- func CreateActivationEmail(la *LocalProvider, user *fs.User) (*fs.Mail, error)
- func CreateConfirmationURL(baseURL, appKey string, user *fs.User) (string, error)
- func CreateRecoveryEmail(la *LocalProvider, user *fs.User) (*fs.Mail, error)
- func NewGithubAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func NewGoogleAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func NewLocalAuthProvider(config fs.Map, redirectURL string) (fs.AuthProvider, error)
- func SendConfirmationEmail(la *LocalProvider, logger logger.Logger, mail *fs.Mail)
- func ValidateConfirmationToken(token, key string) (uint64, error)
- func ValidateRegisterData(c context.Context, logger logger.Logger, dbClient db.Client, payload *Register) (err error)
- type Activation
- type Confirmation
- type GithubAccessTokenResponse
- type GithubAuthProvider
- func (ga *GithubAuthProvider) Callback(c fs.Context) (_ *fs.User, err error)
- func (ga *GithubAuthProvider) Login(c fs.Context) (_ any, err error)
- func (ga *GithubAuthProvider) Name() string
- func (ga *GithubAuthProvider) VerifyIDToken(c fs.Context, t fs.IDToken) (_ *fs.User, err error)
- func (ga *GithubAuthProvider) WithResources(resource *fs.Resource)
- type GithubUserResponse
- type GoogleAuthProvider
- type GoogleUser
- type LocalProvider
- func (la *LocalProvider) Activate(c fs.Context, data *Confirmation) (*Activation, error)
- func (la *LocalProvider) Callback(c fs.Context) (user *fs.User, err error)
- func (la *LocalProvider) Init(db func() db.Client, appKey func() string, appName func() string, ...)
- func (la *LocalProvider) LocalLogin(c fs.Context, payload *LoginData) (*fs.User, error)
- func (la *LocalProvider) Login(c fs.Context) (_ any, err error)
- func (la *LocalProvider) Name() string
- func (la *LocalProvider) Recover(c fs.Context, data *Recovery) (_ bool, err error)
- func (la *LocalProvider) RecoverCheck(c fs.Context, data *Confirmation) (_ bool, err error)
- func (la *LocalProvider) Register(c fs.Context, payload *Register) (*Activation, error)
- func (la *LocalProvider) ResetPassword(c fs.Context, data *ResetPassword) (_ bool, err error)
- func (la *LocalProvider) SendActivationLink(c fs.Context, data *Confirmation) (*Activation, error)
- func (la *LocalProvider) VerifyIDToken(c fs.Context, t fs.IDToken) (user *fs.User, err error)
- type LoginData
- type Recovery
- type Register
- type ResetPassword
Constants ¶
View Source
const ProviderGithub = "github"
View Source
const ProviderGoogle = "google"
View Source
const ProviderLocal = "local"
Variables ¶
View Source
var ( MSG_USER_SAVE_ERROR = "Error saving user" MSG_USER_ACTIVATION_ERROR = "Error activating user" MSG_USER_ALREADY_ACTIVE = "Your account is already activated" MSG_INVALID_TOKEN = "Invalid token" MSG_TOKEN_EXPIRED = "Token expired" MSG_CREATE_ACTIVATION_MAIL_ERROR = "Error while creating activation email: %w" MSG_USER_UPDATE_PROVIDER_ID_ERROR = "Error while update provider id: %w" MSG_CREATEP_RECOVERY_MAIL_ERROR = "Error while creating recovery email" MSG_INVALID_EMAIL = "Invalid email" MSG_INVALID_PASSWORD = "Invalid password" MSG_INVALID_LOGIN_OR_PASSWORD = "Invalid login or password" //nolint:gosec // G101: This is an error message, not a hardcoded credential MSG_USER_IS_INACTIVE = "User is inactive" MSG_INVALID_REGISTRATION = "Email, password and confirm_password are required" MSG_SEND_ACTIVATION_EMAIL_ERROR = "Error while sending activation email" MSG_MAILER_NOT_SET = "Mailer is not set" MSG_CHECKING_USER_ERROR = "Error checking user" MSG_USER_EXISTS = "User already exists" MSG_EXISTING_USER_WITH_EMAIL = "" /* 147-byte string literal not displayed */ ERR_SAVE_USER = errors.InternalServerError(MSG_USER_SAVE_ERROR) ERR_INVALID_TOKEN = errors.BadRequest(MSG_INVALID_TOKEN) ERR_TOKEN_EXPIRED = errors.BadRequest(MSG_TOKEN_EXPIRED) ERR_INVALID_LOGIN = errors.UnprocessableEntity(MSG_INVALID_LOGIN_OR_PASSWORD) ERR_USER_ALREADY_ACTIVE = errors.BadRequest(MSG_USER_ALREADY_ACTIVE) )
Functions ¶
func CreateActivationEmail ¶ added in v0.6.0
func CreateConfirmationURL ¶ added in v0.6.0
func CreateRecoveryEmail ¶ added in v0.6.0
func NewGithubAuthProvider ¶
func NewGoogleAuthProvider ¶
func NewLocalAuthProvider ¶ added in v0.5.0
func SendConfirmationEmail ¶ added in v0.6.0
func SendConfirmationEmail(la *LocalProvider, logger logger.Logger, mail *fs.Mail)
func ValidateConfirmationToken ¶ added in v0.6.0
Types ¶
type Activation ¶ added in v0.6.0
type Activation struct {
Activation string `json:"activation"` // auto, manual, email, activated
}
type Confirmation ¶ added in v0.6.0
type Confirmation struct {
Token string `json:"token"`
}
type GithubAuthProvider ¶
type GithubAuthProvider struct {
// contains filtered or unexported fields
}
func (*GithubAuthProvider) Login ¶
func (ga *GithubAuthProvider) Login(c fs.Context) (_ any, err error)
func (*GithubAuthProvider) Name ¶
func (ga *GithubAuthProvider) Name() string
func (*GithubAuthProvider) VerifyIDToken ¶ added in v0.7.5
func (*GithubAuthProvider) WithResources ¶ added in v0.6.0
func (ga *GithubAuthProvider) WithResources(resource *fs.Resource)
type GithubUserResponse ¶
type GoogleAuthProvider ¶
type GoogleAuthProvider struct {
// contains filtered or unexported fields
}
func (*GoogleAuthProvider) Login ¶
func (as *GoogleAuthProvider) Login(c fs.Context) (_ any, err error)
func (*GoogleAuthProvider) Name ¶
func (as *GoogleAuthProvider) Name() string
func (*GoogleAuthProvider) VerifyIDToken ¶ added in v0.7.5
type GoogleUser ¶ added in v0.7.3
type GoogleUser struct {
Issuer string `json:"iss"`
Audience string `json:"aud"`
ExpiresAt time.Time `json:"exp"`
IssuedAt time.Time `json:"iat"`
ID string `json:"id"` // Using token Subject as ID
Email string `json:"email"`
Name string `json:"name"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
Locale string `json:"locale"`
Picture string `json:"picture"`
EmailVerified bool `json:"email_verified"`
HD string `json:"hd"`
}
func (*GoogleUser) ToFSUser ¶ added in v0.7.5
func (gu *GoogleUser) ToFSUser() *fs.User
type LocalProvider ¶ added in v0.6.0
type LocalProvider struct {
// contains filtered or unexported fields
}
LocalProvider represents the local authentication provider.
config: activationMethod: auto, manual, email
auto: user is activated automatically manual: user is activated manually by admin email: user is activated by email
func (*LocalProvider) Activate ¶ added in v0.6.0
func (la *LocalProvider) Activate(c fs.Context, data *Confirmation) (*Activation, error)
func (*LocalProvider) LocalLogin ¶ added in v0.6.0
LocalLogin performs local login with username/email and password
func (*LocalProvider) Login ¶ added in v0.6.0
func (la *LocalProvider) Login(c fs.Context) (_ any, err error)
func (*LocalProvider) Name ¶ added in v0.6.0
func (la *LocalProvider) Name() string
func (*LocalProvider) RecoverCheck ¶ added in v0.6.0
func (la *LocalProvider) RecoverCheck(c fs.Context, data *Confirmation) (_ bool, err error)
func (*LocalProvider) Register ¶ added in v0.6.0
func (la *LocalProvider) Register(c fs.Context, payload *Register) (*Activation, error)
func (*LocalProvider) ResetPassword ¶ added in v0.6.0
func (la *LocalProvider) ResetPassword(c fs.Context, data *ResetPassword) (_ bool, err error)
func (*LocalProvider) SendActivationLink ¶ added in v0.6.0
func (la *LocalProvider) SendActivationLink(c fs.Context, data *Confirmation) (*Activation, error)
func (*LocalProvider) VerifyIDToken ¶ added in v0.7.5
type Register ¶ added in v0.6.0
type ResetPassword ¶ added in v0.6.0
type ResetPassword struct {
*Confirmation
Password string `json:"password"`
ConfirmPassword string `json:"confirm_password"`
}
Click to show internal directories.
Click to hide internal directories.