Documentation
¶
Overview ¶
Package types provides the core data types for the service
Index ¶
- Constants
- func IsValidAccountStatus(s string) bool
- type APIClient
- type APIClientCreationInput
- type APIClientCreationResponse
- type APIClientDataManager
- type APIClientDataService
- type APIClientList
- type Account
- type AccountBillingStatus
- type AccountCreationInput
- type AccountDataManager
- type AccountDataService
- type AccountList
- type AccountOwnershipTransferInput
- type AccountUpdateInput
- type AccountUserMembership
- type AccountUserMembershipCreationInput
- type AccountUserMembershipDataManager
- type AccountUserMembershipList
- type AccountUserMembershipUpdateInput
- type AddUserToAccountInput
- type AdminService
- type AdminUserDataManager
- type AuthService
- type ChangeActiveAccountInput
- type ContextKey
- type DataChangeMessage
- type ErrorResponse
- type FrontendService
- type Item
- type ItemCreationInput
- type ItemDataManager
- type ItemDataService
- type ItemDatabaseCreationInput
- type ItemList
- type ItemUpdateInput
- type ModifyUserPermissionsInput
- type PASETOCreationInput
- type PASETOResponse
- type Pagination
- type PasswordUpdateInput
- type PreArchiveMessage
- type PreUpdateMessage
- type PreWriteMessage
- type PreWriteResponse
- type QueryFilter
- type RequesterInfo
- type SessionContextData
- func (x *SessionContextData) AccountRolePermissionsChecker() authorization.AccountRolePermissionsChecker
- func (x *SessionContextData) AttachToLogger(logger logging.Logger) logging.Logger
- func (x *SessionContextData) ServiceRolePermissionChecker() authorization.ServiceRolePermissionChecker
- func (x *SessionContextData) ToBytes() []byte
- type TOTPSecretRefreshInput
- type TOTPSecretRefreshResponse
- type TOTPSecretVerificationInput
- type TestUserCreationConfig
- type User
- type UserAccountMembershipInfo
- type UserCreationResponse
- type UserDataManager
- type UserDataService
- type UserDataStoreCreationInput
- type UserList
- type UserLoginInput
- type UserRegistrationInput
- type UserReputationUpdateInput
- type UserStatusResponse
- type Webhook
- type WebhookCreationInput
- type WebhookDataManager
- type WebhookDataService
- type WebhookDatabaseCreationInput
- type WebhookList
- type WebsocketDataService
Constants ¶
const ( // SortAscending is the pre-determined Ascending sortType for external use. SortAscending sortType = "asc" // SortDescending is the pre-determined Descending sortType for external use. SortDescending sortType = "desc" )
const ( // MaxLimit is the maximum value for list queries. MaxLimit = 250 // DefaultLimit represents how many results we return in a response by default. DefaultLimit = 20 // SearchQueryKey is the query param key to find search queries in requests. SearchQueryKey = "q" // LimitQueryKey is the query param key to specify a limit in a query. LimitQueryKey = "limit" )
const ( // GoodStandingAccountStatus indicates a User's account is in good standing. GoodStandingAccountStatus accountStatus = "good" // UnverifiedAccountStatus indicates a User's account requires two factor secret verification. UnverifiedAccountStatus accountStatus = "unverified" // BannedUserAccountStatus indicates a User's account is banned. BannedUserAccountStatus accountStatus = "banned" // TerminatedUserReputation indicates a User's account is banned. TerminatedUserReputation accountStatus = "terminated" )
const (
// ItemDataType indicates an event is item-related.
ItemDataType dataType = "item"
)
const (
// UserMembershipDataType indicates an event is user membership-related.
UserMembershipDataType dataType = "user_membership"
)
const (
// WebhookDataType indicates an event is webhook-related.
WebhookDataType dataType = "webhook"
)
Variables ¶
This section is empty.
Functions ¶
func IsValidAccountStatus ¶
IsValidAccountStatus returns whether the provided string is a valid accountStatus.
Types ¶
type APIClient ¶
type APIClient struct { LastUpdatedOn *uint64 `json:"lastUpdatedOn"` ArchivedOn *uint64 `json:"archivedOn"` Name string `json:"name"` ClientID string `json:"clientID"` ID string `json:"id"` BelongsToUser string `json:"belongsToUser"` ClientSecret []byte `json:"-"` CreatedOn uint64 `json:"createdOn"` // contains filtered or unexported fields }
APIClient represents a user-authorized API client.
type APIClientCreationInput ¶
type APIClientCreationInput struct { UserLoginInput ID string `json:"-"` Name string `json:"clientName"` ClientID string `json:"-"` BelongsToUser string `json:"-"` ClientSecret []byte `json:"-"` // contains filtered or unexported fields }
APIClientCreationInput is a struct for use when creating API clients.
func (*APIClientCreationInput) ValidateWithContext ¶
func (x *APIClientCreationInput) ValidateWithContext(ctx context.Context, minUsernameLength, minPasswordLength uint8) error
ValidateWithContext validates an APICreationInput.
type APIClientCreationResponse ¶
type APIClientCreationResponse struct { ClientID string `json:"clientID"` ClientSecret string `json:"clientSecret"` ID string `json:"id"` // contains filtered or unexported fields }
APIClientCreationResponse is a struct for informing users of what their API client's secret key is.
type APIClientDataManager ¶
type APIClientDataManager interface { GetAPIClientByClientID(ctx context.Context, clientID string) (*APIClient, error) GetAPIClientByDatabaseID(ctx context.Context, clientID, ownerUserID string) (*APIClient, error) GetTotalAPIClientCount(ctx context.Context) (uint64, error) GetAPIClients(ctx context.Context, owneruserID string, filter *QueryFilter) (*APIClientList, error) CreateAPIClient(ctx context.Context, input *APIClientCreationInput) (*APIClient, error) ArchiveAPIClient(ctx context.Context, clientID, ownerUserID string) error }
APIClientDataManager handles API clients.
type APIClientDataService ¶
type APIClientDataService interface { ListHandler(res http.ResponseWriter, req *http.Request) CreateHandler(res http.ResponseWriter, req *http.Request) ReadHandler(res http.ResponseWriter, req *http.Request) ArchiveHandler(res http.ResponseWriter, req *http.Request) }
APIClientDataService describes a structure capable of serving traffic related to API clients.
type APIClientList ¶
type APIClientList struct { Clients []*APIClient `json:"clients"` Pagination // contains filtered or unexported fields }
APIClientList is a response struct containing a list of API clients.
type Account ¶
type Account struct { ArchivedOn *uint64 `json:"archivedOn"` SubscriptionPlanID *uint64 `json:"subscriptionPlanID"` LastUpdatedOn *uint64 `json:"lastUpdatedOn"` Name string `json:"name"` BillingStatus AccountBillingStatus `json:"billingStatus"` ContactEmail string `json:"contactEmail"` ContactPhone string `json:"contactPhone"` PaymentProcessorCustomerID string `json:"paymentProcessorCustomer"` BelongsToUser string `json:"belongsToUser"` ID string `json:"id"` Members []*AccountUserMembership `json:"members"` CreatedOn uint64 `json:"createdOn"` // contains filtered or unexported fields }
Account represents an account.
func (*Account) Update ¶
func (x *Account) Update(input *AccountUpdateInput)
Update merges an AccountUpdateInput with an account.
type AccountBillingStatus ¶
type AccountBillingStatus string
AccountBillingStatus is the type to use/compare against when checking billing status.
const ( // PaidAccountBillingStatus indicates an account is fully paid. PaidAccountBillingStatus AccountBillingStatus = "paid" // UnpaidAccountBillingStatus indicates an account is not paid. UnpaidAccountBillingStatus AccountBillingStatus = "unpaid" )
type AccountCreationInput ¶
type AccountCreationInput struct { ID string `json:"-"` Name string `json:"name"` ContactEmail string `json:"contactEmail"` ContactPhone string `json:"contactPhone"` BelongsToUser string `json:"-"` // contains filtered or unexported fields }
AccountCreationInput represents what a User could set as input for creating accounts.
func AccountCreationInputForNewUser ¶
func AccountCreationInputForNewUser(u *User) *AccountCreationInput
AccountCreationInputForNewUser creates a new AccountInputCreation struct for a given user.
func (*AccountCreationInput) ValidateWithContext ¶
func (x *AccountCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a AccountCreationInput.
type AccountDataManager ¶
type AccountDataManager interface { GetAccount(ctx context.Context, accountID, userID string) (*Account, error) GetAllAccountsCount(ctx context.Context) (uint64, error) GetAccounts(ctx context.Context, userID string, filter *QueryFilter) (*AccountList, error) GetAccountsForAdmin(ctx context.Context, filter *QueryFilter) (*AccountList, error) CreateAccount(ctx context.Context, input *AccountCreationInput) (*Account, error) UpdateAccount(ctx context.Context, updated *Account) error ArchiveAccount(ctx context.Context, accountID string, userID string) error }
AccountDataManager describes a structure capable of storing accounts permanently.
type AccountDataService ¶
type AccountDataService interface { ListHandler(res http.ResponseWriter, req *http.Request) CreateHandler(res http.ResponseWriter, req *http.Request) ReadHandler(res http.ResponseWriter, req *http.Request) UpdateHandler(res http.ResponseWriter, req *http.Request) ArchiveHandler(res http.ResponseWriter, req *http.Request) AddMemberHandler(res http.ResponseWriter, req *http.Request) RemoveMemberHandler(res http.ResponseWriter, req *http.Request) MarkAsDefaultAccountHandler(res http.ResponseWriter, req *http.Request) ModifyMemberPermissionsHandler(res http.ResponseWriter, req *http.Request) TransferAccountOwnershipHandler(res http.ResponseWriter, req *http.Request) }
AccountDataService describes a structure capable of serving traffic related to accounts.
type AccountList ¶
type AccountList struct { Accounts []*Account `json:"accounts"` Pagination // contains filtered or unexported fields }
AccountList represents a list of accounts.
type AccountOwnershipTransferInput ¶
type AccountOwnershipTransferInput struct { Reason string `json:"reason"` CurrentOwner string `json:"currentOwner"` NewOwner string `json:"newOwner"` // contains filtered or unexported fields }
AccountOwnershipTransferInput represents what a User could set as input for updating account user memberships.
func (*AccountOwnershipTransferInput) ValidateWithContext ¶
func (x *AccountOwnershipTransferInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a AccountOwnershipTransferInput.
type AccountUpdateInput ¶
type AccountUpdateInput struct { Name string `json:"name"` ContactEmail string `json:"contactEmail"` ContactPhone string `json:"contactPhone"` BelongsToUser string `json:"-"` // contains filtered or unexported fields }
AccountUpdateInput represents what a User could set as input for updating accounts.
func (*AccountUpdateInput) ValidateWithContext ¶
func (x *AccountUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a AccountUpdateInput.
type AccountUserMembership ¶
type AccountUserMembership struct { ArchivedOn *uint64 `json:"archivedOn"` LastUpdatedOn *uint64 `json:"lastUpdatedOn"` ID string `json:"id"` BelongsToUser string `json:"belongsToUser"` BelongsToAccount string `json:"belongsToAccount"` AccountRoles []string `json:"accountRole"` CreatedOn uint64 `json:"createdOn"` DefaultAccount bool `json:"defaultAccount"` // contains filtered or unexported fields }
AccountUserMembership defines a relationship between a user and an account.
type AccountUserMembershipCreationInput ¶
type AccountUserMembershipCreationInput struct { ID string `json:"-"` BelongsToUser string `json:"belongsToUser"` BelongsToAccount string `json:"belongsToAccount"` // contains filtered or unexported fields }
AccountUserMembershipCreationInput represents what a User could set as input for creating account user memberships.
type AccountUserMembershipDataManager ¶
type AccountUserMembershipDataManager interface { BuildSessionContextDataForUser(ctx context.Context, userID string) (*SessionContextData, error) GetDefaultAccountIDForUser(ctx context.Context, userID string) (string, error) MarkAccountAsUserDefault(ctx context.Context, userID, accountID string) error UserIsMemberOfAccount(ctx context.Context, userID, accountID string) (bool, error) ModifyUserPermissions(ctx context.Context, accountID, userID string, input *ModifyUserPermissionsInput) error TransferAccountOwnership(ctx context.Context, accountID string, input *AccountOwnershipTransferInput) error AddUserToAccount(ctx context.Context, input *AddUserToAccountInput) error RemoveUserFromAccount(ctx context.Context, userID, accountID string) error }
AccountUserMembershipDataManager describes a structure capable of storing accountUserMemberships permanently.
type AccountUserMembershipList ¶
type AccountUserMembershipList struct { AccountUserMemberships []*AccountUserMembership `json:"accountUserMemberships"` Pagination // contains filtered or unexported fields }
AccountUserMembershipList represents a list of account user memberships.
type AccountUserMembershipUpdateInput ¶
type AccountUserMembershipUpdateInput struct { BelongsToUser string `json:"belongsToUser"` BelongsToAccount string `json:"belongsToAccount"` // contains filtered or unexported fields }
AccountUserMembershipUpdateInput represents what a User could set as input for updating account user memberships.
type AddUserToAccountInput ¶
type AddUserToAccountInput struct { ID string `json:"-"` Reason string `json:"reason"` UserID string `json:"userID"` AccountID string `json:"accountID"` AccountRoles []string `json:"accountRole"` // contains filtered or unexported fields }
AddUserToAccountInput represents what a User could set as input for updating account user memberships.
func (*AddUserToAccountInput) ValidateWithContext ¶
func (x *AddUserToAccountInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates an AddUserToAccountInput.
type AdminService ¶
type AdminService interface {
UserReputationChangeHandler(res http.ResponseWriter, req *http.Request)
}
AdminService describes a structure capable of serving traffic related to users.
type AdminUserDataManager ¶
type AdminUserDataManager interface {
UpdateUserReputation(ctx context.Context, userID string, input *UserReputationUpdateInput) error
}
AdminUserDataManager contains administrative User functions that we don't necessarily want to expose to, say, the collection of handlers.
type AuthService ¶
type AuthService interface { StatusHandler(res http.ResponseWriter, req *http.Request) BeginSessionHandler(res http.ResponseWriter, req *http.Request) EndSessionHandler(res http.ResponseWriter, req *http.Request) CycleCookieSecretHandler(res http.ResponseWriter, req *http.Request) PASETOHandler(res http.ResponseWriter, req *http.Request) ChangeActiveAccountHandler(res http.ResponseWriter, req *http.Request) PermissionFilterMiddleware(permissions ...authorization.Permission) func(next http.Handler) http.Handler CookieRequirementMiddleware(next http.Handler) http.Handler UserAttributionMiddleware(next http.Handler) http.Handler AuthorizationMiddleware(next http.Handler) http.Handler ServiceAdminMiddleware(next http.Handler) http.Handler AuthenticateUser(ctx context.Context, loginData *UserLoginInput) (*User, *http.Cookie, error) LogoutUser(ctx context.Context, sessionCtxData *SessionContextData, req *http.Request, res http.ResponseWriter) error }
AuthService describes a structure capable of handling passwords and authorization requests.
type ChangeActiveAccountInput ¶
type ChangeActiveAccountInput struct { AccountID string `json:"accountID"` // contains filtered or unexported fields }
ChangeActiveAccountInput represents what a User could set as input for switching accounts.
func (*ChangeActiveAccountInput) ValidateWithContext ¶
func (x *ChangeActiveAccountInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a ChangeActiveAccountInput.
type ContextKey ¶
type ContextKey string
ContextKey represents strings to be used in Context objects. From the docs:
"The provided key must be comparable and should not be of type string or any other built-in type to avoid collisions between packages using context."
const ( // SessionContextDataKey is the non-string type we use for referencing SessionContextData structs. SessionContextDataKey ContextKey = "session_context_data" // UserIDContextKey is the non-string type we use for referencing SessionContextData structs. UserIDContextKey ContextKey = "user_id" // AccountIDContextKey is the non-string type we use for referencing SessionContextData structs. AccountIDContextKey ContextKey = "account_id" // UserLoginInputContextKey is the non-string type we use for referencing SessionContextData structs. UserLoginInputContextKey ContextKey = "user_login_input" // UserRegistrationInputContextKey is the non-string type we use for referencing SessionContextData structs. UserRegistrationInputContextKey ContextKey = "user_registration_input" )
type DataChangeMessage ¶
type DataChangeMessage struct { MessageType string `json:"messageType"` DataType dataType `json:"dataType"` Item *Item `json:"item,omitempty"` Webhook *Webhook `json:"webhook,omitempty"` UserMembership *AccountUserMembership `json:"user_membership"` Context map[string]string `json:"context"` AttributableToUserID string `json:"attributableToUserID"` AttributableToAccountID string `json:"attributeToAccountID"` // contains filtered or unexported fields }
DataChangeMessage represents an event that asks a worker to write data to the datastore.
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Code int `json:"code"` // contains filtered or unexported fields }
ErrorResponse represents a response we might send to the User in the event of an error.
func (*ErrorResponse) Error ¶
func (er *ErrorResponse) Error() string
type FrontendService ¶
type FrontendService interface {
StaticDir(ctx context.Context, staticFilesDirectory string) (http.HandlerFunc, error)
}
FrontendService serves static frontend files.
type Item ¶
type Item struct { ArchivedOn *uint64 `json:"archivedOn"` LastUpdatedOn *uint64 `json:"lastUpdatedOn"` Name string `json:"name"` Details string `json:"details"` ID string `json:"id"` BelongsToAccount string `json:"belongsToAccount"` CreatedOn uint64 `json:"createdOn"` // contains filtered or unexported fields }
Item represents an item.
func (*Item) Update ¶
func (x *Item) Update(input *ItemUpdateInput)
Update merges an ItemUpdateInput with an item.
type ItemCreationInput ¶
type ItemCreationInput struct { ID string `json:"-"` Name string `json:"name"` Details string `json:"details"` BelongsToAccount string `json:"-"` // contains filtered or unexported fields }
ItemCreationInput represents what a user could set as input for creating items.
func (*ItemCreationInput) ValidateWithContext ¶
func (x *ItemCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a ItemCreationInput.
type ItemDataManager ¶
type ItemDataManager interface { ItemExists(ctx context.Context, itemID, accountID string) (bool, error) GetItem(ctx context.Context, itemID, accountID string) (*Item, error) GetTotalItemCount(ctx context.Context) (uint64, error) GetItems(ctx context.Context, accountID string, filter *QueryFilter) (*ItemList, error) GetItemsWithIDs(ctx context.Context, accountID string, limit uint8, ids []string) ([]*Item, error) CreateItem(ctx context.Context, input *ItemDatabaseCreationInput) (*Item, error) UpdateItem(ctx context.Context, updated *Item) error ArchiveItem(ctx context.Context, itemID, accountID string) error }
ItemDataManager describes a structure capable of storing items permanently.
type ItemDataService ¶
type ItemDataService interface { SearchHandler(res http.ResponseWriter, req *http.Request) ListHandler(res http.ResponseWriter, req *http.Request) CreateHandler(res http.ResponseWriter, req *http.Request) ReadHandler(res http.ResponseWriter, req *http.Request) UpdateHandler(res http.ResponseWriter, req *http.Request) ArchiveHandler(res http.ResponseWriter, req *http.Request) }
ItemDataService describes a structure capable of serving traffic related to items.
type ItemDatabaseCreationInput ¶
type ItemDatabaseCreationInput struct { ID string `json:"id"` Name string `json:"name"` Details string `json:"details"` BelongsToAccount string `json:"belongsToAccount"` // contains filtered or unexported fields }
ItemDatabaseCreationInput represents what a user could set as input for creating items.
func ItemDatabaseCreationInputFromItemCreationInput ¶
func ItemDatabaseCreationInputFromItemCreationInput(input *ItemCreationInput) *ItemDatabaseCreationInput
ItemDatabaseCreationInputFromItemCreationInput creates a DatabaseCreationInput from a CreationInput.
func (*ItemDatabaseCreationInput) ValidateWithContext ¶
func (x *ItemDatabaseCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a ItemDatabaseCreationInput.
type ItemList ¶
type ItemList struct { Items []*Item `json:"items"` Pagination // contains filtered or unexported fields }
ItemList represents a list of items.
type ItemUpdateInput ¶
type ItemUpdateInput struct { Name string `json:"name"` Details string `json:"details"` BelongsToAccount string `json:"-"` // contains filtered or unexported fields }
ItemUpdateInput represents what a user could set as input for updating items.
func (*ItemUpdateInput) ValidateWithContext ¶
func (x *ItemUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a ItemUpdateInput.
type ModifyUserPermissionsInput ¶
type ModifyUserPermissionsInput struct { Reason string `json:"reason"` NewRoles []string `json:"newRoles"` // contains filtered or unexported fields }
ModifyUserPermissionsInput represents what a User could set as input for updating account user memberships.
func (*ModifyUserPermissionsInput) ValidateWithContext ¶
func (x *ModifyUserPermissionsInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a ModifyUserPermissionsInput.
type PASETOCreationInput ¶
type PASETOCreationInput struct { ClientID string `json:"clientID"` AccountID string `json:"accountID"` RequestTime int64 `json:"requestTime"` RequestedLifetime uint64 `json:"requestedLifetime,omitempty"` // contains filtered or unexported fields }
PASETOCreationInput is used to create a PASETO.
func (*PASETOCreationInput) ValidateWithContext ¶
func (i *PASETOCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures our provided UserLoginInput meets expectations.
type PASETOResponse ¶
type PASETOResponse struct { Token string `json:"token"` ExpiresAt string `json:"expiresAt"` // contains filtered or unexported fields }
PASETOResponse is used to respond to a PASETO request.
type Pagination ¶
type Pagination struct { Page uint64 `json:"page"` Limit uint8 `json:"limit"` FilteredCount uint64 `json:"filteredCount"` TotalCount uint64 `json:"totalCount"` // contains filtered or unexported fields }
Pagination represents a pagination request.
type PasswordUpdateInput ¶
type PasswordUpdateInput struct { NewPassword string `json:"newPassword"` CurrentPassword string `json:"currentPassword"` TOTPToken string `json:"totpToken"` // contains filtered or unexported fields }
PasswordUpdateInput represents input a User would provide when updating their passwords.
func (*PasswordUpdateInput) ValidateWithContext ¶
func (i *PasswordUpdateInput) ValidateWithContext(ctx context.Context, minPasswordLength uint8) error
ValidateWithContext ensures our provided PasswordUpdateInput meets expectations.
type PreArchiveMessage ¶
type PreArchiveMessage struct { DataType dataType `json:"dataType"` RelevantID string `json:"relevantID"` AttributableToUserID string `json:"attributableToUserID"` AttributableToAccountID string `json:"attributeToAccountID"` // contains filtered or unexported fields }
PreArchiveMessage represents an event that asks a worker to archive data to the datastore.
type PreUpdateMessage ¶
type PreUpdateMessage struct { DataType dataType `json:"dataType"` Item *Item `json:"item,omitempty"` AttributableToUserID string `json:"attributableToUserID"` AttributableToAccountID string `json:"attributeToAccountID"` // contains filtered or unexported fields }
PreUpdateMessage represents an event that asks a worker to update data to the datastore.
type PreWriteMessage ¶
type PreWriteMessage struct { DataType dataType `json:"dataType"` Item *ItemDatabaseCreationInput `json:"item,omitempty"` Webhook *WebhookDatabaseCreationInput `json:"webhook,omitempty"` UserMembership *AddUserToAccountInput `json:"user_membership"` AttributableToUserID string `json:"attributableToUserID"` AttributableToAccountID string `json:"attributeToAccountID"` // contains filtered or unexported fields }
PreWriteMessage represents an event that asks a worker to write data to the datastore.
type PreWriteResponse ¶
type PreWriteResponse struct { ID string `json:"id"` // contains filtered or unexported fields }
PreWriteResponse is what we respond with when the data requested to be written has not yet been written.
type QueryFilter ¶
type QueryFilter struct { SortBy sortType `json:"sortBy"` Page uint64 `json:"page"` CreatedAfter uint64 `json:"createdBefore,omitempty"` CreatedBefore uint64 `json:"createdAfter,omitempty"` UpdatedAfter uint64 `json:"updatedBefore,omitempty"` UpdatedBefore uint64 `json:"updatedAfter,omitempty"` Limit uint8 `json:"limit"` IncludeArchived bool `json:"includeArchived,omitempty"` // contains filtered or unexported fields }
QueryFilter represents all the filters a User could apply to a list query.
func DefaultQueryFilter ¶
func DefaultQueryFilter() *QueryFilter
DefaultQueryFilter builds the default query filter.
func ExtractQueryFilter ¶
func ExtractQueryFilter(req *http.Request) *QueryFilter
ExtractQueryFilter can extract a QueryFilter from a request.
func (*QueryFilter) AttachToLogger ¶
func (qf *QueryFilter) AttachToLogger(logger logging.Logger) logging.Logger
AttachToLogger attaches a QueryFilter's values to a logging.Logger.
func (*QueryFilter) FromParams ¶
func (qf *QueryFilter) FromParams(params url.Values)
FromParams overrides the core QueryFilter values with values retrieved from url.Params.
func (*QueryFilter) QueryPage ¶
func (qf *QueryFilter) QueryPage() uint64
QueryPage calculates a query page from the current filter values.
func (*QueryFilter) SetPage ¶
func (qf *QueryFilter) SetPage(page uint64)
SetPage sets the current page with certain constraints.
func (*QueryFilter) ToValues ¶
func (qf *QueryFilter) ToValues() url.Values
ToValues returns a url.Values from a QueryFilter.
type RequesterInfo ¶
type RequesterInfo struct { ServicePermissions authorization.ServiceRolePermissionChecker `json:"-"` Reputation accountStatus `json:"-"` ReputationExplanation string `json:"-"` UserID string `json:"-"` // contains filtered or unexported fields }
RequesterInfo contains data relevant to the user making a request.
type SessionContextData ¶
type SessionContextData struct { AccountPermissions map[string]authorization.AccountRolePermissionsChecker `json:"-"` Requester RequesterInfo `json:"-"` ActiveAccountID string `json:"-"` // contains filtered or unexported fields }
SessionContextData represents what we encode in our passwords cookies.
func (*SessionContextData) AccountRolePermissionsChecker ¶
func (x *SessionContextData) AccountRolePermissionsChecker() authorization.AccountRolePermissionsChecker
AccountRolePermissionsChecker returns the relevant AccountRolePermissionsChecker.
func (*SessionContextData) AttachToLogger ¶
func (x *SessionContextData) AttachToLogger(logger logging.Logger) logging.Logger
AttachToLogger provides a consistent way to attach a SessionContextData object to a logger.
func (*SessionContextData) ServiceRolePermissionChecker ¶
func (x *SessionContextData) ServiceRolePermissionChecker() authorization.ServiceRolePermissionChecker
ServiceRolePermissionChecker returns the relevant ServiceRolePermissionChecker.
func (*SessionContextData) ToBytes ¶
func (x *SessionContextData) ToBytes() []byte
ToBytes returns the gob encoded session info.
type TOTPSecretRefreshInput ¶
type TOTPSecretRefreshInput struct { CurrentPassword string `json:"currentPassword"` TOTPToken string `json:"totpToken"` // contains filtered or unexported fields }
TOTPSecretRefreshInput represents input a User would provide when updating their 2FA secret.
func (*TOTPSecretRefreshInput) ValidateWithContext ¶
func (i *TOTPSecretRefreshInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures our provided TOTPSecretRefreshInput meets expectations.
type TOTPSecretRefreshResponse ¶
type TOTPSecretRefreshResponse struct { TwoFactorQRCode string `json:"qrCode"` TwoFactorSecret string `json:"twoFactorSecret"` // contains filtered or unexported fields }
TOTPSecretRefreshResponse represents the response we provide to a User when updating their 2FA secret.
type TOTPSecretVerificationInput ¶
type TOTPSecretVerificationInput struct { TOTPToken string `json:"totpToken"` UserID string `json:"userID"` // contains filtered or unexported fields }
TOTPSecretVerificationInput represents input a User would provide when validating their 2FA secret.
func (*TOTPSecretVerificationInput) ValidateWithContext ¶
func (i *TOTPSecretVerificationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures our provided TOTPSecretVerificationInput meets expectations.
type TestUserCreationConfig ¶
type TestUserCreationConfig struct { ID string Username string `json:"username" mapstructure:"username" toml:"username,omitempty"` Password string `json:"password" mapstructure:"password" toml:"password,omitempty"` HashedPassword string `json:"hashed_password" mapstructure:"hashed_password" toml:"hashed_password,omitempty"` IsServiceAdmin bool `json:"is_site_admin" mapstructure:"is_site_admin" toml:"is_site_admin,omitempty"` // contains filtered or unexported fields }
TestUserCreationConfig is here because of cyclical imports.
type User ¶
type User struct { PasswordLastChangedOn *uint64 `json:"passwordLastChangedOn"` ArchivedOn *uint64 `json:"archivedOn"` LastUpdatedOn *uint64 `json:"lastUpdatedOn"` TwoFactorSecretVerifiedOn *uint64 `json:"-"` AvatarSrc *string `json:"avatar"` ServiceAccountStatus accountStatus `json:"reputation"` ReputationExplanation string `json:"reputationExplanation"` Username string `json:"username"` TwoFactorSecret string `json:"-"` HashedPassword string `json:"-"` ID string `json:"id"` ServiceRoles []string `json:"serviceRole"` CreatedOn uint64 `json:"createdOn"` RequiresPasswordChange bool `json:"requiresPasswordChange"` // contains filtered or unexported fields }
User represents a User.
type UserAccountMembershipInfo ¶
type UserAccountMembershipInfo struct { AccountName string `json:"name"` AccountID string `json:"accountID"` AccountRoles []string `json:"-"` // contains filtered or unexported fields }
UserAccountMembershipInfo represents key information about an account membership.
type UserCreationResponse ¶
type UserCreationResponse struct { ID string `json:"id"` Username string `json:"username"` AccountStatus accountStatus `json:"accountStatus"` TwoFactorSecret string `json:"twoFactorSecret"` TwoFactorQRCode string `json:"qrCode"` CreatedUserID string `json:"ID"` CreatedOn uint64 `json:"createdOn"` IsAdmin bool `json:"isAdmin"` // contains filtered or unexported fields }
UserCreationResponse is a response structure for Users that doesn't contain passwords fields, but does contain the two factor secret.
type UserDataManager ¶
type UserDataManager interface { UserHasStatus(ctx context.Context, userID string, statuses ...string) (bool, error) GetUser(ctx context.Context, userID string) (*User, error) GetUserWithUnverifiedTwoFactorSecret(ctx context.Context, userID string) (*User, error) MarkUserTwoFactorSecretAsVerified(ctx context.Context, userID string) error GetUserByUsername(ctx context.Context, username string) (*User, error) SearchForUsersByUsername(ctx context.Context, usernameQuery string) ([]*User, error) GetAllUsersCount(ctx context.Context) (uint64, error) GetUsers(ctx context.Context, filter *QueryFilter) (*UserList, error) CreateUser(ctx context.Context, input *UserDataStoreCreationInput) (*User, error) UpdateUser(ctx context.Context, updated *User) error UpdateUserPassword(ctx context.Context, userID, newHash string) error ArchiveUser(ctx context.Context, userID string) error }
UserDataManager describes a structure which can manage users in permanent storage.
type UserDataService ¶
type UserDataService interface { ListHandler(res http.ResponseWriter, req *http.Request) CreateHandler(res http.ResponseWriter, req *http.Request) ReadHandler(res http.ResponseWriter, req *http.Request) SelfHandler(res http.ResponseWriter, req *http.Request) UsernameSearchHandler(res http.ResponseWriter, req *http.Request) NewTOTPSecretHandler(res http.ResponseWriter, req *http.Request) TOTPSecretVerificationHandler(res http.ResponseWriter, req *http.Request) UpdatePasswordHandler(res http.ResponseWriter, req *http.Request) AvatarUploadHandler(res http.ResponseWriter, req *http.Request) ArchiveHandler(res http.ResponseWriter, req *http.Request) RegisterUser(ctx context.Context, registrationInput *UserRegistrationInput) (*UserCreationResponse, error) VerifyUserTwoFactorSecret(ctx context.Context, input *TOTPSecretVerificationInput) error }
UserDataService describes a structure capable of serving traffic related to users.
type UserDataStoreCreationInput ¶
type UserDataStoreCreationInput struct { ID string `json:"-"` Username string `json:"-"` HashedPassword string `json:"-"` TwoFactorSecret string `json:"-"` // contains filtered or unexported fields }
UserDataStoreCreationInput is used by the User creation route to communicate with the data store.
type UserList ¶
type UserList struct { Users []*User `json:"users"` Pagination // contains filtered or unexported fields }
UserList represents a list of users.
type UserLoginInput ¶
type UserLoginInput struct { Username string `json:"username"` Password string `json:"password"` TOTPToken string `json:"totpToken"` // contains filtered or unexported fields }
UserLoginInput represents the payload used to log in a User.
func (*UserLoginInput) ValidateWithContext ¶
func (i *UserLoginInput) ValidateWithContext(ctx context.Context, minUsernameLength, minPasswordLength uint8) error
ValidateWithContext ensures our provided UserLoginInput meets expectations.
type UserRegistrationInput ¶
type UserRegistrationInput struct { Username string `json:"username"` Password string `json:"password"` // contains filtered or unexported fields }
UserRegistrationInput represents the input required from users to register an account.
func (*UserRegistrationInput) ValidateWithContext ¶
func (i *UserRegistrationInput) ValidateWithContext(ctx context.Context, minUsernameLength, minPasswordLength uint8) error
ValidateWithContext ensures our provided UserRegistrationInput meets expectations.
type UserReputationUpdateInput ¶
type UserReputationUpdateInput struct { NewReputation accountStatus `json:"newReputation"` Reason string `json:"reason"` TargetUserID string `json:"targetUserID"` // contains filtered or unexported fields }
UserReputationUpdateInput represents what an admin User could provide as input for changing statuses.
func (*UserReputationUpdateInput) ValidateWithContext ¶
func (i *UserReputationUpdateInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures our struct is validatable.
type UserStatusResponse ¶
type UserStatusResponse struct { UserReputation accountStatus `json:"accountStatus,omitempty"` UserReputationExplanation string `json:"reputationExplanation"` ActiveAccount string `json:"activeAccount,omitempty"` UserIsAuthenticated bool `json:"isAuthenticated"` // contains filtered or unexported fields }
UserStatusResponse is what we encode when the frontend wants to check auth status.
type Webhook ¶
type Webhook struct { LastUpdatedOn *uint64 `json:"lastUpdatedOn"` ArchivedOn *uint64 `json:"archivedOn"` Name string `json:"name"` URL string `json:"url"` Method string `json:"method"` ContentType string `json:"contentType"` ID string `json:"id"` BelongsToAccount string `json:"belongsToAccount"` Events []string `json:"events"` DataTypes []string `json:"dataTypes"` Topics []string `json:"topics"` CreatedOn uint64 `json:"createdOn"` // contains filtered or unexported fields }
Webhook represents a webhook listener, an endpoint to send an HTTP request to upon an event.
type WebhookCreationInput ¶
type WebhookCreationInput struct { ID string `json:"-"` Name string `json:"name"` ContentType string `json:"contentType"` URL string `json:"url"` Method string `json:"method"` BelongsToAccount string `json:"-"` Events []string `json:"events"` DataTypes []string `json:"dataTypes"` Topics []string `json:"topics"` // contains filtered or unexported fields }
WebhookCreationInput represents what a User could set as input for creating a webhook.
func (*WebhookCreationInput) ValidateWithContext ¶
func (w *WebhookCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a WebhookCreationInput.
type WebhookDataManager ¶
type WebhookDataManager interface { WebhookExists(ctx context.Context, webhookID, accountID string) (bool, error) GetWebhook(ctx context.Context, webhookID, accountID string) (*Webhook, error) GetAllWebhooksCount(ctx context.Context) (uint64, error) GetWebhooks(ctx context.Context, accountID string, filter *QueryFilter) (*WebhookList, error) CreateWebhook(ctx context.Context, input *WebhookDatabaseCreationInput) (*Webhook, error) ArchiveWebhook(ctx context.Context, webhookID, accountID string) error }
WebhookDataManager describes a structure capable of storing webhooks.
type WebhookDataService ¶
type WebhookDataService interface { ListHandler(res http.ResponseWriter, req *http.Request) CreateHandler(res http.ResponseWriter, req *http.Request) ReadHandler(res http.ResponseWriter, req *http.Request) ArchiveHandler(res http.ResponseWriter, req *http.Request) }
WebhookDataService describes a structure capable of serving traffic related to webhooks.
type WebhookDatabaseCreationInput ¶
type WebhookDatabaseCreationInput struct { ID string `json:"id"` Name string `json:"name"` ContentType string `json:"contentType"` URL string `json:"url"` Method string `json:"method"` BelongsToAccount string `json:"belongsToAccount"` Events []string `json:"events"` DataTypes []string `json:"dataTypes"` Topics []string `json:"topics"` // contains filtered or unexported fields }
WebhookDatabaseCreationInput represents what a User could set as input for creating a webhook.
func WebhookDatabaseCreationInputFromWebhookCreationInput ¶
func WebhookDatabaseCreationInputFromWebhookCreationInput(input *WebhookCreationInput) *WebhookDatabaseCreationInput
WebhookDatabaseCreationInputFromWebhookCreationInput creates a DatabaseCreationInput from a CreationInput.
func (*WebhookDatabaseCreationInput) ValidateWithContext ¶
func (w *WebhookDatabaseCreationInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext validates a WebhookDatabaseCreationInput.
type WebhookList ¶
type WebhookList struct { Webhooks []*Webhook `json:"webhooks"` Pagination // contains filtered or unexported fields }
WebhookList represents a list of webhooks.
type WebsocketDataService ¶
type WebsocketDataService interface {
SubscribeHandler(res http.ResponseWriter, req *http.Request)
}
WebsocketDataService describes a structure capable of serving traffic related to notifications.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package fakes provides fakes model builders
|
Package fakes provides fakes model builders |
Package mock provides mockable implementations of every interface defined in the outer types package
|
Package mock provides mockable implementations of every interface defined in the outer types package |