Documentation ¶
Overview ¶
Copyright 2023 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func LoadPlans(filepath string) error
- func ValidateKeys(value interface{}) error
- func ValidatePlanName(name string) error
- type ETag
- type Email
- type Features
- type NewTenant
- type PersonalAccessToken
- type Plan
- type PlanBinding
- type PlanBindingDetails
- type PlanLimits
- type Settings
- type SettingsValues
- type TokenRequest
- type User
- type UserFilter
- type UserInternal
- type UserUpdate
Constants ¶
View Source
const (
MinPasswordLength = 8
)
Variables ¶
View Source
var ( PlanList = []Plan{} PlanNameToPlan = map[string]*Plan{} )
View Source
var ( ErrPasswordTooShort = errors.Errorf( "password: must be minimum %d characters long", MinPasswordLength, ) ErrEmptyUpdate = errors.New("no update information provided") )
Functions ¶
func LoadPlans ¶
LoadPlans loads Plan definitions from filePath. This function also checks for the validity of the definitions.
func ValidateKeys ¶
func ValidateKeys(value interface{}) error
func ValidatePlanName ¶
Types ¶
type ETag ¶
type ETag [12]byte
var (
ETagNil ETag
)
func (ETag) MarshalText ¶
func (*ETag) UnmarshalText ¶
type Features ¶
type Features struct { // RBAC RBAC bool `json:"rbac" bson:"rbac"` // audit logs AuditLogs bool `json:"audit_logs" bson:"audit_logs"` // dynamic groups DynamicGroups bool `json:"dynamic_groups" bson:"dynamic_groups"` // remote terminal Terminal bool `json:"terminal" bson:"terminal"` // file transfer FileTransfer bool `json:"file_transfer" bson:"file_transfer"` // configuration Configuration bool `json:"configuration" bson:"configuration"` // monitoring Monitoring bool `json:"monitoring" bson:"monitoring"` // reporting Reporting bool `json:"reporting" bson:"reporting"` }
type PersonalAccessToken ¶
type PersonalAccessToken struct { // system-generated user ID ID oid.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // token name Name *string `json:"name,omitempty" on:"name,omitempty"` // timestamp of the last usage LastUsed *time.Time `json:"last_used,omitempty" bson:"last_used,omitempty"` // the absolute time when the token expires. ExpirationDate *jwt.Time `json:"expiration_date,omitempty" bson:"exp,omitempty"` // CreatedTs is the absolute time the token was created. CreatedTs jwt.Time `json:"created_ts,omitempty" bson:"iat,omitempty"` }
func (PersonalAccessToken) MarshalJSON ¶
func (t PersonalAccessToken) MarshalJSON() ([]byte, error)
type Plan ¶
type PlanBinding ¶
type PlanBinding struct { // tenant can only have single plan binding TenantID string `json:"-" bson:"_id"` // plan name PlanName string `json:"plan_name" bson:"plan_name"` // limits Limits *PlanLimits `json:"limits,omitempty" bson:"limits,omitempty"` }
type PlanBindingDetails ¶
type PlanBindingDetails struct { // tenant can only have single plan binding TenantID string `json:"-" bson:"_id"` // plan name Plan Plan `json:"plan" bson:"plan"` // limits Limits *PlanLimits `json:"limits,omitempty" bson:"limits,omitempty"` }
type PlanLimits ¶
type Settings ¶
type Settings struct { ID string `json:"id"` ETag string `json:"etag"` UserID string `json:"-"` Values SettingsValues `json:"-"` }
func (Settings) MarshalBSON ¶
func (Settings) MarshalJSON ¶
func (*Settings) UnmarshalBSON ¶
func (*Settings) UnmarshalJSON ¶
type SettingsValues ¶
type SettingsValues map[string]interface{}
type TokenRequest ¶
func (TokenRequest) Validate ¶
func (tr TokenRequest) Validate(maxExpiration int) error
type User ¶
type User struct { // system-generated user ID ID string `json:"id" bson:"_id"` // ETag is the entity tag that together with ID uniquely identifies // the User document. // NOTE: The v1 API does not support ETags, so this is only used // internally for checking pre-conditions before performing updates. ETag *ETag `json:"-" bson:"etag,omitempty"` // user email address Email Email `json:"email" bson:"email"` // user password Password string `json:"password,omitempty" bson:"password"` // timestamp of the user creation CreatedTs *time.Time `json:"created_ts,omitempty" bson:"created_ts,omitempty"` // timestamp of the last user information update UpdatedTs *time.Time `json:"updated_ts,omitempty" bson:"updated_ts,omitempty"` // LoginTs is the timestamp of the last login for this user. LoginTs *time.Time `json:"login_ts,omitempty" bson:"login_ts,omitempty"` }
type UserFilter ¶
type UserFilter struct { ID []string `json:"id,omitempty"` Email []Email `json:"email,omitempty"` CreatedAfter *time.Time `json:"created_after,omitempty"` CreatedBefore *time.Time `json:"created_before,omitempty"` UpdatedAfter *time.Time `json:"updated_after,omitempty"` UpdatedBefore *time.Time `json:"updated_before,omitempty"` }
type UserInternal ¶
type UserInternal struct { User PasswordHash string `json:"password_hash,omitempty" bson:"-"` Propagate *bool `json:"propagate,omitempty" bson:"-"` }
func (UserInternal) ShouldPropagate ¶
func (u UserInternal) ShouldPropagate() bool
func (UserInternal) Validate ¶
func (u UserInternal) Validate() error
type UserUpdate ¶
type UserUpdate struct { // ETag selects user ETag for the user to update // NOTE: This is the only parameter that goes into the query condition if set. // NOTE: If set to ETagNil, it will match users without an ETag. ETag *ETag `json:"-" bson:"-"` // ETagUpdate sets the updated ETag value. If not set, it is incremented from the // ETag field if that field is set. ETagUpdate *ETag `json:"-" bson:"etag,omitempty"` // user email address Email Email `json:"email,omitempty" bson:",omitempty" valid:"email"` // user password Password string `json:"password,omitempty" bson:"password,omitempty"` // user password CurrentPassword string `json:"current_password,omitempty" bson:"-"` // timestamp of the last user information update UpdatedTs *time.Time `json:"-" bson:"updated_ts,omitempty"` // token used to update the user, optional Token *jwt.Token `json:"-" bson:"-"` LoginTs *time.Time `json:"-" bson:"login_ts,omitempty"` }
func (UserUpdate) Validate ¶
func (u UserUpdate) Validate() error
Click to show internal directories.
Click to hide internal directories.