account

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Authorizer

type Authorizer struct {
	// contains filtered or unexported fields
}

func NewAuthorizer

func NewAuthorizer(log *zap.Logger, store Store, authn auth.Authenticator) *Authorizer

func (*Authorizer) Authorize

func (a *Authorizer) Authorize(ctx context.Context, m proto.Message, authField **commonpb.Auth) (*commonpb.UserId, error)

type Server

type Server struct {
	accountpb.UnimplementedAccountServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(log *zap.Logger, store Store, verifier auth.Authenticator) *Server

func (*Server) GetUserFlags

func (*Server) Login

func (*Server) Register

type Store

type Store interface {
	// Bind binds a public key to a UserId, or returns the previously bound UserId.
	Bind(ctx context.Context, userID *commonpb.UserId, pubKey *commonpb.PublicKey) (*commonpb.UserId, error)

	// GetUserId returns the UserId associated with a public key.
	//
	/// ErrNotFound is returned if no binding exists.
	GetUserId(ctx context.Context, pubKey *commonpb.PublicKey) (*commonpb.UserId, error)

	// GetPubKeys returns the set of public keys associated with an account.
	GetPubKeys(ctx context.Context, userID *commonpb.UserId) ([]*commonpb.PublicKey, error)

	// RemoveKey removes a key from the set of user keys.
	//
	// It is idempotent, and does not return an error if the user does not exist.
	RemoveKey(ctx context.Context, userID *commonpb.UserId, pubKey *commonpb.PublicKey) error

	// IsAuthorized returns whether or not a pubKey is authorized to perform actions on behalf of the user.
	IsAuthorized(ctx context.Context, userID *commonpb.UserId, pubKey *commonpb.PublicKey) (bool, error)

	// IsStaff returns whether or not a userID is a staff user
	IsStaff(ctx context.Context, userID *commonpb.UserId) (bool, error)

	// IsRegistered returns whether or not a userID is a registered account
	IsRegistered(ctx context.Context, userID *commonpb.UserId) (bool, error)

	// SetRegistrationFlag sets wether a userID is a registered account
	SetRegistrationFlag(ctx context.Context, userID *commonpb.UserId, isRegistered bool) error

	// ExtendAirdropEligibility extends airdrop eligibility for a user until the
	// specified time
	ExtendAirdropEligibility(ctx context.Context, userID *commonpb.UserId, until time.Time) error

	// GetAirdropEligibilityTimestamp gets the airdrop eligibility timestamp for a user
	GetAirdropEligibilityTimestamp(ctx context.Context, userID *commonpb.UserId) (time.Time, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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