actions

package
v0.0.0-...-069ff91 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(ctx context.Context, p *papers.Papers, fields ConfirmFields) error

Starts the password recovery flow

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 Recover

func Recover(ctx context.Context, p *papers.Papers, fields RecoverStartFields) error

Starts the password recovery flow

func RecoverFinish

func RecoverFinish(ctx context.Context, p *papers.Papers, fields RecoverFinishFields) error

Starts the password recovery flow

func RecoverValidate

func RecoverValidate(ctx context.Context, p *papers.Papers, fields RecoverValidateFields) error

Starts the password recovery flow

func Register

func Register(ctx context.Context, p *papers.Papers, fields RegisterFields) (papers.User, error)

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 LoginFields struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Remember bool   `json:"remember"`
}

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 OAuth2CallbackFields struct {
	Provider string
	Nonce    string
	State    string
	Code     string
	Remember bool
}

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 OAuth2StartFields struct {
	Provider string `json:"provider"`
	Remember bool   `json:"remember"`
}

type OAuth2StartResult

type OAuth2StartResult struct {
	Nonce       string
	RedirectURL string
}

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 RecoverFinishFields struct {
	Token    string `json:"token"`
	Password string `json:"password"`
}

type RecoverStartFields

type RecoverStartFields struct {
	Email string `json:"email"`
}

type RecoverValidateFields

type RecoverValidateFields struct {
	Token string
}

type RegisterFields

type RegisterFields struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type TOTPFinishFields

type TOTPFinishFields struct {
	Secret string `json:"secret"`
	Code   string `json:"code"`
}

type TOTPLoginFields

type TOTPLoginFields struct {
	Code     string `json:"code"`
	UserID   int64  `json:"-"`
	Remember bool   `json:"-"`
}

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

type TOTPSetupResult

type TOTPSetupResult struct {
	Secret string
	QR     image.Image
}

func TOTPSetup

func TOTPSetup(ctx context.Context, p *papers.Papers, user papers.User) (*TOTPSetupResult, error)

Generates a TOTP secret and QR code to start the TOTP enrollment process

Jump to

Keyboard shortcuts

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