anonymous

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

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(i *identity.Anonymous) error

func (*Provider) Delete

func (p *Provider) Delete(i *identity.Anonymous) error

func (*Provider) Get

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

func (*Provider) GetByKeyID

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

func (*Provider) GetMany

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

func (*Provider) List

func (p *Provider) List(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(i *identity.Anonymous) (err error)

func (*Store) Delete

func (s *Store) Delete(i *identity.Anonymous) error

func (*Store) Get

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

func (*Store) GetByKeyID

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

func (*Store) GetMany

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

func (*Store) List

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

type StoreRedis

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

func (*StoreRedis) CreatePromotionCode

func (s *StoreRedis) CreatePromotionCode(code *PromotionCode) error

func (*StoreRedis) DeletePromotionCode

func (s *StoreRedis) DeletePromotionCode(code *PromotionCode) error

func (*StoreRedis) GetPromotionCode

func (s *StoreRedis) GetPromotionCode(codeHash string) (*PromotionCode, error)

Jump to

Keyboard shortcuts

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