console

package
v1.67.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PasswordMinimumLength is the minimum allowed length for user account passwords.
	PasswordMinimumLength = 6
	// PasswordMaximumLength is the maximum allowed length for user account passwords.
	PasswordMaximumLength = 128
)
View Source
const (
	// MFARecoveryCodeCount specifies how many MFA recovery codes to generate.
	MFARecoveryCodeCount = 10
)
View Source
const (

	// TestPasswordCost is the hashing complexity to use for testing.
	TestPasswordCost = bcrypt.MinCost
)

Variables

View Source
var (
	// ErrMFAMissing is error type that occurs when a request is incomplete
	// due to missing MFA passcode or recovery code.
	ErrMFAMissing = errs.Class("MFA credentials missing")

	// ErrMFAConflict is error type that occurs when both a passcode and recovery code are given.
	ErrMFAConflict = errs.Class("MFA conflict")

	// ErrMFARecoveryCode is error type that represents usage of invalid MFA recovery code.
	ErrMFARecoveryCode = errs.Class("MFA recovery code")

	// ErrMFAPasscode is error type that represents usage of invalid MFA passcode.
	ErrMFAPasscode = errs.Class("MFA passcode")
)
View Source
var (
	// Error describes internal console error.
	Error = errs.Class("console service")

	// ErrUnauthorized is error class for authorization related errors.
	ErrUnauthorized = errs.Class("unauthorized")

	// ErrNoMembership is error type of not belonging to a specific project.
	ErrNoMembership = errs.Class("no membership")

	// ErrTokenExpiration is error type of token reached expiration time.
	ErrTokenExpiration = errs.Class("token expiration")

	// ErrTokenInvalid is error type of tokens which are invalid.
	ErrTokenInvalid = errs.Class("invalid token")

	// ErrProjLimit is error type of project limit.
	ErrProjLimit = errs.Class("project limit")

	// ErrUsage is error type of project usage.
	ErrUsage = errs.Class("project usage")

	// ErrLoginCredentials occurs when provided invalid login credentials.
	ErrLoginCredentials = errs.Class("login credentials")

	// ErrLoginPassword occurs when provided invalid login password.
	ErrLoginPassword = errs.Class("login password")

	// ErrEmailUsed is error type that occurs on repeating auth attempts with email.
	ErrEmailUsed = errs.Class("email used")

	// ErrEmailNotFound occurs when no users have the specified email.
	ErrEmailNotFound = errs.Class("email not found")

	// ErrNoAPIKey is error type that occurs when there is no api key found.
	ErrNoAPIKey = errs.Class("no api key found")

	// ErrAPIKeyRequest is returned when there is an error parsing a request for api keys.
	ErrAPIKeyRequest = errs.Class("api key request")

	// ErrRegToken describes registration token errors.
	ErrRegToken = errs.Class("registration token")

	// ErrCaptcha describes captcha validation errors.
	ErrCaptcha = errs.Class("captcha validation")

	// ErrRecoveryToken describes account recovery token errors.
	ErrRecoveryToken = errs.Class("recovery token")
)
View Source
var ErrValidation = errs.Class("validation")

ErrValidation validation related error class.

View Source
var ErrWalletNotClaimed = errs.Class("wallet is not claimed")

ErrWalletNotClaimed shows that no address is claimed by the user.

Functions

func EtherscanURL added in v1.62.1

func EtherscanURL(tx string) string

EtherscanURL creates etherscan transaction URI.

func GetRequest added in v1.12.3

func GetRequest(ctx context.Context) *http.Request

GetRequest gets *http.Request from context.

func NewMFAPasscode added in v1.36.1

func NewMFAPasscode(secretKey string, t time.Time) (string, error)

NewMFAPasscode derives a TOTP passcode from a secret key using a timestamp.

func NewMFARecoveryCode added in v1.36.1

func NewMFARecoveryCode() (string, error)

NewMFARecoveryCode returns a randomly generated MFA recovery code. Recovery codes are uppercase and alphanumeric. They are of the form XXXX-XXXX-XXXX.

func NewMFASecretKey added in v1.36.1

func NewMFASecretKey() (string, error)

NewMFASecretKey generates a new TOTP secret key.

func NewMFAValidationOpts added in v1.36.1

func NewMFAValidationOpts() totp.ValidateOpts

NewMFAValidationOpts returns the options used to validate TOTP passcodes. These settings are also used to generate MFA secret keys for use in testing.

func ValidateFullName added in v0.27.0

func ValidateFullName(name string) error

ValidateFullName validates full name. It returns an plain error (not wrapped in a errs.Class) if name is invalid.

func ValidateMFAPasscode added in v1.36.1

func ValidateMFAPasscode(passcode string, secretKey string, t time.Time) (bool, error)

ValidateMFAPasscode returns whether the TOTP passcode is valid for the secret key at the given time.

func ValidateNameAndDescription added in v1.13.1

func ValidateNameAndDescription(name string, description string) error

ValidateNameAndDescription validates project name and description strings. Project name must have more than 0 and less than 21 symbols. Project description can't have more than hundred symbols.

func ValidatePassword added in v0.27.0

func ValidatePassword(pass string) error

ValidatePassword validates password. It returns an plain error (not wrapped in a errs.Class) if pass is invalid.

func WithRequest added in v1.12.3

func WithRequest(ctx context.Context, req *http.Request) context.Context

WithRequest creates new context with *http.Request.

func WithUser added in v1.58.1

func WithUser(ctx context.Context, user *User) context.Context

WithUser creates new context with User.

Types

type APIKeyCursor added in v0.21.0

type APIKeyCursor struct {
	Search         string         `json:"search"`
	Limit          uint           `json:"limit"`
	Page           uint           `json:"page"`
	Order          APIKeyOrder    `json:"order"`
	OrderDirection OrderDirection `json:"orderDirection"`
}

APIKeyCursor holds info for api keys cursor pagination.

type APIKeyInfo

