Documentation ¶
Index ¶
- Constants
- Variables
- func GetRequest(ctx context.Context) *http.Request
- func ValidateFullName(name string) error
- func ValidateNameAndDescription(name string, description string) error
- func ValidatePassword(pass string) error
- func WithAuth(ctx context.Context, auth Authorization) context.Context
- func WithAuthFailure(ctx context.Context, err error) context.Context
- func WithRequest(ctx context.Context, req *http.Request) context.Context
- type APIKeyCursor
- type APIKeyInfo
- type APIKeyOrder
- type APIKeyPage
- type APIKeys
- type Authorization
- type BillingHistoryItem
- type BillingHistoryItemType
- type Buckets
- type Config
- type CreateUser
- type DB
- type DBTx
- type OrderDirection
- type PaymentsService
- func (paymentService PaymentsService) AccountBalance(ctx context.Context) (balance payments.Balance, err error)
- func (paymentService PaymentsService) AddCreditCard(ctx context.Context, creditCardToken string) (err error)
- func (paymentService PaymentsService) AddPromotionalCoupon(ctx context.Context, userID uuid.UUID) (err error)
- func (paymentService PaymentsService) BillingHistory(ctx context.Context) (billingHistory []*BillingHistoryItem, err error)
- func (paymentService PaymentsService) ListCreditCards(ctx context.Context) (_ []payments.CreditCard, err error)
- func (paymentService PaymentsService) MakeCreditCardDefault(ctx context.Context, cardID string) (err error)
- func (paymentService PaymentsService) PopulatePromotionalCoupons(ctx context.Context) (err error)
- func (paymentService PaymentsService) ProjectsCharges(ctx context.Context, since, before time.Time) (_ []payments.ProjectCharge, err error)
- func (paymentService PaymentsService) RemoveCreditCard(ctx context.Context, cardID string) (err error)
- func (paymentService PaymentsService) SetupAccount(ctx context.Context) (err error)
- func (paymentService PaymentsService) TokenDeposit(ctx context.Context, amount int64) (_ *payments.Transaction, err error)
- type Project
- type ProjectInfo
- type ProjectMember
- type ProjectMemberOrder
- type ProjectMembers
- type ProjectMembersCursor
- type ProjectMembersPage
- type ProjectUsageLimits
- type Projects
- type ProjectsCursor
- type ProjectsPage
- type RegistrationSecret
- type RegistrationToken
- type RegistrationTokens
- type ResetPasswordSecret
- type ResetPasswordToken
- type ResetPasswordTokens
- type Service
- func (s *Service) ActivateAccount(ctx context.Context, activationToken string) (err error)
- func (s *Service) AddProjectMembers(ctx context.Context, projectID uuid.UUID, emails []string) (users []*User, err error)
- func (s *Service) Authorize(ctx context.Context) (a Authorization, err error)
- func (s *Service) ChangeEmail(ctx context.Context, newEmail string) (err error)
- func (s *Service) ChangePassword(ctx context.Context, pass, newPass string) (err error)
- func (s *Service) CreateAPIKey(ctx context.Context, projectID uuid.UUID, name string) (_ *APIKeyInfo, _ *macaroon.APIKey, err error)
- func (s *Service) CreateProject(ctx context.Context, projectInfo ProjectInfo) (p *Project, err error)
- func (s *Service) CreateRegToken(ctx context.Context, projLimit int) (_ *RegistrationToken, err error)
- func (s *Service) CreateUser(ctx context.Context, user CreateUser, tokenSecret RegistrationSecret) (u *User, err error)
- func (s *Service) DeleteAPIKeyByNameAndProjectID(ctx context.Context, name string, projectID uuid.UUID) (err error)
- func (s *Service) DeleteAPIKeys(ctx context.Context, ids []uuid.UUID) (err error)
- func (s *Service) DeleteAccount(ctx context.Context, password string) (err error)
- func (s *Service) DeleteProject(ctx context.Context, projectID uuid.UUID) (err error)
- func (s *Service) DeleteProjectMembers(ctx context.Context, projectID uuid.UUID, emails []string) (err error)
- func (s *Service) GenerateActivationToken(ctx context.Context, id uuid.UUID, email string) (token string, err error)
- func (s *Service) GeneratePasswordRecoveryToken(ctx context.Context, id uuid.UUID) (token string, err error)
- func (s *Service) GetAPIKeyInfo(ctx context.Context, id uuid.UUID) (_ *APIKeyInfo, err error)
- func (s *Service) GetAPIKeys(ctx context.Context, projectID uuid.UUID, cursor APIKeyCursor) (page *APIKeyPage, err error)
- func (s *Service) GetAllBucketNames(ctx context.Context, projectID uuid.UUID) (_ []string, err error)
- func (s *Service) GetBucketTotals(ctx context.Context, projectID uuid.UUID, cursor accounting.BucketUsageCursor, ...) (_ *accounting.BucketUsagePage, err error)
- func (s *Service) GetBucketUsageRollups(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ []accounting.BucketUsageRollup, err error)
- func (s *Service) GetProject(ctx context.Context, projectID uuid.UUID) (p *Project, err error)
- func (s *Service) GetProjectMembers(ctx context.Context, projectID uuid.UUID, cursor ProjectMembersCursor) (pmp *ProjectMembersPage, err error)
- func (s *Service) GetProjectUsage(ctx context.Context, projectID uuid.UUID, since, before time.Time) (_ *accounting.ProjectUsage, err error)
- func (s *Service) GetProjectUsageLimits(ctx context.Context, projectID uuid.UUID) (_ *ProjectUsageLimits, err error)
- func (s *Service) GetUser(ctx context.Context, id uuid.UUID) (u *User, err error)
- func (s *Service) GetUserByEmail(ctx context.Context, email string) (u *User, err error)
- func (s *Service) GetUserID(ctx context.Context) (id uuid.UUID, err error)
- func (s *Service) GetUsersOwnedProjectsPage(ctx context.Context, cursor ProjectsCursor) (_ ProjectsPage, err error)
- func (s *Service) GetUsersProjects(ctx context.Context) (ps []Project, err error)
- func (s *Service) Payments() PaymentsService
- func (s *Service) PaywallEnabled(userID uuid.UUID) bool
- func (s *Service) ResetPassword(ctx context.Context, resetPasswordToken, password string) (err error)
- func (s *Service) RevokeResetPasswordToken(ctx context.Context, resetPasswordToken string) (err error)
- func (s *Service) Token(ctx context.Context, email, password string) (token string, err error)
- func (s *Service) UpdateAccount(ctx context.Context, fullName string, shortName string) (err error)
- func (s *Service) UpdateProject(ctx context.Context, projectID uuid.UUID, name string, description string) (p *Project, err error)
- type Signer
- type UsageLimitsConfig
- type User
- type UserInfo
- type UserStatus
- type Users
Constants ¶
const ( // TestPasswordCost is the hashing complexity to use for testing. TestPasswordCost = bcrypt.MinCost )
Variables ¶
var ( // Error describes internal console error. Error = errs.Class("service error") // ErrNoMembership is error type of not belonging to a specific project. ErrNoMembership = errs.Class("no membership error") // ErrTokenExpiration is error type of token reached expiration time. ErrTokenExpiration = errs.Class("token expiration error") // ErrProjLimit is error type of project limit. ErrProjLimit = errs.Class("project limit error") // ErrUsage is error type of project usage. ErrUsage = errs.Class("project usage error") // ErrEmailUsed is error type that occurs on repeating auth attempts with email. ErrEmailUsed = errs.Class("email used") // ErrNoAPIKey is error type that occurs when there is no api key found. ErrNoAPIKey = errs.Class("no api key found") )
ErrUnauthorized is error class for authorization related errors.
var ErrValidation = errs.Class("validation error")
ErrValidation validation related error class.
Functions ¶
func GetRequest ¶ added in v1.12.3
GetRequest gets *http.Request from context.
func ValidateFullName ¶ added in v0.27.0
ValidateFullName validates full name.
func ValidateNameAndDescription ¶ added in v1.13.1
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
ValidatePassword validates password.
func WithAuth ¶
func WithAuth(ctx context.Context, auth Authorization) context.Context
WithAuth creates new context with Authorization.
func WithAuthFailure ¶
WithAuthFailure creates new context with authorization failure.
Types ¶
type APIKeyCursor ¶ added in v0.21.0
type APIKeyCursor struct { Search string Limit uint Page uint Order APIKeyOrder OrderDirection 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"` Name string `json:"name"` 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 Search string Limit uint Order APIKeyOrder OrderDirection OrderDirection Offset uint64 PageCount uint CurrentPage uint TotalCount uint64 }
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 Authorization ¶
type Authorization struct { User User Claims consoleauth.Claims }
Authorization contains auth info of authorized User.
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 Buckets ¶ added in v1.15.1
type Buckets interface { // Create creates a new bucket. CreateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error) // Get returns an existing bucket. GetBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket storj.Bucket, err error) // GetBucketID returns an existing bucket id. GetBucketID(ctx context.Context, bucket metabase.BucketLocation) (id uuid.UUID, err error) // UpdateBucket updates an existing bucket. UpdateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error) // Delete deletes a bucket. DeleteBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (err error) // List returns all buckets for a project. ListBuckets(ctx context.Context, projectID uuid.UUID, listOpts storj.BucketListOptions, allowedBuckets macaroon.AllowedBuckets) (bucketList storj.BucketList, err error) // CountBuckets returns the number of buckets a project currently has. CountBuckets(ctx context.Context, projectID uuid.UUID) (int, error) }
Buckets is the interface for the database to interact with buckets.
architecture: Database
type Config ¶ added in v0.34.8
type Config struct { PasswordCost int `help:"password hashing cost (0=automatic)" internal:"true"` OpenRegistrationEnabled bool `help:"enable open registration" default:"false"` DefaultProjectLimit int `help:"default project limits for users" default:"3"` UsageLimits UsageLimitsConfig }
Config keeps track of core console service configuration parameters.
type CreateUser ¶
type CreateUser struct { FullName string `json:"fullName"` ShortName string `json:"shortName"` Email string `json:"email"` PartnerID string `json:"partnerId"` Password string `json:"password"` IsProfessional bool `json:"isProfessional"` Position string `json:"position"` CompanyName string `json:"companyName"` WorkingOn string `json:"workingOn"` EmployeeCount string `json:"employeeCount"` }
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.
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 // 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 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 PaymentsService ¶ added in v0.24.0
type PaymentsService struct {
// contains filtered or unexported fields
}
PaymentsService separates all payment related functionality.
func (PaymentsService) AccountBalance ¶ added in v0.24.0
func (paymentService PaymentsService) AccountBalance(ctx context.Context) (balance payments.Balance, err error)
AccountBalance return account balance.
func (PaymentsService) AddCreditCard ¶ added in v0.24.0
func (paymentService PaymentsService) AddCreditCard(ctx context.Context, creditCardToken string) (err error)
AddCreditCard is used to save new credit card and attach it to payment account.
func (PaymentsService) AddPromotionalCoupon ¶ added in v0.31.4
func (paymentService PaymentsService) AddPromotionalCoupon(ctx context.Context, userID uuid.UUID) (err error)
AddPromotionalCoupon creates new coupon for specified user.
func (PaymentsService) BillingHistory ¶ added in v0.25.0
func (paymentService PaymentsService) BillingHistory(ctx context.Context) (billingHistory []*BillingHistoryItem, err error)
BillingHistory returns a list of billing history items for payment account.
func (PaymentsService) ListCreditCards ¶ added in v0.24.0
func (paymentService PaymentsService) ListCreditCards(ctx context.Context) (_ []payments.CreditCard, err error)
ListCreditCards returns a list of credit cards for a given payment account.
func (PaymentsService) MakeCreditCardDefault ¶ added in v0.24.0
func (paymentService PaymentsService) MakeCreditCardDefault(ctx context.Context, cardID string) (err error)
MakeCreditCardDefault makes a credit card default payment method.
func (PaymentsService) PopulatePromotionalCoupons ¶ added in v0.31.0
func (paymentService PaymentsService) PopulatePromotionalCoupons(ctx context.Context) (err error)
PopulatePromotionalCoupons is used to populate promotional coupons through all active users who already have a project, payment method and do not have a promotional coupon yet. And updates project limits to selected size. This functionality is deprecated and will be removed.
func (PaymentsService) ProjectsCharges ¶ added in v0.26.0
func (paymentService PaymentsService) 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 (PaymentsService) RemoveCreditCard ¶ added in v0.24.0
func (paymentService PaymentsService) RemoveCreditCard(ctx context.Context, cardID string) (err error)
RemoveCreditCard is used to detach a credit card from payment account.
func (PaymentsService) SetupAccount ¶ added in v0.24.0
func (paymentService PaymentsService) SetupAccount(ctx context.Context) (err error)
SetupAccount creates payment account for authorized user.
func (PaymentsService) TokenDeposit ¶ added in v0.26.0
func (paymentService PaymentsService) TokenDeposit(ctx context.Context, amount int64) (_ *payments.Transaction, err error)
TokenDeposit creates new deposit transaction for adding STORJ tokens to account balance.
type Project ¶
type Project struct { ID uuid.UUID `json:"id"` Name string `json:"name"` Description string `json:"description"` PartnerID uuid.UUID `json:"partnerId"` OwnerID uuid.UUID `json:"ownerId"` RateLimit *int `json:"rateLimit"` MaxBuckets *int `json:"maxBuckets"` CreatedAt time.Time `json:"createdAt"` MemberCount int `json:"memberCount"` StorageLimit *memory.Size `json:"storageLimit"` BandwidthLimit *memory.Size `json:"bandwidthLimit"` }
Project is a database object that describes Project entity.
type ProjectInfo ¶
type ProjectInfo struct { Name string `json:"name"` Description string `json:"description"` CreatedAt time.Time `json:"createdAt"` }
ProjectInfo holds data needed to create/update Project.
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"` }
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) // 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 // 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
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 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 Service ¶
type Service struct { Signer // contains filtered or unexported fields }
Service is handling accounts related logic.
architecture: Service
func NewService ¶
func NewService(log *zap.Logger, signer Signer, store DB, projectAccounting accounting.ProjectAccounting, projectUsage *accounting.Service, buckets Buckets, partners *rewards.PartnersService, accounts payments.Accounts, analytics *analytics.Service, config Config, minCoinPayment int64) (*Service, error)
NewService returns new instance of Service.
func (*Service) ActivateAccount ¶
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.
func (*Service) Authorize ¶
func (s *Service) Authorize(ctx context.Context) (a Authorization, err error)
Authorize validates token from context and returns authorized Authorization.
func (*Service) ChangeEmail ¶ added in v1.17.1
ChangeEmail updates email for a given user.
func (*Service) ChangePassword ¶
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) 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 ¶
DeleteAPIKeys deletes api key by id.
func (*Service) DeleteAccount ¶
DeleteAccount deletes User.
func (*Service) DeleteProject ¶
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) 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) GetAPIKeyInfo ¶
GetAPIKeyInfo retrieves api key by 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) GetProject ¶
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) GetUserByEmail ¶ added in v0.10.0
GetUserByEmail returns User by email.
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 ¶
GetUsersProjects is a method for querying all projects.
func (*Service) Payments ¶ added in v0.24.0
func (s *Service) Payments() PaymentsService
Payments separates all payment related functionality.
func (*Service) PaywallEnabled ¶ added in v1.10.1
PaywallEnabled returns a true if a credit card or account balance is required to create projects.
func (*Service) ResetPassword ¶ added in v0.10.0
func (s *Service) ResetPassword(ctx context.Context, resetPasswordToken, password string) (err error)
ResetPassword - is a method for resetting user password.
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) UpdateAccount ¶
UpdateAccount updates User.
type UsageLimitsConfig ¶ added in v1.26.2
type UsageLimitsConfig struct { DefaultStorageLimit memory.Size `help:"the default storage usage limit" default:"50.00GB"` DefaultBandwidthLimit memory.Size `help:"the default bandwidth usage limit" default:"50.00GB"` }
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"` CreatedAt time.Time `json:"createdAt"` ProjectLimit int `json:"projectLimit"` IsProfessional bool `json:"isProfessional"` Position string `json:"position"` CompanyName string `json:"companyName"` CompanySize int `json:"companySize"` WorkingOn string `json:"workingOn"` EmployeeCount string `json:"employeeCount"` }
User is a database object that describes User entity.
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) // GetByEmail is a method for querying user by 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, user *User) error // GetProjectLimit is a method to get the users project limit GetProjectLimit(ctx context.Context, id uuid.UUID) (limit int, err error) }
Users exposes methods to manage User table in database.
architecture: Database