Documentation ¶
Index ¶
- func Confirm(ctx context.Context, p *papers.Papers, fields ConfirmFields) error
- func Logout(ctx context.Context, p *papers.Papers, userID int64, ...) error
- func Recover(ctx context.Context, p *papers.Papers, fields RecoverStartFields) error
- func RecoverFinish(ctx context.Context, p *papers.Papers, fields RecoverFinishFields) error
- func RecoverValidate(ctx context.Context, p *papers.Papers, fields RecoverValidateFields) error
- func Register(ctx context.Context, p *papers.Papers, fields RegisterFields) (papers.User, error)
- func TOTPFinish(ctx context.Context, p *papers.Papers, user papers.User, ...) error
- type ConfirmFields
- type LoginFields
- type LoginResult
- type MultiError
- type OAuth2CallbackFields
- type OAuth2CallbackResult
- type OAuth2StartFields
- type OAuth2StartResult
- type RecoverFinishFields
- type RecoverStartFields
- type RecoverValidateFields
- type RegisterFields
- type TOTPFinishFields
- type TOTPLoginFields
- type TOTPLoginResult
- type TOTPSetupResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logout ¶
func Logout(ctx context.Context, p *papers.Papers, userID int64, accessToken *papers.AccessToken, refreshToken *papers.RefreshToken) error
Invalidates the current token chain
func RecoverFinish ¶
Starts the password recovery flow
func RecoverValidate ¶
Starts the password recovery flow
func Register ¶
Creates a new user from the given fields. Errors are returned with errors.Join, use a type assertion with actions.MultiError to call Unwrap() []error
func TOTPFinish ¶
func TOTPFinish(ctx context.Context, p *papers.Papers, user papers.User, fields TOTPFinishFields) error
Generates a TOTP secret and QR code to start the TOTP enrollment process
Types ¶
type ConfirmFields ¶
type ConfirmFields struct {
Token string
}
type LoginFields ¶
type LoginResult ¶
type LoginResult struct { NeedsTOTP bool Remember bool User papers.User AccessToken *papers.AccessToken RefreshToken *papers.RefreshToken }
func Login ¶
func Login(ctx context.Context, p *papers.Papers, fields LoginFields) (*LoginResult, error)
Attempts to authenticate a user with the given email and password. Caller is responsible for sending access and refresh tokens to the client
type MultiError ¶
type MultiError interface {
Unwrap() []error
}
type OAuth2CallbackFields ¶
type OAuth2CallbackResult ¶
type OAuth2CallbackResult struct { User papers.User AccessToken *papers.AccessToken RefreshToken *papers.RefreshToken }
func OAuth2Callback ¶
func OAuth2Callback(ctx context.Context, p *papers.Papers, fields OAuth2CallbackFields) (*OAuth2CallbackResult, error)
Handles the callback from an OAuth2 provider
type OAuth2StartFields ¶
type OAuth2StartResult ¶
func OAuth2Start ¶
func OAuth2Start(ctx context.Context, p *papers.Papers, fields OAuth2StartFields) (*OAuth2StartResult, error)
Starts the OAuth2 flow for a given provider
type RecoverFinishFields ¶
type RecoverStartFields ¶
type RecoverStartFields struct {
Email string `json:"email"`
}
type RecoverValidateFields ¶
type RecoverValidateFields struct {
Token string
}
type RegisterFields ¶
type TOTPFinishFields ¶
type TOTPLoginFields ¶
type TOTPLoginResult ¶
type TOTPLoginResult struct { User papers.User AccessToken *papers.AccessToken RefreshToken *papers.RefreshToken }
func TOTPLogin ¶
func TOTPLogin(ctx context.Context, p *papers.Papers, fields TOTPLoginFields) (*TOTPLoginResult, error)
Completes authentication of users with a TOTP configured. Caller is responsible for sending access and refresh tokens to the client