type APIKeyInfo struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"projectId"`
	PartnerID uuid.UUID `json:"partnerId"`
	UserAgent []byte    `json:"userAgent"`
	Name      string    `json:"name"`
	Head      []byte    `json:"-"`
	Secret    []byte    `json:"-"`
	CreatedAt time.Time `json:"createdAt"`
}

APIKeyInfo describing api key model in the database.

type APIKeyOrder added in v0.21.0

type APIKeyOrder uint8

APIKeyOrder is used for querying api keys in specified order.

const (
	// KeyName indicates that we should order by key name.
	KeyName APIKeyOrder = 1
	// CreationDate indicates that we should order by creation date.
	CreationDate APIKeyOrder = 2
)

type APIKeyPage added in v0.21.0

type APIKeyPage struct {
	APIKeys []APIKeyInfo `json:"apiKeys"`

	Search         string         `json:"search"`
	Limit          uint           `json:"limit"`
	Order          APIKeyOrder    `json:"order"`
	OrderDirection OrderDirection `json:"orderDirection"`
	Offset         uint64         `json:"offset"`

	PageCount   uint   `json:"pageCount"`
	CurrentPage uint   `json:"currentPage"`
	TotalCount  uint64 `json:"totalCount"`
}

APIKeyPage represent api key page result.

type APIKeys

type APIKeys interface {
	// GetPagedByProjectID is a method for querying API keys from the database by projectID and cursor
	GetPagedByProjectID(ctx context.Context, projectID uuid.UUID, cursor APIKeyCursor) (akp *APIKeyPage, err error)
	// Get retrieves APIKeyInfo with given ID
	Get(ctx context.Context, id uuid.UUID) (*APIKeyInfo, error)
	// GetByHead retrieves APIKeyInfo for given key head
	GetByHead(ctx context.Context, head []byte) (*APIKeyInfo, error)
	// GetByNameAndProjectID retrieves APIKeyInfo for given key name and projectID
	GetByNameAndProjectID(ctx context.Context, name string, projectID uuid.UUID) (*APIKeyInfo, error)
	// Create creates and stores new APIKeyInfo
	Create(ctx context.Context, head []byte, info APIKeyInfo) (*APIKeyInfo, error)
	// Update updates APIKeyInfo in store
	Update(ctx context.Context, key APIKeyInfo) error
	// Delete deletes APIKeyInfo from store
	Delete(ctx context.Context, id uuid.UUID) error
}

APIKeys is interface for working with api keys store.

architecture: Database

type AccountActivationEmail added in v1.62.1

type AccountActivationEmail struct {
	Origin                string
	ActivationLink        string
	ContactInfoURL        string
	TermsAndConditionsURL string
	UserName              string
}

AccountActivationEmail is mailservice template with activation data.

func (*AccountActivationEmail) Subject added in v1.62.1

func (*AccountActivationEmail) Subject() string

Subject gets email subject.

func (*AccountActivationEmail) Template added in v1.62.1

func (*AccountActivationEmail) Template() string

Template returns email template name.

type AccountAlreadyExistsEmail added in v1.62.1

type AccountAlreadyExistsEmail struct {
	Origin            string
	SatelliteName     string
	SignInLink        string
	ResetPasswordLink string
	CreateAccountLink string
}

AccountAlreadyExistsEmail is mailservice template for email where user tries to create account, but one already exists.

func (*AccountAlreadyExistsEmail) Subject added in v1.62.1

func (*AccountAlreadyExistsEmail) Subject() string

Subject gets email subject.

func (*AccountAlreadyExistsEmail) Template added in v1.62.1

func (*AccountAlreadyExistsEmail) Template() string

Template returns email template name.

type AuthUser added in v1.36.1

type AuthUser struct {
	Email           string `json:"email"`
	Password        string `json:"password"`
	MFAPasscode     string `json:"mfaPasscode"`
	MFARecoveryCode string `json:"mfaRecoveryCode"`
	CaptchaResponse string `json:"captchaResponse"`
	IP              string `json:"-"`
	UserAgent       string `json:"-"`
}

AuthUser holds info for user authentication token requests.

type BandwidthLimitConfig added in v1.34.1

type BandwidthLimitConfig struct {
	Free memory.Size `help:"the default free-tier bandwidth usage limit" default:"150.00GB" testDefault:"25.00 GB"`
	Paid memory.Size `help:"the default paid-tier bandwidth usage limit" default:"100.00TB" testDefault:"25.00 GB"`
}

BandwidthLimitConfig is a configuration struct for default bandwidth per-project usage limits.

type BillingHistoryItem added in v0.25.0

type BillingHistoryItem struct {
	ID          string                 `json:"id"`
	Description string                 `json:"description"`
	Amount      int64                  `json:"amount"`
	Remaining   int64                  `json:"remaining"`
	Received    int64                  `json:"received"`
	Status      string                 `json:"status"`
	Link        string                 `json:"link"`
	Start       time.Time              `json:"start"`
	End         time.Time              `json:"end"`
	Type        BillingHistoryItemType `json:"type"`
}

BillingHistoryItem holds all public information about billing history line.

type BillingHistoryItemType added in v0.25.0

type BillingHistoryItemType int

BillingHistoryItemType indicates type of billing history item.

const (
	// Invoice is a Stripe invoice billing item.
	Invoice BillingHistoryItemType = 0
	// Transaction is a Coinpayments transaction billing item.
	Transaction BillingHistoryItemType = 1
	// Charge is a credit card charge billing item.
	Charge BillingHistoryItemType = 2
	// Coupon is an entity that adds some funds to Accounts balance for some fixed period.
	Coupon BillingHistoryItemType = 3
	// DepositBonus is an entity that adds some funds to Accounts balance after deposit with storj coins.
	DepositBonus BillingHistoryItemType = 4
)

type CaptchaConfig added in v1.62.1

type CaptchaConfig struct {
	Login        MultiCaptchaConfig
	Registration MultiCaptchaConfig
}

CaptchaConfig contains configurations for login/registration captcha system.

type CaptchaHandler added in v1.56.1

type CaptchaHandler interface {
	Verify(ctx context.Context, responseToken string, userIP string) (bool, *float64, error)
}

CaptchaHandler is responsible for contacting a captcha API and returning whether the user response characterized by the given response token and IP is valid.

func NewDefaultCaptcha added in v1.56.1

func NewDefaultCaptcha(kind CaptchaType, secretKey string) CaptchaHandler

NewDefaultCaptcha returns a captcha handler that contacts a reCAPTCHA or hCaptcha API.

type CaptchaType added in v1.56.1

type CaptchaType int

CaptchaType is a type of captcha.

const (
	// Recaptcha is the type for reCAPTCHA.
	Recaptcha CaptchaType = iota
	// Hcaptcha is the type for hCaptcha.
	Hcaptcha
)

type Config added in v0.34.8

type Config struct {
	PasswordCost                int           `help:"password hashing cost (0=automatic)" testDefault:"4" default:"0"`
	OpenRegistrationEnabled     bool          `help:"enable open registration" default:"false" testDefault:"true"`
	DefaultProjectLimit         int           `help:"default project limits for users" default:"1" testDefault:"5"`
	AsOfSystemTimeDuration      time.Duration `help:"default duration for AS OF SYSTEM TIME" devDefault:"-5m" releaseDefault:"-5m" testDefault:"0"`
	LoginAttemptsWithoutPenalty int           `help:"number of times user can try to login without penalty" default:"3"`
	FailedLoginPenalty          float64       `help:"incremental duration of penalty for failed login attempts in minutes" default:"2.0"`
	UsageLimits                 UsageLimitsConfig
	Captcha                     CaptchaConfig
	Session                     SessionConfig
}

Config keeps track of core console service configuration parameters.

type CreateAPIKeyRequest added in v1.57.1

type CreateAPIKeyRequest struct {
	ProjectID string `json:"projectID"`
	Name      string `json:"name"`
}

CreateAPIKeyRequest holds create API key info.

type CreateAPIKeyResponse added in v1.57.1

type CreateAPIKeyResponse struct {
	Key     string      `json:"key"`
	KeyInfo *APIKeyInfo `json:"keyInfo"`
}

CreateAPIKeyResponse holds macaroon.APIKey and APIKeyInfo.

type CreateUser

type CreateUser struct {
	FullName         string `json:"fullName"`
	ShortName        string `json:"shortName"`
	Email            string `json:"email"`
	PartnerID        string `json:"partnerId"`
	UserAgent        []byte `json:"userAgent"`
	Password         string `json:"password"`
	IsProfessional   bool   `json:"isProfessional"`
	Position         string `json:"position"`
	CompanyName      string `json:"companyName"`
	WorkingOn        string `json:"workingOn"`
	EmployeeCount    string `json:"employeeCount"`
	HaveSalesContact bool   `json:"haveSalesContact"`
	CaptchaResponse  string `json:"captchaResponse"`
	IP               string `json:"ip"`
	SignupPromoCode  string `json:"signupPromoCode"`
}

CreateUser struct holds info for User creation.

func (*CreateUser) IsValid

func (user *CreateUser) IsValid() error

IsValid checks CreateUser validity and returns error describing whats wrong. The returned error has the class ErrValiation.

type DB

type DB interface {
	// Users is a getter for Users repository.
	Users() Users
	// Projects is a getter for Projects repository.
	Projects() Projects
	// ProjectMembers is a getter for ProjectMembers repository.
	ProjectMembers() ProjectMembers
	// APIKeys is a getter for APIKeys repository.
	APIKeys() APIKeys
	// RegistrationTokens is a getter for RegistrationTokens repository.
	RegistrationTokens() RegistrationTokens
	// ResetPasswordTokens is a getter for ResetPasswordTokens repository.
	ResetPasswordTokens() ResetPasswordTokens
	// WebappSessions is a getter for WebappSessions repository.
	WebappSessions() consoleauth.WebappSessions

	// WithTx is a method for executing transactions with retrying as necessary.
	WithTx(ctx context.Context, fn func(ctx context.Context, tx DBTx) error) error
}

DB contains access to different satellite databases.

architecture: Database

type DBTx

type DBTx interface {
	DB
	// Commit is a method for committing and closing transaction.
	Commit() error
	// Rollback is a method for rollback and closing transaction.
	Rollback() error
}

DBTx extends Database with transaction scope.

type ForgotPasswordEmail added in v1.62.1

type ForgotPasswordEmail struct {
	Origin                     string
	UserName                   string
	ResetLink                  string
	CancelPasswordRecoveryLink string
	LetUsKnowURL               string
	ContactInfoURL             string
	TermsAndConditionsURL      string
}

ForgotPasswordEmail is mailservice template with reset password data.

func (*ForgotPasswordEmail) Subject added in v1.62.1

func (*ForgotPasswordEmail) Subject() string

Subject gets email subject.

func (*ForgotPasswordEmail) Template added in v1.62.1

func (*ForgotPasswordEmail) Template() string

Template returns email template name.

type LockAccountEmail added in v1.62.1

type LockAccountEmail struct {
	Name              string
	LockoutDuration   time.Duration
	ResetPasswordLink string
}

LockAccountEmail is mailservice template with lock account data.

func (*LockAccountEmail) Subject added in v1.62.1

func (*LockAccountEmail) Subject() string

Subject gets email subject.

func (*LockAccountEmail) Template added in v1.62.1

func (*LockAccountEmail) Template() string

Template returns email template name.

type MultiCaptchaConfig added in v1.62.1

type MultiCaptchaConfig struct {
	Recaptcha SingleCaptchaConfig
	Hcaptcha  SingleCaptchaConfig
}

MultiCaptchaConfig contains configurations for Recaptcha and Hcaptcha systems.

type OrderDirection added in v0.21.0

type OrderDirection uint8

OrderDirection is used for members in specific order direction.

const (
	// Ascending indicates that we should order ascending.
	Ascending OrderDirection = 1
	// Descending indicates that we should order descending.
	Descending OrderDirection = 2
)

type PaymentInfo added in v1.62.1

type PaymentInfo struct {
	ID        string
	Type      string
	Wallet    string
	Amount    currency.Amount
	Received  currency.Amount
	Status    string
	Link      string
	Timestamp time.Time
}

PaymentInfo includes token payment information required by GUI.

type Payments added in v1.57.1

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

Payments separates all payment related functionality.

func (Payments) AccountBalance added in v1.57.1

func (payment Payments) AccountBalance(ctx context.Context) (balance payments.Balance, err error)

AccountBalance return account balance.

func (Payments) AddCreditCard added in v1.57.1

func (payment Payments) AddCreditCard(ctx context.Context, creditCardToken string) (err error)

AddCreditCard is used to save new credit card and attach it to payment account.

func (Payments) ApplyCouponCode added in v1.57.1

func (payment Payments) ApplyCouponCode(ctx context.Context, couponCode string) (coupon *payments.Coupon, err error)

ApplyCouponCode applies a coupon code to a Stripe customer and returns the coupon corresponding to the code.

func (Payments) BillingHistory added in v1.57.1

func (payment Payments) BillingHistory(ctx context.Context) (billingHistory []*BillingHistoryItem, err error)

BillingHistory returns a list of billing history items for payment account.

func (Payments) ClaimWallet added in v1.57.1

func (payment Payments) ClaimWallet(ctx context.Context) (_ WalletInfo, err error)

ClaimWallet requests a new wallet for the users to be used for payments. If wallet is already claimed, it will return with the info without error.

func (Payments) GetCoupon added in v1.57.1

func (payment Payments) GetCoupon(ctx context.Context) (coupon *payments.Coupon, err error)

GetCoupon returns the coupon applied to the user's account.

func (Payments) GetWallet added in v1.57.1

func (payment Payments) GetWallet(ctx context.Context) (_ WalletInfo, err error)

GetWallet returns with the assigned wallet, or with ErrWalletNotClaimed if not yet claimed.

func (Payments) ListCreditCards added in v1.57.1

func (payment Payments) ListCreditCards(ctx context.Context) (_ []payments.CreditCard, err error)

ListCreditCards returns a list of credit cards for a given payment account.

func (Payments) MakeCreditCardDefault added in v1.57.1

func (payment Payments) MakeCreditCardDefault(ctx context.Context, cardID string) (err error)

MakeCreditCardDefault makes a credit card default payment method.

func (Payments) ProjectsCharges added in v1.57.1

func (payment Payments) ProjectsCharges(ctx context.Context, since, before time.Time) (_ []payments.ProjectCharge, err error)

ProjectsCharges returns how much money current user will be charged for each project which he owns.

func (Payments) RemoveCreditCard added in v1.57.1

func (payment Payments) RemoveCreditCard(ctx context.Context, cardID string) (err error)

RemoveCreditCard is used to detach a credit card from payment account.

func (Payments) SetupAccount added in v1.57.1

func (payment Payments) SetupAccount(ctx context.Context) (_ payments.CouponType, err error)

SetupAccount creates payment account for authorized user.

func (Payments) WalletPayments added in v1.62.1

func (payment Payments) WalletPayments(ctx context.Context) (_ WalletPayments, err error)

WalletPayments returns with all the native blockchain payments for a user's wallet.

type Project

type Project struct {
	ID       uuid.UUID `json:"id"`
	PublicID uuid.UUID `json:"publicId"`

	Name           string       `json:"name"`
	Description    string       `json:"description"`
	PartnerID      uuid.UUID    `json:"partnerId"`
	UserAgent      []byte       `json:"userAgent"`
	OwnerID        uuid.UUID    `json:"ownerId"`
	RateLimit      *int         `json:"rateLimit"`
	BurstLimit     *int         `json:"burstLimit"`
	MaxBuckets     *int         `json:"maxBuckets"`
	CreatedAt      time.Time    `json:"createdAt"`
	MemberCount    int          `json:"memberCount"`
	StorageLimit   *memory.Size `json:"storageLimit"`
	BandwidthLimit *memory.Size `json:"bandwidthLimit"`
	SegmentLimit   *int64       `json:"segmentLimit"`
}

Project is a database object that describes Project entity.

type ProjectInfo

type ProjectInfo struct {
	Name           string      `json:"name"`
	Description    string      `json:"description"`
	StorageLimit   memory.Size `json:"storageLimit"`
	BandwidthLimit memory.Size `json:"bandwidthLimit"`
	CreatedAt      time.Time   `json:"createdAt"`
}

ProjectInfo holds data needed to create/update Project.

type ProjectInvitationEmail added in v1.62.1

type ProjectInvitationEmail struct {
	Origin                string
	UserName              string
	ProjectName           string
	SignInLink            string
	LetUsKnowURL          string
	ContactInfoURL        string
	TermsAndConditionsURL string
}

ProjectInvitationEmail is mailservice template for project invitation email.

func (*ProjectInvitationEmail) Subject added in v1.62.1

func (email *ProjectInvitationEmail) Subject() string

Subject gets email subject.

func (*ProjectInvitationEmail) Template added in v1.62.1

func (*ProjectInvitationEmail) Template() string

Template returns email template name.

type ProjectLimitConfig added in v1.51.1

type ProjectLimitConfig struct {
	Free int `help:"the default free-tier project limit" default:"1"`
	Paid int `help:"the default paid-tier project limit" default:"3"`
}

ProjectLimitConfig is a configuration struct for default project limits.

type ProjectLimits added in v1.43.1

type ProjectLimits struct {
	ProjectBandwidthLimit memory.Size `json:"projectBandwidthLimit"`
	ProjectStorageLimit   memory.Size `json:"projectStorageLimit"`
	ProjectSegmentLimit   int64       `json:"projectSegmentLimit"`
}

ProjectLimits holds info for a users bandwidth and storage limits for new projects.

type ProjectMember

type ProjectMember struct {
	// FK on Users table.
	MemberID uuid.UUID
	// FK on Projects table.
	ProjectID uuid.UUID

	CreatedAt time.Time
}

ProjectMember is a database object that describes ProjectMember entity.

type ProjectMemberOrder

type ProjectMemberOrder int8

ProjectMemberOrder is used for querying project members in specified order.

const (
	// Name indicates that we should order by full name.
	Name ProjectMemberOrder = 1
	// Email indicates that we should order by email.
	Email ProjectMemberOrder = 2
	// Created indicates that we should order by created date.
	Created ProjectMemberOrder = 3
)

type ProjectMembers

type ProjectMembers interface {
	// GetByMemberID is a method for querying project members from the database by memberID.
	GetByMemberID(ctx context.Context, memberID uuid.UUID) ([]ProjectMember, error)
	// GetPagedByProjectID is a method for querying project members from the database by projectID and cursor
	GetPagedByProjectID(ctx context.Context, projectID uuid.UUID, cursor ProjectMembersCursor) (*ProjectMembersPage, error)
	// Insert is a method for inserting project member into the database.
	Insert(ctx context.Context, memberID, projectID uuid.UUID) (*ProjectMember, error)
	// Delete is a method for deleting project member by memberID and projectID from the database.
	Delete(ctx context.Context, memberID, projectID uuid.UUID) error
}

ProjectMembers exposes methods to manage ProjectMembers table in database.

architecture: Database

type ProjectMembersCursor added in v0.17.0

type ProjectMembersCursor struct {
	Search         string
	Limit          uint
	Page           uint
	Order          ProjectMemberOrder
	OrderDirection OrderDirection
}

ProjectMembersCursor holds info for project members cursor pagination.

type ProjectMembersPage added in v0.17.0

type ProjectMembersPage struct {
	ProjectMembers []ProjectMember

	Search         string
	Limit          uint
	Order          ProjectMemberOrder
	OrderDirection OrderDirection
	Offset         uint64

	PageCount   uint
	CurrentPage uint
	TotalCount  uint64
}

ProjectMembersPage represent project members page result.

type ProjectUsageLimits added in v0.28.0

type ProjectUsageLimits struct {
	StorageLimit   int64 `json:"storageLimit"`
	BandwidthLimit int64 `json:"bandwidthLimit"`
	StorageUsed    int64 `json:"storageUsed"`
	BandwidthUsed  int64 `json:"bandwidthUsed"`
	ObjectCount    int64 `json:"objectCount"`
	SegmentCount   int64 `json:"segmentCount"`
}

ProjectUsageLimits holds project usage limits and current usage.

type Projects

type Projects interface {
	// GetAll is a method for querying all projects from the database.
	GetAll(ctx context.Context) ([]Project, error)
	// GetCreatedBefore retrieves all projects created before provided date.
	GetCreatedBefore(ctx context.Context, before time.Time) ([]Project, error)
	// GetByUserID returns a list of projects where user is a project member.
	GetByUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
	// GetOwn returns a list of projects where user is an owner.
	GetOwn(ctx context.Context, userID uuid.UUID) ([]Project, error)
	// Get is a method for querying project from the database by id.
	Get(ctx context.Context, id uuid.UUID) (*Project, error)
	// GetSalt returns the project's salt.
	GetSalt(ctx context.Context, id uuid.UUID) ([]byte, error)
	// GetByPublicID is a method for querying project from the database by public_id.
	GetByPublicID(ctx context.Context, publicID uuid.UUID) (*Project, error)
	// Insert is a method for inserting project into the database.
	Insert(ctx context.Context, project *Project) (*Project, error)
	// Delete is a method for deleting project by Id from the database.
	Delete(ctx context.Context, id uuid.UUID) error
	// Update is a method for updating project entity.
	Update(ctx context.Context, project *Project) error
	// List returns paginated projects, created before provided timestamp.
	List(ctx context.Context, offset int64, limit int, before time.Time) (ProjectsPage, error)
	// ListByOwnerID is a method for querying all projects from the database by ownerID. It also includes the number of members for each project.
	ListByOwnerID(ctx context.Context, userID uuid.UUID, cursor ProjectsCursor) (ProjectsPage, error)

	// UpdateRateLimit is a method for updating projects rate limit.
	UpdateRateLimit(ctx context.Context, id uuid.UUID, newLimit int) error

	// UpdateBurstLimit is a method for updating projects burst limit.
	UpdateBurstLimit(ctx context.Context, id uuid.UUID, newLimit int) error

	// GetMaxBuckets is a method to get the maximum number of buckets allowed for the project
	GetMaxBuckets(ctx context.Context, id uuid.UUID) (*int, error)
	// UpdateBucketLimit is a method for updating projects bucket limit.
	UpdateBucketLimit(ctx context.Context, id uuid.UUID, newLimit int) error
}

Projects exposes methods to manage Project table in database.

architecture: Database

type ProjectsCursor added in v1.21.1

type ProjectsCursor struct {
	Limit int
	Page  int
}

ProjectsCursor holds info for project cursor pagination.

type ProjectsPage added in v0.25.0

type ProjectsPage struct {
	Projects   []Project
	Next       bool
	NextOffset int64

	Limit  int
	Offset int64

	PageCount   int
	CurrentPage int
	TotalCount  int64
}

ProjectsPage returns paginated projects, providing next offset if there are more projects to retrieve.

type RESTKeys added in v1.54.1

type RESTKeys interface {
	Create(ctx context.Context, userID uuid.UUID, expiration time.Duration) (apiKey string, expiresAt time.Time, err error)
	GetUserAndExpirationFromKey(ctx context.Context, apiKey string) (userID uuid.UUID, exp time.Time, err error)
	Revoke(ctx context.Context, apiKey string) (err error)
}

RESTKeys is an interface for rest key operations.

type RegistrationSecret

type RegistrationSecret [32]byte

RegistrationSecret stores secret of registration token.

func NewRegistrationSecret

func NewRegistrationSecret() (RegistrationSecret, error)

NewRegistrationSecret creates new registration secret.

func RegistrationSecretFromBase64

func RegistrationSecretFromBase64(s string) (RegistrationSecret, error)

RegistrationSecretFromBase64 creates new registration secret from base64 string.

func (RegistrationSecret) IsZero added in v0.34.8

func (secret RegistrationSecret) IsZero() bool

IsZero returns if the RegistrationSecret is not set.

func (RegistrationSecret) String

func (secret RegistrationSecret) String() string

String implements Stringer.

type RegistrationToken

type RegistrationToken struct {
	// Secret is PK of the table and keeps unique value forRegToken
	Secret RegistrationSecret
	// OwnerID stores current token owner ID
	OwnerID *uuid.UUID

	// ProjectLimit defines how many projects user is able to create
	ProjectLimit int `json:"projectLimit"`

	CreatedAt time.Time `json:"createdAt"`
}

RegistrationToken describing api key model in the database.

type RegistrationTokens

type RegistrationTokens interface {
	// Create creates new registration token
	Create(ctx context.Context, projectLimit int) (*RegistrationToken, error)
	// GetBySecret retrieves RegTokenInfo with given Secret
	GetBySecret(ctx context.Context, secret RegistrationSecret) (*RegistrationToken, error)
	// GetByOwnerID retrieves RegTokenInfo by ownerID
	GetByOwnerID(ctx context.Context, ownerID uuid.UUID) (*RegistrationToken, error)
	// UpdateOwner updates registration token's owner
	UpdateOwner(ctx context.Context, secret RegistrationSecret, ownerID uuid.UUID) error
}

RegistrationTokens is interface for working with registration tokens.

architecture: Database

type ResetPasswordSecret added in v0.12.0

type ResetPasswordSecret [32]byte

ResetPasswordSecret stores secret of registration token.

func NewResetPasswordSecret added in v0.12.0

func NewResetPasswordSecret() (ResetPasswordSecret, error)

NewResetPasswordSecret creates new reset password secret.

func ResetPasswordSecretFromBase64 added in v0.12.0

func ResetPasswordSecretFromBase64(s string) (ResetPasswordSecret, error)

ResetPasswordSecretFromBase64 creates new reset password secret from base64 string.

func (ResetPasswordSecret) String added in v0.12.0

func (secret ResetPasswordSecret) String() string

String implements Stringer.

type ResetPasswordToken added in v0.12.0

type ResetPasswordToken struct {
	// Secret is PK of the table and keeps unique value for reset password token
	Secret ResetPasswordSecret
	// OwnerID stores current token owner ID
	OwnerID *uuid.UUID

	CreatedAt time.Time `json:"createdAt"`
}

ResetPasswordToken describing reset password model in the database.

type ResetPasswordTokens added in v0.12.0

type ResetPasswordTokens interface {
	// Create creates new reset password token
	Create(ctx context.Context, ownerID uuid.UUID) (*ResetPasswordToken, error)
	// GetBySecret retrieves ResetPasswordToken with given secret
	GetBySecret(ctx context.Context, secret ResetPasswordSecret) (*ResetPasswordToken, error)
	// GetByOwnerID retrieves ResetPasswordToken by ownerID
	GetByOwnerID(ctx context.Context, ownerID uuid.UUID) (*ResetPasswordToken, error)
	// Delete deletes ResetPasswordToken by ResetPasswordSecret
	Delete(ctx context.Context, secret ResetPasswordSecret) error
}

ResetPasswordTokens is interface for working with reset password tokens.

architecture: Database

type ResponseUser added in v1.57.1

type ResponseUser struct {
	ID                   uuid.UUID `json:"id"`
	FullName             string    `json:"fullName"`
	ShortName            string    `json:"shortName"`
	Email                string    `json:"email"`
	PartnerID            uuid.UUID `json:"partnerId"`
	UserAgent            []byte    `json:"userAgent"`
	ProjectLimit         int       `json:"projectLimit"`
	IsProfessional       bool      `json:"isProfessional"`
	Position             string    `json:"position"`
	CompanyName          string    `json:"companyName"`
	EmployeeCount        string    `json:"employeeCount"`
	HaveSalesContact     bool      `json:"haveSalesContact"`
	PaidTier             bool      `json:"paidTier"`
	MFAEnabled           bool      `json:"isMFAEnabled"`
	MFARecoveryCodeCount int       `json:"mfaRecoveryCodeCount"`
}

ResponseUser is an entity which describes db User and can be sent in response.

type Satellites added in v1.60.1

type Satellites []satellite

Satellites is a configuration value that contains a list of satellite names and addresses. Format should be [{"name": "","address": ""],{"name": "","address": ""},...] in valid JSON format.

Can be used as a flag.

func (*Satellites) Set added in v1.60.1

func (sl *Satellites) Set(s string) (err error)

Set does validation on the configured JSON.

func (*Satellites) String added in v1.60.1

func (sl *Satellites) String() string

String is required for pflag.Value.

func (Satellites) Type added in v1.60.1

func (Satellites) Type() string

Type implements pflag.Value.

type SegmentLimitConfig added in v1.46.3

type SegmentLimitConfig struct {
	Free int64 `help:"the default free-tier segment usage limit" default:"150000"`
	Paid int64 `help:"the default paid-tier segment usage limit" default:"100000000"`
}

SegmentLimitConfig is a configuration struct for default segments per-project usage limits.

type Service

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

Service is handling accounts related logic.

architecture: Service

func NewService

func NewService(log *zap.Logger, store DB, restKeys RESTKeys, projectAccounting accounting.ProjectAccounting, projectUsage *accounting.Service, buckets buckets.DB, partners *rewards.PartnersService, accounts payments.Accounts, depositWallets payments.DepositWallets, billing billing.TransactionsDB, analytics *analytics.Service, tokens *consoleauth.Service, mailService *mailservice.Service, satelliteAddress string, config Config) (*Service, error)

NewService returns new instance of Service.

func (*Service) ActivateAccount

func (s *Service) ActivateAccount(ctx context.Context, activationToken string) (user *User, err error)

ActivateAccount - is a method for activating user account after registration.

func (*Service) AddProjectMembers

func (s *Service) AddProjectMembers(ctx context.Context, projectID uuid.UUID, emails []string) (users []*User, err error)

AddProjectMembers adds users by email to given project. Email addresses not belonging to a user are ignored.

func (*Service) ChangeEmail added in v1.17.1

func (s *Service) ChangeEmail(ctx context.Context, newEmail string) (err error)

ChangeEmail updates email for a given user.

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, pass, newPass string) (err error)

ChangePassword updates password for a given user.

func (*Service) CreateAPIKey

func (s *Service) CreateAPIKey(ctx context.Context, projectID uuid.UUID, name string) (_ *APIKeyInfo, _ *macaroon.APIKey, err error)

CreateAPIKey creates new api key.

func (*Service) CreateProject

func (s *Service) CreateProject(ctx context.Context, projectInfo ProjectInfo) (p *Project, err error)

CreateProject is a method for creating new project.

func (*Service) CreateRESTKey added in v1.54.1

func (s *Service) CreateRESTKey(ctx context.Context, expiration time.Duration) (apiKey string, expiresAt time.Time, err error)

CreateRESTKey creates a satellite rest key.

func (*Service) CreateRegToken

func (s *Service) CreateRegToken(ctx context.Context, projLimit int) (_ *RegistrationToken, err error)

CreateRegToken creates new registration token. Needed for testing.

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, user CreateUser, tokenSecret RegistrationSecret) (u *User, err error)

CreateUser gets password hash value and creates new inactive User.

func (*Service) DeleteAPIKeyByNameAndProjectID added in v1.26.2

func (s *Service) DeleteAPIKeyByNameAndProjectID(ctx context.Context, name string, projectID uuid.UUID) (err error)

DeleteAPIKeyByNameAndProjectID deletes api key by name and project ID.

func (*Service) DeleteAPIKeys

func (s *Service) DeleteAPIKeys(ctx context.Context, ids []uuid.UUID) (err error)

DeleteAPIKeys deletes api key by id.

func (*Service) DeleteAccount

func (s *Service) DeleteAccount(ctx context.Context, password string) (err error)

DeleteAccount deletes User.

func (*Service) DeleteProject

func (s *Service) DeleteProject(ctx context.Context, projectID uuid.UUID) (err error)

DeleteProject is a method for deleting project by id.

func (*Service) DeleteProjectMembers

func (s *Service) DeleteProjectMembers(ctx context.Context, projectID uuid.UUID, emails []string) (err error)

DeleteProjectMembers removes users by email from given project.

func (*Service) DeleteSession added in v1.63.1

func (s *Service) DeleteSession(ctx context.Context, sessionID uuid.UUID) (err error)

DeleteSession removes the session from the database.

func (*Service) DisableUserMFA added in v1.36.1

func (s *Service) DisableUserMFA(ctx context.Context, passcode string, t time.Time, recoveryCode string) (err error)

DisableUserMFA disables multi-factor authentication for the user if the given secret key and password are valid.

func (*Service) EnableUserMFA added in v1.36.1

func (s *Service) EnableUserMFA(ctx context.Context, passcode string, t time.Time) (err error)

EnableUserMFA enables multi-factor authentication for the user if the given secret key and password are valid.

func (*Service) GenCreateAPIKey added in v1.57.1

func (s *Service) GenCreateAPIKey(ctx context.Context, requestInfo CreateAPIKeyRequest) (*CreateAPIKeyResponse, api.HTTPError)

GenCreateAPIKey creates new api key for generated api.

func (*Service) GenCreateProject added in v1.53.1

func (s *Service) GenCreateProject(ctx context.Context, projectInfo ProjectInfo) (p *Project, httpError api.HTTPError)

GenCreateProject is a method for creating new project for generated api.

func (*Service) GenDeleteAPIKey added in v1.64.1

func (s *Service) GenDeleteAPIKey(ctx context.Context, keyID uuid.UUID) (httpError api.HTTPError)

GenDeleteAPIKey deletes api key for generated api.

func (*Service) GenDeleteProject added in v1.57.1

func (s *Service) GenDeleteProject(ctx context.Context, projectID uuid.UUID) (httpError api.HTTPError)

GenDeleteProject is a method for deleting project by id for generated API.

func (*Service) GenGetAPIKeys added in v1.64.1

func (s *Service) GenGetAPIKeys(ctx context.Context, projectID uuid.UUID, search string, limit, page uint, order APIKeyOrder, orderDirection OrderDirection) (*APIKeyPage, api.HTTPError)

GenGetAPIKeys returns api keys belonging to a project for generated api.

func (*Service) GenGetBucketUsageRollups added in v1.52.1

func (s *Service) GenGetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) (rollups []accounting.BucketUsageRollup, httpError api.HTTPError)

GenGetBucketUsageRollups retrieves summed usage rollups for every bucket of particular project for a given period for generated api.

func (*Service) GenGetSingleBucketUsageRollup added in v1.51.1

func (s *Service) GenGetSingleBucketUsageRollup(ctx context.Context, projectID uuid.UUID, bucket string, since, before time.Time) (rollup *accounting.BucketUsageRollup, httpError api.HTTPError)

GenGetSingleBucketUsageRollup retrieves usage rollup for single bucket of particular project for a given period for generated api.

func (*Service) GenGetUser added in v1.57.1

func (s *Service) GenGetUser(ctx context.Context) (*ResponseUser, api.HTTPError)

GenGetUser returns ResponseUser by request context for generated api.

func (*Service) GenGetUsersProjects added in v1.51.1

func (s *Service) GenGetUsersProjects(ctx context.Context) (ps []Project, httpErr api.HTTPError)

GenGetUsersProjects is a method for querying all projects for generated api.

func (*Service) GenUpdateProject added in v1.54.1

func (s *Service) GenUpdateProject(ctx context.Context, projectID uuid.UUID, projectInfo ProjectInfo) (p *Project, httpError api.HTTPError)

GenUpdateProject is a method for updating project name and description by id for generated api.

func (*Service) GenerateActivationToken

func (s *Service) GenerateActivationToken(ctx context.Context, id uuid.UUID, email string) (token string, err error)

GenerateActivationToken - is a method for generating activation token.

func (*Service) GeneratePasswordRecoveryToken added in v0.10.0

func (s *Service) GeneratePasswordRecoveryToken(ctx context.Context, id uuid.UUID) (token string, err error)

GeneratePasswordRecoveryToken - is a method for generating password recovery token.

func (*Service) GenerateSessionToken added in v1.58.1

func (s *Service) GenerateSessionToken(ctx context.Context, userID uuid.UUID, email, ip, userAgent string) (_ *TokenInfo, err error)

GenerateSessionToken creates a new session and returns the string representation of its token.

func (*Service) GetAPIKeyInfo

func (s *Service) GetAPIKeyInfo(ctx context.Context, id uuid.UUID) (_ *APIKeyInfo, err error)

GetAPIKeyInfo retrieves api key by id.

func (*Service) GetAPIKeyInfoByName added in v1.51.1

func (s *Service) GetAPIKeyInfoByName(ctx context.Context, projectID uuid.UUID, name string) (_ *APIKeyInfo, err error)

GetAPIKeyInfoByName retrieves an api key by its name and project id.

func (*Service) GetAPIKeys added in v0.21.0

func (s *Service) GetAPIKeys(ctx context.Context, projectID uuid.UUID, cursor APIKeyCursor) (page *APIKeyPage, err error)

GetAPIKeys returns paged api key list for given Project.

func (*Service) GetAllBucketNames added in v1.18.1

func (s *Service) GetAllBucketNames(ctx context.Context, projectID uuid.UUID) (_ []string, err error)

GetAllBucketNames retrieves all bucket names of a specific project.

func (*Service) GetBucketTotals added in v0.12.0

func (s *Service) GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor accounting.BucketUsageCursor, before time.Time) (_ *accounting.BucketUsagePage, err error)

GetBucketTotals retrieves paged bucket total usages since project creation.

func (*Service) GetBucketUsageRollups added in v0.9.0

func (s *Service) GetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ []accounting.BucketUsageRollup, err error)

GetBucketUsageRollups retrieves summed usage rollups for every bucket of particular project for a given period.

func (*Service) GetDailyProjectUsage added in v1.48.1

func (s *Service) GetDailyProjectUsage(ctx context.Context, projectID uuid.UUID, from, to time.Time) (_ *accounting.ProjectDailyUsage, err error)

GetDailyProjectUsage returns daily usage by project ID.

func (*Service) GetProject

func (s *Service) GetProject(ctx context.Context, projectID uuid.UUID) (p *Project, err error)

GetProject is a method for querying project by id.

func (*Service) GetProjectMembers

func (s *Service) GetProjectMembers(ctx context.Context, projectID uuid.UUID, cursor ProjectMembersCursor) (pmp *ProjectMembersPage, err error)

GetProjectMembers returns ProjectMembers for given Project.

func (*Service) GetProjectUsage added in v0.9.0

func (s *Service) GetProjectUsage(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ *accounting.ProjectUsage, err error)

GetProjectUsage retrieves project usage for a given period.

func (*Service) GetProjectUsageLimits added in v0.28.0

func (s *Service) GetProjectUsageLimits(ctx context.Context, projectID uuid.UUID) (_ *ProjectUsageLimits, err error)

GetProjectUsageLimits returns project limits and current usage.

Among others,it can return one of the following errors returned by storj.io/storj/satellite/accounting.Service, wrapped Error.

func (*Service) GetSalt added in v1.65.1

func (s *Service) GetSalt(ctx context.Context, projectID uuid.UUID) (salt []byte, err error)

GetSalt is a method for querying project salt by id.

func (*Service) GetTotalUsageLimits added in v1.34.1

func (s *Service) GetTotalUsageLimits(ctx context.Context) (_ *ProjectUsageLimits, err error)

GetTotalUsageLimits returns total limits and current usage for all the projects.

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, id uuid.UUID) (u *User, err error)

GetUser returns User by id.

func (*Service) GetUserByEmailWithUnverified added in v1.46.3

func (s *Service) GetUserByEmailWithUnverified(ctx context.Context, email string) (verified *User, unverified []User, err error)

GetUserByEmailWithUnverified returns Users by email.

func (*Service) GetUserID added in v1.27.0

func (s *Service) GetUserID(ctx context.Context) (id uuid.UUID, err error)

GetUserID returns the User ID from the session.

func (*Service) GetUsersOwnedProjectsPage added in v1.22.1

func (s *Service) GetUsersOwnedProjectsPage(ctx context.Context, cursor ProjectsCursor) (_ ProjectsPage, err error)

GetUsersOwnedProjectsPage is a method for querying paged projects.

func (*Service) GetUsersProjects

func (s *Service) GetUsersProjects(ctx context.Context) (ps []Project, err error)

GetUsersProjects is a method for querying all projects.

func (*Service) KeyAuth added in v1.58.1

func (s *Service) KeyAuth(ctx context.Context, apikey string, authTime time.Time) (_ context.Context, err error)

KeyAuth returns an authenticated context by api key.

func (*Service) Payments added in v0.24.0

func (s *Service) Payments() Payments

Payments separates all payment related functionality.

func (*Service) RefreshSession added in v1.63.1

func (s *Service) RefreshSession(ctx context.Context, sessionID uuid.UUID) (expiresAt time.Time, err error)

RefreshSession resets the expiration time of the session.

func (*Service) ResetMFARecoveryCodes added in v1.36.1

func (s *Service) ResetMFARecoveryCodes(ctx context.Context) (codes []string, err error)

ResetMFARecoveryCodes creates a new set of MFA recovery codes for the user.

func (*Service) ResetMFASecretKey added in v1.36.1

func (s *Service) ResetMFASecretKey(ctx context.Context) (key string, err error)

ResetMFASecretKey creates a new TOTP secret key for the user.

func (*Service) ResetPassword added in v0.10.0

func (s *Service) ResetPassword(ctx context.Context, resetPasswordToken, password string, passcode string, recoveryCode string, t time.Time) (err error)

ResetPassword - is a method for resetting user password.

func (*Service) RevokeRESTKey added in v1.54.1

func (s *Service) RevokeRESTKey(ctx context.Context, apiKey string) (err error)

RevokeRESTKey revokes a satellite REST key.

func (*Service) RevokeResetPasswordToken added in v0.12.0

func (s *Service) RevokeResetPasswordToken(ctx context.Context, resetPasswordToken string) (err error)

RevokeResetPasswordToken - is a method to revoke reset password token.

func (*Service) TestSwapCaptchaHandler added in v1.56.1

func (s *Service) TestSwapCaptchaHandler(h CaptchaHandler)

TestSwapCaptchaHandler replaces the existing handler for captchas with the one specified for use in testing.

func (*Service) Token

func (s *Service) Token(ctx context.Context, request AuthUser) (response *TokenInfo, err error)

Token authenticates User by credentials and returns session token.

func (*Service) TokenAuth added in v1.58.1

func (s *Service) TokenAuth(ctx context.Context, token consoleauth.Token, authTime time.Time) (_ context.Context, err error)

TokenAuth returns an authenticated context by session token.

func (*Service) UpdateAccount

func (s *Service) UpdateAccount(ctx context.Context, fullName string, shortName string) (err error)

UpdateAccount updates User.

func (*Service) UpdateProject

func (s *Service) UpdateProject(ctx context.Context, projectID uuid.UUID, updatedProject ProjectInfo) (p *Project, err error)

UpdateProject is a method for updating project name and description by id.

func (*Service) UpdateUsersFailedLoginState added in v1.55.1

func (s *Service) UpdateUsersFailedLoginState(ctx context.Context, user *User) (err error)

UpdateUsersFailedLoginState updates User's failed login state.

func (*Service) VerifyForgotPasswordCaptcha added in v1.65.1

func (s *Service) VerifyForgotPasswordCaptcha(ctx context.Context, responseToken, userIP string) (valid bool, err error)

VerifyForgotPasswordCaptcha returns whether the given captcha response for the forgot password page is valid. It will return true without error if the captcha handler has not been set.

type SessionConfig added in v1.63.1

type SessionConfig struct {
	InactivityTimerEnabled       bool          `help:"indicates if session can be timed out due inactivity" default:"false"`
	InactivityTimerDuration      int           `help:"inactivity timer delay in seconds" default:"600"`
	InactivityTimerViewerEnabled bool          `help:"indicates whether remaining session time is shown for debugging" default:"false"`
	Duration                     time.Duration `help:"duration a session is valid for (superseded by inactivity timer delay if inactivity timer is enabled)" default:"168h"`
}

SessionConfig contains configurations for session management.

type SingleCaptchaConfig added in v1.62.1

type SingleCaptchaConfig struct {
	Enabled   bool   `help:"whether or not captcha is enabled" default:"false"`
	SiteKey   string `help:"captcha site key"`
	SecretKey string `help:"captcha secret key"`
}

SingleCaptchaConfig contains configurations abstract captcha system.

type StorageLimitConfig added in v1.34.1

type StorageLimitConfig struct {
	Free memory.Size `help:"the default free-tier storage usage limit" default:"150.00GB" testDefault:"25.00 GB"`
	Paid memory.Size `help:"the default paid-tier storage usage limit" default:"25.00TB" testDefault:"25.00 GB"`
}

StorageLimitConfig is a configuration struct for default storage per-project usage limits.

type TokenInfo added in v1.63.1

type TokenInfo struct {
	consoleauth.Token `json:"token"`
	ExpiresAt         time.Time `json:"expiresAt"`
}

TokenInfo holds info for user authentication token responses.

type UnknownResetPasswordEmail added in v1.62.1

type UnknownResetPasswordEmail struct {
	Satellite           string
	Email               string
	DoubleCheckLink     string
	ResetPasswordLink   string
	CreateAnAccountLink string
	SupportTeamLink     string
}

UnknownResetPasswordEmail is mailservice template with unknown password reset data.

func (*UnknownResetPasswordEmail) Subject added in v1.62.1

func (*UnknownResetPasswordEmail) Subject() string

Subject gets email subject.

func (*UnknownResetPasswordEmail) Template added in v1.62.1

func (*UnknownResetPasswordEmail) Template() string

Template returns email template name.

type UpdateUserRequest added in v1.58.1

type UpdateUserRequest struct {
	FullName  *string
	ShortName **string

	Email        *string
	PasswordHash []byte

	Status *UserStatus

	ProjectLimit          *int
	ProjectStorageLimit   *int64
	ProjectBandwidthLimit *int64
	ProjectSegmentLimit   *int64
	PaidTier              *bool

	MFAEnabled       *bool
	MFASecretKey     **string
	MFARecoveryCodes *[]string

	LastVerificationReminder **time.Time

	// failed_login_count is nullable, but we don't really have a reason
	// to set it to NULL, so it doesn't need to be a double pointer here.
	FailedLoginCount *int

	LoginLockoutExpiration **time.Time
}

UpdateUserRequest contains all columns which are optionally updatable by users.Update.

type UsageLimitsConfig added in v1.26.2

type UsageLimitsConfig struct {
	Storage   StorageLimitConfig
	Bandwidth BandwidthLimitConfig
	Segment   SegmentLimitConfig
	Project   ProjectLimitConfig
}

UsageLimitsConfig is a configuration struct for default per-project usage limits.

type User

type User struct {
	ID uuid.UUID `json:"id"`

	FullName  string `json:"fullName"`
	ShortName string `json:"shortName"`

	Email        string `json:"email"`
	PasswordHash []byte `json:"passwordHash"`

	Status    UserStatus `json:"status"`
	PartnerID uuid.UUID  `json:"partnerId"`
	UserAgent []byte     `json:"userAgent"`

	CreatedAt time.Time `json:"createdAt"`

	ProjectLimit          int   `json:"projectLimit"`
	ProjectStorageLimit   int64 `json:"projectStorageLimit"`
	ProjectBandwidthLimit int64 `json:"projectBandwidthLimit"`
	ProjectSegmentLimit   int64 `json:"projectSegmentLimit"`
	PaidTier              bool  `json:"paidTier"`

	IsProfessional bool   `json:"isProfessional"`
	Position       string `json:"position"`
	CompanyName    string `json:"companyName"`
	CompanySize    int    `json:"companySize"`
	WorkingOn      string `json:"workingOn"`
	EmployeeCount  string `json:"employeeCount"`

	HaveSalesContact bool `json:"haveSalesContact"`

	MFAEnabled       bool     `json:"mfaEnabled"`
	MFASecretKey     string   `json:"mfaSecretKey"`
	MFARecoveryCodes []string `json:"mfaRecoveryCodes"`

	SignupPromoCode string `json:"signupPromoCode"`

	LastVerificationReminder time.Time `json:"lastVerificationReminder"`
	VerificationReminders    int       `json:"verificationReminders"`

	FailedLoginCount       int       `json:"failedLoginCount"`
	LoginLockoutExpiration time.Time `json:"loginLockoutExpiration"`
	SignupCaptcha          *float64  `json:"-"`
}

User is a database object that describes User entity.

func GetUser added in v1.58.1

func GetUser(ctx context.Context) (*User, error)

GetUser gets User from context.

type UserInfo

type UserInfo struct {
	FullName  string `json:"fullName"`
	ShortName string `json:"shortName"`
}

UserInfo holds User updatable data.

func (*UserInfo) IsValid

func (user *UserInfo) IsValid() error

IsValid checks UserInfo validity and returns error describing whats wrong. The returned error has the class ErrValiation.

type UserProjectLimits added in v1.43.1

type UserProjectLimits struct {
	BandwidthLimit memory.Size `json:"bandwidthLimit"`
	StorageLimit   memory.Size `json:"storageUsed"`
	SegmentLimit   int64       `json:"segmentLimit"`
}

UserProjectLimits holds a users storage, bandwidth, and segment limits for new projects.

type UserStatus

type UserStatus int

UserStatus - is used to indicate status of the users account.

const (
	// Inactive is a user status that he receives after registration.
	Inactive UserStatus = 0
	// Active is a user status that he receives after account activation.
	Active UserStatus = 1
	// Deleted is a user status that he receives after deleting account.
	Deleted UserStatus = 2
)

type Users

type Users interface {
	// Get is a method for querying user from the database by id.
	Get(ctx context.Context, id uuid.UUID) (*User, error)
	// GetUnverifiedNeedingReminder gets unverified users needing a reminder to verify their email.
	GetUnverifiedNeedingReminder(ctx context.Context, firstReminder, secondReminder, cutoff time.Time) ([]*User, error)
	// UpdateVerificationReminders increments verification_reminders.
	UpdateVerificationReminders(ctx context.Context, id uuid.UUID) error
	// UpdateFailedLoginCountAndExpiration increments failed_login_count and sets login_lockout_expiration appropriately.
	UpdateFailedLoginCountAndExpiration(ctx context.Context, failedLoginPenalty *float64, id uuid.UUID) error
	// GetByEmailWithUnverified is a method for querying users by email from the database.
	GetByEmailWithUnverified(ctx context.Context, email string) (*User, []User, error)
	// GetByEmail is a method for querying user by verified email from the database.
	GetByEmail(ctx context.Context, email string) (*User, error)
	// Insert is a method for inserting user into the database.
	Insert(ctx context.Context, user *User) (*User, error)
	// Delete is a method for deleting user by Id from the database.
	Delete(ctx context.Context, id uuid.UUID) error
	// Update is a method for updating user entity.
	Update(ctx context.Context, userID uuid.UUID, request UpdateUserRequest) error
	// UpdatePaidTier sets whether the user is in the paid tier.
	UpdatePaidTier(ctx context.Context, id uuid.UUID, paidTier bool, projectBandwidthLimit, projectStorageLimit memory.Size, projectSegmentLimit int64, projectLimit int) error
	// GetProjectLimit is a method to get the users project limit
	GetProjectLimit(ctx context.Context, id uuid.UUID) (limit int, err error)
	// GetUserProjectLimits is a method to get the users storage and bandwidth limits for new projects.
	GetUserProjectLimits(ctx context.Context, id uuid.UUID) (limit *ProjectLimits, err error)
	// GetUserPaidTier is a method to gather whether the specified user is on the Paid Tier or not.
	GetUserPaidTier(ctx context.Context, id uuid.UUID) (isPaid bool, err error)
}

Users exposes methods to manage User table in database.

architecture: Database

type WalletInfo added in v1.56.1

type WalletInfo struct {
	Address blockchain.Address `json:"address"`
	Balance currency.Amount    `json:"balance"`
}

WalletInfo contains all the information about a destination wallet assigned to a user.

type WalletPayments added in v1.62.1

type WalletPayments struct {
	Payments []PaymentInfo `json:"payments"`
}

WalletPayments represents the list of ERC-20 token payments.

Jump to

Keyboard shortcuts

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