anonymous

package
v0.0.0-...-2bc625b Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const RequestTokenType = "vnd.authgear.anonymous-request"

nolint:gosec

Variables

View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Store), "*"),
	wire.Struct(new(Provider), "*"),
	wire.Struct(new(StoreRedis), "*"),
)
View Source
var ErrPromotionCodeNotFound = errors.New("promotion code not found")
View Source
var KeyIDFormat = regexp.MustCompile(`^[-\w]{8,64}$`)

Functions

func GeneratePromotionCode

func GeneratePromotionCode() string

func HashPromotionCode

func HashPromotionCode(code string) string

Types

type PromotionCode

type PromotionCode struct {
	AppID      string `json:"app_id"`
	UserID     string `json:"user_id"`
	IdentityID string `json:"identity_id"`

	CreatedAt time.Time `json:"created_at"`
	ExpireAt  time.Time `json:"expire_at"`
	CodeHash  string    `json:"code_hash"`
}

type Provider

type Provider struct {
	Store *Store
	Clock clock.Clock
}

func (*Provider) Create

func (p *Provider) Create(ctx context.Context, i *identity.Anonymous) error

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, i *identity.Anonymous) error

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, userID, id string) (*identity.Anonymous, error)

func (*Provider) GetByKeyID

func (p *Provider) GetByKeyID(ctx context.Context, keyID string) (*identity.Anonymous, error)

func (*Provider) GetMany

func (p *Provider) GetMany(ctx context.Context, ids []string) ([]*identity.Anonymous, error)

func (*Provider) List

func (p *Provider) List(ctx context.Context, userID string) ([]*identity.Anonymous, error)

func (*Provider) New

func (p *Provider) New(
	userID string,
	keyID string,
	key []byte,
) *identity.Anonymous

func (*Provider) ParseRequest

func (p *Provider) ParseRequest(requestJWT string, i *identity.Anonymous) (*Request, error)

func (*Provider) ParseRequestUnverified

func (p *Provider) ParseRequestUnverified(requestJWT string) (r *Request, err error)

type Request

type Request struct {
	Key       jwk.Key       `json:"-"`
	KeyID     string        `json:"-"`
	Challenge string        `json:"challenge"`
	Action    RequestAction `json:"action"`
}

type RequestAction

type RequestAction string
const (
	RequestActionAuth    RequestAction = "auth"
	RequestActionPromote RequestAction = "promote"
)

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
}

func (*Store) Create

func (s *Store) Create(ctx context.Context, i *identity.Anonymous) (err error)

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, i *identity.Anonymous) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, userID, id string) (*identity.Anonymous, error)

func (*Store) GetByKeyID

func (s *Store) GetByKeyID(ctx context.Context, keyID string) (*identity.Anonymous, error)

func (*Store) GetMany

func (s *Store) GetMany(ctx context.Context, ids []string) ([]*identity.Anonymous, error)

func (*Store) List

func (s *Store) List(ctx context.Context, userID string) ([]*identity.Anonymous, error)

type StoreRedis

type StoreRedis struct {
	Redis *appredis.Handle
	AppID config.AppID
	Clock clock.Clock
}

func (*StoreRedis) CreatePromotionCode

func (s *StoreRedis) CreatePromotionCode(ctx context.Context, code *PromotionCode) error

func (*StoreRedis) DeletePromotionCode

func (s *StoreRedis) DeletePromotionCode(ctx context.Context, code *PromotionCode) error

func (*StoreRedis) GetPromotionCode

func (s *StoreRedis) GetPromotionCode(ctx context.Context, codeHash string) (*PromotionCode, error)

Jump to

Keyboard shortcuts

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