authentication

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication struct {
	Account    account.Account `json:"account"`
	Service    Service         `json:"service"`
	Identifier string          `json:"identifier"`
	Token      string          `json:"-"`
	Metadata   interface{}     `json:"metadata,omitempty"`
}

func FromModel

func FromModel(m *model.Authentication) *Authentication

func FromModelMany

func FromModelMany(m []*model.Authentication) []Authentication

type Repository

type Repository interface {
	// Create an auth method for a account.
	Create(ctx context.Context,
		userID account.AccountID,
		service Service,
		identifier string,
		token string,
		metadata map[string]any,
	) (*Authentication, error)

	// Gets an auth method based on a service's external account ID.
	GetByIdentifier(ctx context.Context, service Service, identifier string) (*Authentication, error)

	// Gets all auth methods that a account has.
	GetAuthMethods(ctx context.Context, userID account.AccountID) ([]Authentication, error)

	// Checks if the given token is equal to the stored auth method's token.
	IsEqual(ctx context.Context, userID account.AccountID, identifier string, token string) (bool, error)
}

func New

func New(db *model.Client) Repository

type Service

type Service string

Jump to

Keyboard shortcuts

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