Documentation
¶
Index ¶
- Variables
- func GenerateToken(length int) string
- func GetLanguageFromAcceptLanguageHeader(headerValue string) string
- func MustTranslate(lang, key string) string
- func RegisterDETranslations(v *validator.Validate, trans ut.Translator) (err error)
- func Translate(lang, key string) (string, error)
- type AuthGatewayService
- type AuthRequest
- type AuthScopesCtxKey
- type AuthService
- type AuthUserIDCtxKey
- type ClientService
- type EmailService
- type EmailTemplateData
- type UserService
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCredentials = errors.New("invalid-credentials") ErrTimeout = errors.New("timeout") ErrInvalidRedirectURI = errors.New("invalid-redirect-uri") ErrUnsupportedResponseType = errors.New("unsupported-response-type") ErrInvalidScope = errors.New("invalid-scope") ErrMissingRequiredSessionData = errors.New("missing-required-session-data") ErrReusedToken = errors.New("reused-token") ErrInvalidGrant = errors.New("invalid-grant") ErrUnsupportedGrantType = errors.New("unsupported-grant-type") ErrInvalidCodeChallenge = errors.New("invalid-code-challenge") ErrInsufficientScope = errors.New("insufficient-scope") )
Functions ¶
func GenerateToken ¶
func MustTranslate ¶
func RegisterDETranslations ¶
func RegisterDETranslations(v *validator.Validate, trans ut.Translator) (err error)
Types ¶
type AuthGatewayService ¶
type AuthGatewayService interface {
IsAuthorized(userID ulid.ULID, domain string) bool
IsAllowedURL(url string) bool
IsAllowedDomain(url string) bool
}
func NewAuthGatewayService ¶
func NewAuthGatewayService() (AuthGatewayService, error)
type AuthRequest ¶
type AuthScopesCtxKey ¶
type AuthScopesCtxKey struct{}
type AuthService ¶
type AuthService interface {
PublicJWTKey() *rsa.PublicKey
Login(ctx context.Context, userID ulid.ULID) error
VerifyUsernamePassword(ctx context.Context, email, password string) (*repos.UserModel, error)
Logout(ctx context.Context) error
HashPassword(password string) ([]byte, error)
VerifyPassword(user *repos.UserModel, password string) error
VerifyPasswordByID(ctx context.Context, id ulid.ULID, password string) error
AuthenticatedUserID(ctx context.Context) ulid.ULID
AuthorizedScopes(ctx context.Context) []string
IsEmailConfirmed(ctx context.Context, id ulid.ULID) (bool, error)
SendConfirmEmail(r *http.Request, ctx context.Context, user *repos.UserModel) error
ConfirmEmail(ctx context.Context, userID ulid.ULID, code string) error
RequestForgotPassword(ctx context.Context, lang, email string) error
ResetPassword(ctx context.Context, token, newPassword string) error
UpdatePassword(ctx context.Context, userID ulid.ULID, password string) error
CheckLoginPrerequisites(ctx context.Context) (emailConfirmed, otpActive, hasRefreshTokens bool, err error)
SendInvitation(ctx context.Context, email, lang string, blocking bool) error
VerifyInvitationToken(ctx context.Context, email, token string) error
GenerateOTPKey(ctx context.Context, user *repos.UserModel) (*otp.Key, error)
ActivateOTPKey(ctx context.Context, userID ulid.ULID, code string) error
VerifyOTPCode(ctx context.Context, userID ulid.ULID, code string) error
IsOTPActive(ctx context.Context, id ulid.ULID) (bool, error)
DisableOTP(ctx context.Context, id ulid.ULID, password string) error
HasRecoveryCodes(ctx context.Context, userID ulid.ULID) (bool, error)
GenerateRecoveryCodes(ctx context.Context, userID ulid.ULID) ([]string, error)
DeleteRecoveryCodes(ctx context.Context, userID ulid.ULID, password string) error
CreateRemember2FACookie(ctx context.Context, userID ulid.ULID) (*http.Cookie, error)
VerifyRemember2FACookie(ctx context.Context, userID ulid.ULID, r *http.Request) error
RemoveRemember2FACookie(ctx context.Context, userID ulid.ULID, w http.ResponseWriter, r *http.Request) error
PasskeyBeginRegistration(ctx context.Context, user *repos.UserModel, password, passkeyName string) (*protocol.CredentialCreation, error)
PasskeyFinishRegistration(ctx context.Context, user *repos.UserModel, req *http.Request) error
PasskeyBeginLogin(ctx context.Context) (*protocol.CredentialAssertion, error)
PasskeyFinishLogin(ctx context.Context, req *http.Request) (*repos.UserModel, error)
StartOAuthCodeFlow(ctx context.Context, clientID ulid.ULID, redirectURI *url.URL, responseType, scope, state, nonce, codeChallenge, codeChallengeMethod string) error
GetAuthRequest(ctx context.Context) (AuthRequest, error)
OAuthConsent(ctx context.Context) (string, error)
OAuthGenerateTokens(ctx context.Context, clientID ulid.ULID, clientSecret string, redirectURI *url.URL, grantType, grant, codeVerifier, scope string) (access string, refresh string, id string, scopes []string, expiresIn time.Duration, err error)
VerifyClientCredentials(ctx context.Context, clientID ulid.ULID, clientSecret string) error
RevokeOAuthTokens(ctx context.Context, clientID, userID ulid.ULID) error
VerifyAccessToken(ctx context.Context, token string, requiredScopes []string) (userID ulid.ULID, scopes []string, err error)
CreateGatewayToken(ctx context.Context, userID ulid.ULID) (string, error)
VerifyGatewayToken(ctx context.Context, secret string) (userID ulid.ULID, err error)
DeleteGatewayToken(ctx context.Context, secret string) error
DeleteAllGatewayTokens(ctx context.Context, userID ulid.ULID) error
DescribeScopes(lang string, scopes []string) []string
}
func NewAuthService ¶
func NewAuthService(userRepository repos.UserRepository, tokenRepository repos.TokenRepository, gatewayTokenRepository repos.GatewayTokenRepository, oauthRepository repos.OAuthRepository, clientRepository repos.ClientRepository, systemRepository repos.SystemRepository, sessionManager *scs.SessionManager, emailService EmailService) (AuthService, error)
type AuthUserIDCtxKey ¶
type AuthUserIDCtxKey struct{}
type ClientService ¶
type ClientService interface {
Find(ctx context.Context, id ulid.ULID) (*repos.ClientModel, error)
FindByUserAndID(ctx context.Context, userID, clientID ulid.ULID) (*repos.ClientModel, error)
FindByUser(ctx context.Context, userID ulid.ULID) ([]*repos.ClientModel, error)
Create(ctx context.Context, userID ulid.ULID, name, description string, website *url.URL, redirectURIs []*url.URL) (*repos.ClientModel, string, error)
Update(ctx context.Context, userID, clientID ulid.ULID, name, description string, website *url.URL, redirectURIs []*url.URL) error
ClientRotateSecret(ctx context.Context, userID, clientID ulid.ULID) (string, error)
Delete(ctx context.Context, userID, clientID ulid.ULID) error
}
func NewClientService ¶
func NewClientService(clientRepository repos.ClientRepository) ClientService
type EmailService ¶
type EmailService interface {
SendEmail(address, subject, messageName string, data EmailTemplateData) error
}
func NewEmailService ¶
func NewEmailService(emailFS fs.FS) EmailService
type EmailTemplateData ¶
func NewEmailTemplateData ¶
func NewEmailTemplateData(name, lang string) EmailTemplateData
type UserService ¶
type UserService interface {
Find(ctx context.Context, id ulid.ULID) (*repos.UserModel, error)
FindAll(ctx context.Context) ([]*repos.UserModel, error)
FindByEmail(ctx context.Context, email string) (*repos.UserModel, error)
Create(ctx context.Context, name, email, password string) (*repos.UserModel, error)
Update(ctx context.Context, id ulid.ULID, name string) error
SetProfilePicture(userID ulid.ULID, img image.Image) error
LoadProfilePicture(userID ulid.ULID, size int, writer io.Writer) error
ProfilePictureETag(userID ulid.ULID, size int) string
RequestChangeEmail(ctx context.Context, lang string, user *repos.UserModel, newEmail string) error
ChangeEmail(ctx context.Context, lang, token string) (string, error)
GetPasskeys(ctx context.Context, userID ulid.ULID) ([]*repos.Passkey, error)
GetPasskey(ctx context.Context, userID, id ulid.ULID) (*repos.Passkey, error)
UpdatePasskey(ctx context.Context, userID, id ulid.ULID, name string) error
DeletePasskey(ctx context.Context, userID, id ulid.ULID) error
Delete(ctx context.Context, id ulid.ULID) error
}
func NewUserService ¶
func NewUserService(userRepository repos.UserRepository, authService AuthService, emailService EmailService) UserService
Click to show internal directories.
Click to hide internal directories.