tenant

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

The tenant domain encapsulates all the storage critical metadata services: User Organization Bucket URM's

These services are the cornerstone of all other metadata services. The intent is to have a single location for all tenant related code. THis should facilitate faster bug resolution and allow us to make changes to this service without effecting any dependant services.

When a new request for the tenant service comes in it should follow this pattern: 1 http_server_resource - this is where the request is parsed and rejected if the client didn't send

the right information

2 middleware_resource_auth - We now confirm the user that generated the request has sufficient permission

to accomplish this task, in some cases we adjust the request if the user is without the correct permissions

3 middleware_resource_metrics - Track RED metrics for this request 4 middleware_resource_logging - add logging around request duration and status. 5 service_resource - When a request reaches the service we verify the content for compatibility with the existing dataset,

for instance if a resource has a "orgID" we will ensure the organization exists

6 storage_resource - Basic CRUD actions for the system.

This pattern of api -> middleware -> service -> basic crud helps us to break down the responsibilities into digestible chunks and allows us to swap in or out any pieces we need depending on the situation. Currently the storage layer is using a kv store but by breaking the crud actions into its own independent set of concerns we allow ourselves to move away from kv if the need arises without having to be concerned about messing up some other pieces of logic.

Index

Constants

View Source
const MaxIDGenerationN = 100
View Source
const MinPasswordLen int = 8

Variables

View Source
var (
	// ErrNameisEmpty is when a name is empty
	ErrNameisEmpty = &errors.Error{
		Code: errors.EInvalid,
		Msg:  "name is empty",
	}

	// ErrIDNotUnique is used when attempting to create an org or bucket that already
	// exists.
	ErrIDNotUnique = &errors.Error{
		Code: errors.EConflict,
		Msg:  "ID already exists",
	}

	// ErrFailureGeneratingID occurs ony when the random number generator
	// cannot generate an ID in MaxIDGenerationN times.
	ErrFailureGeneratingID = &errors.Error{
		Code: errors.EInternal,
		Msg:  "unable to generate valid id",
	}

	// ErrOnboardingNotAllowed occurs when request to onboard comes in and we are not allowing this request
	ErrOnboardingNotAllowed = &errors.Error{
		Code: errors.EConflict,
		Msg:  "onboarding has already been completed",
	}

	ErrNotFound = &errors.Error{
		Code: errors.ENotFound,
		Msg:  "not found",
	}
)
View Source
var (
	ErrBucketNotFound = &errors.Error{
		Code: errors.ENotFound,
		Msg:  "bucket not found",
	}

	ErrBucketNameNotUnique = &errors.Error{
		Code: errors.EConflict,
		Msg:  "bucket name is not unique",
	}
)
View Source
var (
	// ErrInvalidURMID is used when the service was provided
	// an invalid ID format.
	ErrInvalidURMID = &errors.Error{
		Code: errors.EInvalid,
		Msg:  "provided user resource mapping ID has invalid format",
	}

	// ErrURMNotFound is used when the user resource mapping is not found.
	ErrURMNotFound = &errors.Error{
		Msg:  "user to resource mapping not found",
		Code: errors.ENotFound,
	}
)
View Source
var (
	// ErrUserNotFound is used when the user is not found.
	ErrUserNotFound = &errors.Error{
		Msg:  "user not found",
		Code: errors.ENotFound,
	}

	// EIncorrectPassword is returned when any password operation fails in which
	// we do not want to leak information.
	EIncorrectPassword = &errors.Error{
		Code: errors.EForbidden,
		Msg:  "your username or password is incorrect",
	}

	// EIncorrectUser is returned when any user is failed to be found which indicates
	// the userID provided is for a user that does not exist.
	EIncorrectUser = &errors.Error{
		Code: errors.EForbidden,
		Msg:  "your userID is incorrect",
	}

	// EShortPassword is used when a password is less than the minimum
	// acceptable password length.
	EShortPassword = &errors.Error{
		Code: errors.EInvalid,
		Msg:  fmt.Sprintf("passwords must be at least %d characters long", MinPasswordLen),
	}
)
View Source
var (
	// ErrOrgNotFound is used when the user is not found.
	ErrOrgNotFound = &errors.Error{
		Msg:  "organization not found",
		Code: errors.ENotFound,
	}
)

Functions

func BucketAlreadyExistsError

func BucketAlreadyExistsError(n string) *errors.Error

BucketAlreadyExistsError is used when attempting to create a user with a name that already exists.

func CorruptURMError

func CorruptURMError(err error) *errors.Error

CorruptURMError is used when the config cannot be unmarshalled from the bytes stored in the kv.

func ErrBucketNotFoundByName

func ErrBucketNotFoundByName(n string) *errors.Error

ErrBucketNotFoundByName is used when the user is not found.

func ErrCorruptBucket

func ErrCorruptBucket(err error) *errors.Error

ErrCorruptBucket is used when the user cannot be unmarshalled from the bytes stored in the kv.

func ErrCorruptOrg

func ErrCorruptOrg(err error) *errors.Error

ErrCorruptOrg is used when the user cannot be unmarshalled from the bytes stored in the kv.

func ErrCorruptUser

func ErrCorruptUser(err error) *errors.Error

ErrCorruptUser is used when the user cannot be unmarshalled from the bytes stored in the kv.

func ErrInternalServiceError

func ErrInternalServiceError(err error) *errors.Error

ErrInternalServiceError is used when the error comes from an internal system.

func ErrUnprocessableBucket

func ErrUnprocessableBucket(err error) *errors.Error

ErrUnprocessableBucket is used when a org is not able to be processed.

func ErrUnprocessableMapping

func ErrUnprocessableMapping(err error) *errors.Error

ErrUnprocessableMapping is used when a user resource mapping is not able to be converted to JSON.

func ErrUnprocessableOrg

func ErrUnprocessableOrg(err error) *errors.Error

ErrUnprocessableOrg is used when a org is not able to be processed.

func ErrUnprocessableUser

func ErrUnprocessableUser(err error) *errors.Error

ErrUnprocessableUser is used when a user is not able to be processed.

func InvalidOrgIDError

func InvalidOrgIDError(err error) *errors.Error

InvalidOrgIDError is used when a service was provided an invalid ID. This is some sort of internal server error.

func InvalidUserIDError

func InvalidUserIDError(err error) *errors.Error

InvalidUserIDError is used when a service was provided an invalid ID. This is some sort of internal server error.

func NewBucketResponse

func NewBucketResponse(b *influxdb.Bucket, labels ...*influxdb.Label) *bucketResponse

func NewOnboardService

func NewOnboardService(svc *Service, as influxdb.AuthorizationService, opts ...OnboardServiceOptionFn) influxdb.OnboardingService

func NewOnboardingResponse

func NewOnboardingResponse(results *influxdb.OnboardingResults) *onboardingResponse

func NewURMHandler

func NewURMHandler(log *zap.Logger, rt influxdb.ResourceType, idLookupKey string, uSvc influxdb.UserService, urmSvc influxdb.UserResourceMappingService) http.Handler

NewURMHandler generates a mountable handler for URMs. It needs to know how it will be looking up your resource id this system assumes you are using chi syntax for query string params `/orgs/{id}/` so it can use chi.URLParam().

func NonUniqueMappingError

func NonUniqueMappingError(userID platform.ID) error

NonUniqueMappingError is an internal error when a user already has been mapped to a resource

func OrgAlreadyExistsError

func OrgAlreadyExistsError(name string) error

OrgAlreadyExistsError is used when creating a new organization with a name that has already been used. Organization names must be unique.

func OrgNotFoundByName

func OrgNotFoundByName(name string) error

func UnavailablePasswordServiceError

func UnavailablePasswordServiceError(err error) *errors.Error

UnavailablePasswordServiceError is used if we aren't able to add the password to the store, it means the store is not available at the moment (e.g. network).

func UnavailableURMServiceError

func UnavailableURMServiceError(err error) *errors.Error

UnavailableURMServiceError is used if we aren't able to interact with the store, it means the store is not available at the moment (e.g. network).

func UnexpectedUserBucketError

func UnexpectedUserBucketError(err error) *errors.Error

UnexpectedUserBucketError is used when the error comes from an internal system.

func UnexpectedUserIndexError

func UnexpectedUserIndexError(err error) *errors.Error

UnexpectedUserIndexError is used when the error comes from an internal system.

func UserAlreadyExistsError

func UserAlreadyExistsError(n string) *errors.Error

UserAlreadyExistsError is used when attempting to create a user with a name that already exists.

Types

type AggregateError

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

AggregateError enables composing multiple errors. This is ideal in the case that you are applying functions with side effects to a slice of elements. E.g., deleting/updating a slice of resources.

func NewAggregateError

func NewAggregateError() *AggregateError

NewAggregateError returns a new AggregateError.

func (*AggregateError) Add

func (e *AggregateError) Add(err error)

Add adds an error to the aggregate.

func (*AggregateError) Err

func (e *AggregateError) Err() error

Err returns a proper error from this aggregate error.

type AuthedBucketService

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

AuthedBucketService wraps a influxdb.BucketService and authorizes actions against it appropriately.

func NewAuthedBucketService

func NewAuthedBucketService(s influxdb.BucketService) *AuthedBucketService

NewAuthedBucketService constructs an instance of an authorizing bucket service.

func (*AuthedBucketService) CreateBucket

func (s *AuthedBucketService) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

CreateBucket checks to see if the authorizer on context has write access to the global buckets resource.

func (*AuthedBucketService) DeleteBucket

func (s *AuthedBucketService) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket checks to see if the authorizer on context has write access to the bucket provided.

func (*AuthedBucketService) FindBucket

func (s *AuthedBucketService) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error)

FindBucket retrieves the bucket and checks to see if the authorizer on context has read access to the bucket.

func (*AuthedBucketService) FindBucketByID

func (s *AuthedBucketService) FindBucketByID(ctx context.Context, id platform.ID) (*influxdb.Bucket, error)

FindBucketByID checks to see if the authorizer on context has read access to the id provided.

func (*AuthedBucketService) FindBucketByName

func (s *AuthedBucketService) FindBucketByName(ctx context.Context, orgID platform.ID, n string) (*influxdb.Bucket, error)

FindBucketByName returns a bucket by name for a particular organization.

func (*AuthedBucketService) FindBuckets

func (s *AuthedBucketService) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)

FindBuckets retrieves all buckets that match the provided filter and then filters the list down to only the resources that are authorized.

func (*AuthedBucketService) UpdateBucket

func (s *AuthedBucketService) UpdateBucket(ctx context.Context, id platform.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

UpdateBucket checks to see if the authorizer on context has write access to the bucket provided.

type AuthedOnboardSvc

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

AuthedOnboardSvc wraps a influxdb.OnboardingService and authorizes actions against it appropriately.

func NewAuthedOnboardSvc

func NewAuthedOnboardSvc(s influxdb.OnboardingService) *AuthedOnboardSvc

NewAuthedOnboardSvc constructs an instance of an authorizing org service.

func (*AuthedOnboardSvc) IsOnboarding

func (s *AuthedOnboardSvc) IsOnboarding(ctx context.Context) (bool, error)

IsOnboarding pass through. this is handled by the underlying service layer

func (*AuthedOnboardSvc) OnboardInitialUser

func (s *AuthedOnboardSvc) OnboardInitialUser(ctx context.Context, req *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error)

OnboardInitialUser pass through. this is handled by the underlying service layer

type AuthedOrgService

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

AuthedOrgService wraps a influxdb.OrganizationService and authorizes actions against it appropriately.

func NewAuthedOrgService

func NewAuthedOrgService(s influxdb.OrganizationService) *AuthedOrgService

NewAuthedOrgService constructs an instance of an authorizing org service.

func (*AuthedOrgService) CreateOrganization

func (s *AuthedOrgService) CreateOrganization(ctx context.Context, o *influxdb.Organization) error

CreateOrganization checks to see if the authorizer on context has write access to the global orgs resource.

func (*AuthedOrgService) DeleteOrganization

func (s *AuthedOrgService) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization checks to see if the authorizer on context has write access to the organization provided.

func (*AuthedOrgService) FindOrganization

func (s *AuthedOrgService) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error)

FindOrganization retrieves the organization and checks to see if the authorizer on context has read access to the org.

func (*AuthedOrgService) FindOrganizationByID

func (s *AuthedOrgService) FindOrganizationByID(ctx context.Context, id platform.ID) (*influxdb.Organization, error)

FindOrganizationByID checks to see if the authorizer on context has read access to the id provided.

func (*AuthedOrgService) FindOrganizations

func (s *AuthedOrgService) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) ([]*influxdb.Organization, int, error)

FindOrganizations retrieves all organizations that match the provided filter and then filters the list down to only the resources that are authorized.

func (*AuthedOrgService) UpdateOrganization

func (s *AuthedOrgService) UpdateOrganization(ctx context.Context, id platform.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

UpdateOrganization checks to see if the authorizer on context has write access to the organization provided.

type AuthedPasswordService

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

AuthedPasswordService is a new authorization middleware for a password service.

func NewAuthedPasswordService

func NewAuthedPasswordService(svc influxdb.PasswordsService) *AuthedPasswordService

NewAuthedPasswordService wraps an existing password service with auth middleware.

func (*AuthedPasswordService) CompareAndSetPassword

func (s *AuthedPasswordService) CompareAndSetPassword(ctx context.Context, userID platform.ID, old string, new string) error

CompareAndSetPassword checks the password and if they match updates to the new password.

func (*AuthedPasswordService) ComparePassword

func (s *AuthedPasswordService) ComparePassword(ctx context.Context, userID platform.ID, password string) error

ComparePassword checks if the password matches the password recorded. Passwords that do not match return errors.

func (*AuthedPasswordService) SetPassword

func (s *AuthedPasswordService) SetPassword(ctx context.Context, userID platform.ID, password string) error

SetPassword overrides the password of a known user.

type AuthedURMService

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

func NewAuthedURMService

func NewAuthedURMService(orgSvc influxdb.OrganizationService, s influxdb.UserResourceMappingService) *AuthedURMService

func (*AuthedURMService) CreateUserResourceMapping

func (s *AuthedURMService) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error

func (*AuthedURMService) DeleteUserResourceMapping

func (s *AuthedURMService) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

func (*AuthedURMService) FindUserResourceMappings

func (s *AuthedURMService) FindUserResourceMappings(ctx context.Context, filter influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

type AuthedUserService

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

AuthedUserService wraps a influxdb.UserService and authorizes actions against it appropriately.

func NewAuthedUserService

func NewAuthedUserService(s influxdb.UserService) *AuthedUserService

NewAuthedUserService constructs an instance of an authorizing user service.

func (*AuthedUserService) CreateUser

func (s *AuthedUserService) CreateUser(ctx context.Context, o *influxdb.User) error

CreateUser checks to see if the authorizer on context has write access to the global users resource.

func (*AuthedUserService) DeleteUser

func (s *AuthedUserService) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser checks to see if the authorizer on context has write access to the user provided.

func (*AuthedUserService) FindPermissionForUser

func (s *AuthedUserService) FindPermissionForUser(ctx context.Context, id platform.ID) (influxdb.PermissionSet, error)

func (*AuthedUserService) FindUser

func (s *AuthedUserService) FindUser(ctx context.Context, filter influxdb.UserFilter) (*influxdb.User, error)

FindUser retrieves the user and checks to see if the authorizer on context has read access to the user.

func (*AuthedUserService) FindUserByID

func (s *AuthedUserService) FindUserByID(ctx context.Context, id platform.ID) (*influxdb.User, error)

FindUserByID checks to see if the authorizer on context has read access to the id provided.

func (*AuthedUserService) FindUsers

func (s *AuthedUserService) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) ([]*influxdb.User, int, error)

FindUsers retrieves all users that match the provided filter and then filters the list down to only the resources that are authorized.

func (*AuthedUserService) UpdateUser

func (s *AuthedUserService) UpdateUser(ctx context.Context, id platform.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

UpdateUser checks to see if the authorizer on context has write access to the user provided.

type BucketClientService

type BucketClientService struct {
	Client *httpc.Client
	// OpPrefix is an additional property for error
	// find bucket service, when finds nothing.
	OpPrefix string
}

BucketClientService connects to Influx via HTTP using tokens to manage buckets

func (*BucketClientService) CreateBucket

func (s *BucketClientService) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

CreateBucket creates a new bucket and sets b.ID with the new identifier.

func (*BucketClientService) DeleteBucket

func (s *BucketClientService) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket removes a bucket by ID.

func (*BucketClientService) FindBucket

func (s *BucketClientService) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error)

FindBucket returns the first bucket that matches filter.

func (*BucketClientService) FindBucketByID

func (s *BucketClientService) FindBucketByID(ctx context.Context, id platform.ID) (*influxdb.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketClientService) FindBucketByName

func (s *BucketClientService) FindBucketByName(ctx context.Context, orgID platform.ID, name string) (*influxdb.Bucket, error)

FindBucketByName returns a single bucket by name

func (*BucketClientService) FindBuckets

func (s *BucketClientService) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets. Additional options provide pagination & sorting.

func (*BucketClientService) UpdateBucket

func (s *BucketClientService) UpdateBucket(ctx context.Context, id platform.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

UpdateBucket updates a single bucket with changeset. Returns the new bucket state after update.

type BucketFilter

type BucketFilter struct {
	Name           *string
	OrganizationID *platform.ID
}

type BucketHandler

type BucketHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

BucketHandler represents an HTTP API handler for users.

func NewHTTPBucketHandler

func NewHTTPBucketHandler(log *zap.Logger, bucketSvc influxdb.BucketService, labelSvc influxdb.LabelService, urmHandler, labelHandler http.Handler) *BucketHandler

NewHTTPBucketHandler constructs a new http server.

func (*BucketHandler) Prefix

func (h *BucketHandler) Prefix() string

type BucketLogger

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

func NewBucketLogger

func NewBucketLogger(log *zap.Logger, s influxdb.BucketService) *BucketLogger

NewBucketLogger returns a logging service middleware for the Bucket Service.

func (*BucketLogger) CreateBucket

func (l *BucketLogger) CreateBucket(ctx context.Context, u *influxdb.Bucket) (err error)

func (*BucketLogger) DeleteBucket

func (l *BucketLogger) DeleteBucket(ctx context.Context, id platform.ID) (err error)

func (*BucketLogger) FindBucket

func (l *BucketLogger) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (u *influxdb.Bucket, err error)

func (*BucketLogger) FindBucketByID

func (l *BucketLogger) FindBucketByID(ctx context.Context, id platform.ID) (u *influxdb.Bucket, err error)

func (*BucketLogger) FindBucketByName

func (l *BucketLogger) FindBucketByName(ctx context.Context, orgID platform.ID, name string) (u *influxdb.Bucket, err error)

func (*BucketLogger) FindBuckets

func (l *BucketLogger) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) (buckets []*influxdb.Bucket, n int, err error)

func (*BucketLogger) UpdateBucket

func (l *BucketLogger) UpdateBucket(ctx context.Context, id platform.ID, upd influxdb.BucketUpdate) (u *influxdb.Bucket, err error)

type BucketMetrics

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

func NewBucketMetrics

func NewBucketMetrics(reg prometheus.Registerer, s influxdb.BucketService, opts ...metric.ClientOptFn) *BucketMetrics

NewBucketMetrics returns a metrics service middleware for the Bucket Service.

func (*BucketMetrics) CreateBucket

func (m *BucketMetrics) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

Creates a new bucket and sets b.ID with the new identifier.

func (*BucketMetrics) DeleteBucket

func (m *BucketMetrics) DeleteBucket(ctx context.Context, id platform.ID) error

Removes a bucket by ID.

func (*BucketMetrics) FindBucket

func (m *BucketMetrics) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error)

Returns the first bucket that matches filter.

func (*BucketMetrics) FindBucketByID

func (m *BucketMetrics) FindBucketByID(ctx context.Context, id platform.ID) (*influxdb.Bucket, error)

Returns a single bucket by ID.

func (*BucketMetrics) FindBucketByName

func (m *BucketMetrics) FindBucketByName(ctx context.Context, orgID platform.ID, name string) (*influxdb.Bucket, error)

FindBucketByName finds a Bucket given its name and Organization ID

func (*BucketMetrics) FindBuckets

func (m *BucketMetrics) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets.

func (*BucketMetrics) UpdateBucket

func (m *BucketMetrics) UpdateBucket(ctx context.Context, id platform.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

Updates a single bucket with changeset and returns the new bucket state after update.

type BucketSvc

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

func NewBucketSvc

func NewBucketSvc(st *Store, svc *Service) *BucketSvc

func (*BucketSvc) CreateBucket

func (s *BucketSvc) CreateBucket(ctx context.Context, b *influxdb.Bucket) error

CreateBucket creates a new bucket and sets b.ID with the new identifier.

func (*BucketSvc) DeleteBucket

func (s *BucketSvc) DeleteBucket(ctx context.Context, id platform.ID) error

DeleteBucket removes a bucket by ID.

func (*BucketSvc) FindBucket

func (s *BucketSvc) FindBucket(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error)

FindBucket returns the first bucket that matches filter.

func (*BucketSvc) FindBucketByID

func (s *BucketSvc) FindBucketByID(ctx context.Context, id platform.ID) (*influxdb.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketSvc) FindBucketByName

func (s *BucketSvc) FindBucketByName(ctx context.Context, orgID platform.ID, name string) (*influxdb.Bucket, error)

func (*BucketSvc) FindBuckets

func (s *BucketSvc) FindBuckets(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error)

FindBuckets returns a list of buckets that match filter and the total count of matching buckets. Additional options provide pagination & sorting.

func (*BucketSvc) UpdateBucket

func (s *BucketSvc) UpdateBucket(ctx context.Context, id platform.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

UpdateBucket updates a single bucket with changeset. Returns the new bucket state after update.

type OnboardClientService

type OnboardClientService struct {
	Client *httpc.Client
}

OnboardClientService connects to Influx via HTTP to perform onboarding operations

func (*OnboardClientService) IsOnboarding

func (s *OnboardClientService) IsOnboarding(ctx context.Context) (bool, error)

IsOnboarding determine if onboarding request is allowed.

func (*OnboardClientService) OnboardInitialUser

func (s *OnboardClientService) OnboardInitialUser(ctx context.Context, or *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error)

OnboardInitialUser OnboardingResults.

type OnboardHandler

type OnboardHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

OnboardHandler represents an HTTP API handler for users.

func NewHTTPOnboardHandler

func NewHTTPOnboardHandler(log *zap.Logger, onboardSvc influxdb.OnboardingService) *OnboardHandler

NewHTTPOnboardHandler constructs a new http server.

func (*OnboardHandler) Prefix

func (h *OnboardHandler) Prefix() string

type OnboardService

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

func (*OnboardService) IsOnboarding

func (s *OnboardService) IsOnboarding(ctx context.Context) (bool, error)

IsOnboarding determine if onboarding request is allowed.

func (*OnboardService) OnboardInitialUser

func (s *OnboardService) OnboardInitialUser(ctx context.Context, req *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error)

OnboardInitialUser allows us to onboard a new user if is onboarding is allowed

type OnboardServiceOptionFn

type OnboardServiceOptionFn func(*OnboardService)

func WithAlwaysAllowInitialUser

func WithAlwaysAllowInitialUser() OnboardServiceOptionFn

WithAlwaysAllowInitialUser configures the OnboardService to always return true for IsOnboarding to allow multiple initial onboard requests.

func WithOnboardingLogger added in v2.0.4

func WithOnboardingLogger(logger *zap.Logger) OnboardServiceOptionFn

type OnboardingLogger

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

func NewOnboardingLogger

func NewOnboardingLogger(log *zap.Logger, s influxdb.OnboardingService) *OnboardingLogger

NewOnboardingLogger returns a logging service middleware for the Bucket Service.

func (*OnboardingLogger) IsOnboarding

func (l *OnboardingLogger) IsOnboarding(ctx context.Context) (available bool, err error)

func (*OnboardingLogger) OnboardInitialUser

func (l *OnboardingLogger) OnboardInitialUser(ctx context.Context, req *influxdb.OnboardingRequest) (res *influxdb.OnboardingResults, err error)

type OnboardingMetrics

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

func NewOnboardingMetrics

func NewOnboardingMetrics(reg prometheus.Registerer, s influxdb.OnboardingService, opts ...metric.ClientOptFn) *OnboardingMetrics

NewOnboardingMetrics returns a metrics service middleware for the User Service.

func (*OnboardingMetrics) IsOnboarding

func (m *OnboardingMetrics) IsOnboarding(ctx context.Context) (bool, error)

func (*OnboardingMetrics) OnboardInitialUser

func (m *OnboardingMetrics) OnboardInitialUser(ctx context.Context, req *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error)

type OpLogService added in v2.0.2

type OpLogService struct {
	TimeGenerator influxdb.TimeGenerator
	// contains filtered or unexported fields
}

OpLogService is a type which stores operation logs for buckets, users and orgs.

func NewOpLogService added in v2.0.2

func NewOpLogService(store kv.Store, opLogStore OpLogStore) *OpLogService

NewOpLogService constructs and configures a new op log service.

func (*OpLogService) GetBucketOperationLog added in v2.0.2

func (s *OpLogService) GetBucketOperationLog(ctx context.Context, id platform.ID, opts influxdb.FindOptions) ([]*influxdb.OperationLogEntry, int, error)

GetBucketOperationLog retrieves a buckets operation log.

func (*OpLogService) GetOrganizationOperationLog added in v2.0.2

func (s *OpLogService) GetOrganizationOperationLog(ctx context.Context, id platform.ID, opts influxdb.FindOptions) ([]*influxdb.OperationLogEntry, int, error)

GetOrganizationOperationLog retrieves a organization operation log.

func (*OpLogService) GetUserOperationLog added in v2.0.2

func (s *OpLogService) GetUserOperationLog(ctx context.Context, id platform.ID, opts influxdb.FindOptions) ([]*influxdb.OperationLogEntry, int, error)

GetUserOperationLog retrieves a user operation log.

type OpLogStore added in v2.0.2

type OpLogStore interface {
	AddLogEntryTx(ctx context.Context, tx kv.Tx, k, v []byte, t time.Time) error
	ForEachLogEntryTx(ctx context.Context, tx kv.Tx, k []byte, opts influxdb.FindOptions, fn func([]byte, time.Time) error) error
}

OpLogStore is a type which persists and reports operation log entries on a backing kv store transaction.

type OrgClientService

type OrgClientService struct {
	Client *httpc.Client
	// OpPrefix is for not found errors.
	OpPrefix string
}

OrgClientService connects to Influx via HTTP using tokens to manage organizations

func (*OrgClientService) CreateOrganization

func (s *OrgClientService) CreateOrganization(ctx context.Context, o *influxdb.Organization) error

CreateOrganization creates an organization.

func (*OrgClientService) DeleteOrganization

func (s *OrgClientService) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization removes organization id over HTTP.

func (*OrgClientService) FindOrganization

func (s *OrgClientService) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error)

FindOrganization gets a single organization matching the filter using HTTP.

func (*OrgClientService) FindOrganizationByID

func (s *OrgClientService) FindOrganizationByID(ctx context.Context, id platform.ID) (*influxdb.Organization, error)

FindOrganizationByID gets a single organization with a given id using HTTP.

func (*OrgClientService) FindOrganizations

func (s *OrgClientService) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) ([]*influxdb.Organization, int, error)

FindOrganizations returns all organizations that match the filter via HTTP.

func (*OrgClientService) UpdateOrganization

func (s *OrgClientService) UpdateOrganization(ctx context.Context, id platform.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

UpdateOrganization updates the organization over HTTP.

type OrgHandler

type OrgHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

OrgHandler represents an HTTP API handler for organizations.

func NewHTTPOrgHandler

func NewHTTPOrgHandler(log *zap.Logger, orgService influxdb.OrganizationService, urm http.Handler, secretHandler http.Handler) *OrgHandler

NewHTTPOrgHandler constructs a new http server.

func (*OrgHandler) Prefix

func (h *OrgHandler) Prefix() string

type OrgLogger

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

func NewOrgLogger

func NewOrgLogger(log *zap.Logger, s influxdb.OrganizationService) *OrgLogger

NewOrgLogger returns a logging service middleware for the Organization Service.

func (*OrgLogger) CreateOrganization

func (l *OrgLogger) CreateOrganization(ctx context.Context, u *influxdb.Organization) (err error)

func (*OrgLogger) DeleteOrganization

func (l *OrgLogger) DeleteOrganization(ctx context.Context, id platform.ID) (err error)

func (*OrgLogger) FindOrganization

func (l *OrgLogger) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (u *influxdb.Organization, err error)

func (*OrgLogger) FindOrganizationByID

func (l *OrgLogger) FindOrganizationByID(ctx context.Context, id platform.ID) (u *influxdb.Organization, err error)

func (*OrgLogger) FindOrganizations

func (l *OrgLogger) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) (orgs []*influxdb.Organization, n int, err error)

func (*OrgLogger) UpdateOrganization

func (l *OrgLogger) UpdateOrganization(ctx context.Context, id platform.ID, upd influxdb.OrganizationUpdate) (u *influxdb.Organization, err error)

type OrgMetrics

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

func NewOrgMetrics

func NewOrgMetrics(reg prometheus.Registerer, s influxdb.OrganizationService, opts ...metric.ClientOptFn) *OrgMetrics

NewOrgMetrics returns a metrics service middleware for the Organization Service.

func (*OrgMetrics) CreateOrganization

func (m *OrgMetrics) CreateOrganization(ctx context.Context, b *influxdb.Organization) error

func (*OrgMetrics) DeleteOrganization

func (m *OrgMetrics) DeleteOrganization(ctx context.Context, id platform.ID) error

func (*OrgMetrics) FindOrganization

func (m *OrgMetrics) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error)

func (*OrgMetrics) FindOrganizationByID

func (m *OrgMetrics) FindOrganizationByID(ctx context.Context, id platform.ID) (*influxdb.Organization, error)

func (*OrgMetrics) FindOrganizations

func (m *OrgMetrics) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) ([]*influxdb.Organization, int, error)

func (*OrgMetrics) UpdateOrganization

func (m *OrgMetrics) UpdateOrganization(ctx context.Context, id platform.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

type OrgSvc

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

func NewOrganizationSvc

func NewOrganizationSvc(st *Store, svc *Service) *OrgSvc

func (*OrgSvc) CreateOrganization

func (s *OrgSvc) CreateOrganization(ctx context.Context, o *influxdb.Organization) error

Creates a new organization and sets b.ID with the new identifier.

func (*OrgSvc) DeleteOrganization

func (s *OrgSvc) DeleteOrganization(ctx context.Context, id platform.ID) error

DeleteOrganization removes a organization by ID and its dependent resources.

func (*OrgSvc) FindOrganization

func (s *OrgSvc) FindOrganization(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error)

Returns the first organization that matches filter.

func (*OrgSvc) FindOrganizationByID

func (s *OrgSvc) FindOrganizationByID(ctx context.Context, id platform.ID) (*influxdb.Organization, error)

Returns a single organization by ID.

func (*OrgSvc) FindOrganizations

func (s *OrgSvc) FindOrganizations(ctx context.Context, filter influxdb.OrganizationFilter, opt ...influxdb.FindOptions) ([]*influxdb.Organization, int, error)

Returns a list of organizations that match filter and the total count of matching organizations. Additional options provide pagination & sorting.

func (*OrgSvc) UpdateOrganization

func (s *OrgSvc) UpdateOrganization(ctx context.Context, id platform.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

Updates a single organization with changeset. Returns the new organization state after update.

type PasswordClientService

type PasswordClientService struct {
	Client *httpc.Client
}

PasswordClientService is an http client to speak to the password service.

func (*PasswordClientService) CompareAndSetPassword

func (s *PasswordClientService) CompareAndSetPassword(ctx context.Context, userID platform.ID, old string, new string) error

CompareAndSetPassword compares the old and new password and submits the new password if possible. Note: is not implemented.

func (*PasswordClientService) ComparePassword

func (s *PasswordClientService) ComparePassword(ctx context.Context, userID platform.ID, password string) error

ComparePassword compares the user new password with existing. Note: is not implemented.

func (*PasswordClientService) SetPassword

func (s *PasswordClientService) SetPassword(ctx context.Context, userID platform.ID, password string) error

SetPassword sets the user's password.

type PasswordLogger

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

func NewPasswordLogger

func NewPasswordLogger(log *zap.Logger, s influxdb.PasswordsService) *PasswordLogger

NewPasswordLogger returns a logging service middleware for the Password Service.

func (*PasswordLogger) CompareAndSetPassword

func (l *PasswordLogger) CompareAndSetPassword(ctx context.Context, userID platform.ID, old, new string) (err error)

func (*PasswordLogger) ComparePassword

func (l *PasswordLogger) ComparePassword(ctx context.Context, userID platform.ID, password string) (err error)

func (*PasswordLogger) SetPassword

func (l *PasswordLogger) SetPassword(ctx context.Context, userID platform.ID, password string) (err error)

type PasswordMetrics

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

func NewPasswordMetrics

func NewPasswordMetrics(reg prometheus.Registerer, s influxdb.PasswordsService, opts ...metric.ClientOptFn) *PasswordMetrics

NewPasswordMetrics returns a metrics service middleware for the Password Service.

func (*PasswordMetrics) CompareAndSetPassword

func (m *PasswordMetrics) CompareAndSetPassword(ctx context.Context, userID platform.ID, old, new string) error

func (*PasswordMetrics) ComparePassword

func (m *PasswordMetrics) ComparePassword(ctx context.Context, userID platform.ID, password string) error

func (*PasswordMetrics) SetPassword

func (m *PasswordMetrics) SetPassword(ctx context.Context, userID platform.ID, password string) error

type Service

type Service struct {
	influxdb.UserService
	influxdb.PasswordsService
	influxdb.UserResourceMappingService
	influxdb.OrganizationService
	influxdb.BucketService
	// contains filtered or unexported fields
}

func NewService

func NewService(st *Store) *Service

NewService creates a new base tenant service.

func NewSystem

func NewSystem(store *Store, log *zap.Logger, reg prometheus.Registerer, metricOpts ...metric.ClientOptFn) *Service

creates a new Service with logging and metrics middleware wrappers.

func (*Service) NewBucketHTTPHandler

func (ts *Service) NewBucketHTTPHandler(log *zap.Logger, labelSvc influxdb.LabelService) *BucketHandler

func (*Service) NewOrgHTTPHandler

func (ts *Service) NewOrgHTTPHandler(log *zap.Logger, secretSvc influxdb.SecretService) *OrgHandler

func (*Service) NewUserHTTPHandler

func (ts *Service) NewUserHTTPHandler(log *zap.Logger) *UserHandler

func (*Service) RLock added in v2.1.0

func (s *Service) RLock()

func (*Service) RUnlock added in v2.1.0

func (s *Service) RUnlock()

type SpecificURMSvc

type SpecificURMSvc struct {
	Client *httpc.Client
	// contains filtered or unexported fields
}

SpecificURMSvc is a URM client that speaks to a specific resource with a specified user type

func (*SpecificURMSvc) CreateUserResourceMapping

func (s *SpecificURMSvc) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error

CreateUserResourceMapping will create a user resource mapping

func (*SpecificURMSvc) DeleteUserResourceMapping

func (s *SpecificURMSvc) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

DeleteUserResourceMapping will delete user resource mapping based in criteria.

func (*SpecificURMSvc) FindUserResourceMappings

func (s *SpecificURMSvc) FindUserResourceMappings(ctx context.Context, f influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

FindUserResourceMappings returns the user resource mappings

type Store

type Store struct {
	IDGen       platform.IDGenerator
	OrgIDGen    platform.IDGenerator
	BucketIDGen platform.IDGenerator
	// contains filtered or unexported fields
}

func NewStore

func NewStore(kvStore kv.Store, opts ...StoreOption) *Store

func (*Store) CreateBucket

func (s *Store) CreateBucket(ctx context.Context, tx kv.Tx, bucket *influxdb.Bucket) (err error)

func (*Store) CreateOrg

func (s *Store) CreateOrg(ctx context.Context, tx kv.Tx, o *influxdb.Organization) (err error)

func (*Store) CreateURM

func (s *Store) CreateURM(ctx context.Context, tx kv.Tx, urm *influxdb.UserResourceMapping) error

NOTE(affo): On URM creation, we check that the user exists. We do not check that the resource it is pointing to exists. This decision takes into account that different resources could not be in the same store. To perform that kind of check, we must rely on the service layer. However, we do not want having the storage layer depend on the service layer above.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, tx kv.Tx, u *influxdb.User) error

func (*Store) DeleteBucket

func (s *Store) DeleteBucket(ctx context.Context, tx kv.Tx, id platform.ID) error

func (*Store) DeleteOrg

func (s *Store) DeleteOrg(ctx context.Context, tx kv.Tx, id platform.ID) error

func (*Store) DeletePassword

func (s *Store) DeletePassword(ctx context.Context, tx kv.Tx, id platform.ID) error

func (*Store) DeleteURM

func (s *Store) DeleteURM(ctx context.Context, tx kv.Tx, resourceID, userID platform.ID) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, tx kv.Tx, id platform.ID) error

func (*Store) GetBucket

func (s *Store) GetBucket(ctx context.Context, tx kv.Tx, id platform.ID) (*influxdb.Bucket, error)

func (*Store) GetBucketByName

func (s *Store) GetBucketByName(ctx context.Context, tx kv.Tx, orgID platform.ID, n string) (*influxdb.Bucket, error)

func (*Store) GetOrg

func (s *Store) GetOrg(ctx context.Context, tx kv.Tx, id platform.ID) (*influxdb.Organization, error)

func (*Store) GetOrgByName

func (s *Store) GetOrgByName(ctx context.Context, tx kv.Tx, n string) (*influxdb.Organization, error)

func (*Store) GetPassword

func (s *Store) GetPassword(ctx context.Context, tx kv.Tx, id platform.ID) (string, error)

func (*Store) GetURM

func (s *Store) GetURM(ctx context.Context, tx kv.Tx, resourceID, userID platform.ID) (*influxdb.UserResourceMapping, error)

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, tx kv.Tx, id platform.ID) (*influxdb.User, error)

func (*Store) GetUserByName

func (s *Store) GetUserByName(ctx context.Context, tx kv.Tx, n string) (*influxdb.User, error)

func (*Store) ListBuckets

func (s *Store) ListBuckets(ctx context.Context, tx kv.Tx, filter BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, error)

func (*Store) ListOrgs

func (s *Store) ListOrgs(ctx context.Context, tx kv.Tx, opt ...influxdb.FindOptions) ([]*influxdb.Organization, error)

func (*Store) ListURMs

func (s *Store) ListURMs(ctx context.Context, tx kv.Tx, filter influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, tx kv.Tx, opt ...influxdb.FindOptions) ([]*influxdb.User, error)

func (*Store) RLock added in v2.1.0

func (s *Store) RLock()

func (*Store) RUnlock added in v2.1.0

func (s *Store) RUnlock()

func (*Store) SetPassword

func (s *Store) SetPassword(ctx context.Context, tx kv.Tx, id platform.ID, password string) error

func (*Store) Update

func (s *Store) Update(ctx context.Context, fn func(kv.Tx) error) error

Update opens up a transaction that will mutate data.

func (*Store) UpdateBucket

func (s *Store) UpdateBucket(ctx context.Context, tx kv.Tx, id platform.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

func (*Store) UpdateOrg

func (s *Store) UpdateOrg(ctx context.Context, tx kv.Tx, id platform.ID, upd influxdb.OrganizationUpdate) (*influxdb.Organization, error)

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, tx kv.Tx, id platform.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

func (*Store) View

func (s *Store) View(ctx context.Context, fn func(kv.Tx) error) error

View opens up a transaction that will not write to any data. Implementing interfaces should take care to ensure that all view transactions do not mutate any data.

type StoreOption

type StoreOption func(*Store)

type URMLogger

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

func NewURMLogger

func NewURMLogger(log *zap.Logger, s influxdb.UserResourceMappingService) *URMLogger

NewUrmLogger returns a logging service middleware for the User Resource Mapping Service.

func (*URMLogger) CreateUserResourceMapping

func (l *URMLogger) CreateUserResourceMapping(ctx context.Context, u *influxdb.UserResourceMapping) (err error)

func (*URMLogger) DeleteUserResourceMapping

func (l *URMLogger) DeleteUserResourceMapping(ctx context.Context, resourceID, userID platform.ID) (err error)

func (*URMLogger) FindUserResourceMappings

func (l *URMLogger) FindUserResourceMappings(ctx context.Context, filter influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) (urms []*influxdb.UserResourceMapping, n int, err error)

type URMSvc

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

func NewUserResourceMappingSvc

func NewUserResourceMappingSvc(st *Store, svc *Service) *URMSvc

func (*URMSvc) CreateUserResourceMapping

func (s *URMSvc) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error

CreateUserResourceMapping creates a user resource mapping.

func (*URMSvc) DeleteUserResourceMapping

func (s *URMSvc) DeleteUserResourceMapping(ctx context.Context, resourceID, userID platform.ID) error

DeleteUserResourceMapping deletes a user resource mapping.

func (*URMSvc) FindUserResourceMappings

func (s *URMSvc) FindUserResourceMappings(ctx context.Context, filter influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

FindUserResourceMappings returns a list of UserResourceMappings that match filter and the total count of matching mappings.

type UrmMetrics

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

func NewUrmMetrics

func NewUrmMetrics(reg prometheus.Registerer, s influxdb.UserResourceMappingService, opts ...metric.ClientOptFn) *UrmMetrics

NewUrmMetrics returns a metrics service middleware for the User Resource Mapping Service.

func (*UrmMetrics) CreateUserResourceMapping

func (m *UrmMetrics) CreateUserResourceMapping(ctx context.Context, urm *influxdb.UserResourceMapping) error

func (*UrmMetrics) DeleteUserResourceMapping

func (m *UrmMetrics) DeleteUserResourceMapping(ctx context.Context, resourceID, userID platform.ID) error

func (*UrmMetrics) FindUserResourceMappings

func (m *UrmMetrics) FindUserResourceMappings(ctx context.Context, filter influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

type UserClientService

type UserClientService struct {
	Client *httpc.Client
	// OpPrefix is the ops of not found error.
	OpPrefix string
}

UserService connects to Influx via HTTP using tokens to manage users

func (*UserClientService) CreateUser

func (s *UserClientService) CreateUser(ctx context.Context, u *influxdb.User) error

CreateUser creates a new user and sets u.ID with the new identifier.

func (*UserClientService) DeleteUser

func (s *UserClientService) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser removes a user by ID.

func (*UserClientService) FindMe

func (s *UserClientService) FindMe(ctx context.Context, id platform.ID) (*influxdb.User, error)

FindMe returns user information about the owner of the token

func (*UserClientService) FindPermissionForUser

func (s *UserClientService) FindPermissionForUser(ctx context.Context, id platform.ID) (influxdb.PermissionSet, error)

FindUserByID returns a single user by ID.

func (*UserClientService) FindUser

func (s *UserClientService) FindUser(ctx context.Context, filter influxdb.UserFilter) (*influxdb.User, error)

FindUser returns the first user that matches filter.

func (*UserClientService) FindUserByID

func (s *UserClientService) FindUserByID(ctx context.Context, id platform.ID) (*influxdb.User, error)

FindUserByID returns a single user by ID.

func (*UserClientService) FindUsers

func (s *UserClientService) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) ([]*influxdb.User, int, error)

FindUsers returns a list of users that match filter and the total count of matching users. Additional options provide pagination & sorting.

func (*UserClientService) UpdateUser

func (s *UserClientService) UpdateUser(ctx context.Context, id platform.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

UpdateUser updates a single user with changeset. Returns the new user state after update.

type UserHandler

type UserHandler struct {
	chi.Router
	// contains filtered or unexported fields
}

UserHandler represents an HTTP API handler for users.

func NewHTTPUserHandler

func NewHTTPUserHandler(log *zap.Logger, userService influxdb.UserService, passwordService influxdb.PasswordsService) *UserHandler

NewHTTPUserHandler constructs a new http server.

func (*UserHandler) MeResourceHandler

func (h *UserHandler) MeResourceHandler() *resourceHandler

func (*UserHandler) UserResourceHandler

func (h *UserHandler) UserResourceHandler() *resourceHandler

type UserLogger

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

func NewUserLogger

func NewUserLogger(log *zap.Logger, s influxdb.UserService) *UserLogger

NewUserLogger returns a logging service middleware for the User Service.

func (*UserLogger) CreateUser

func (l *UserLogger) CreateUser(ctx context.Context, u *influxdb.User) (err error)

func (*UserLogger) DeleteUser

func (l *UserLogger) DeleteUser(ctx context.Context, id platform.ID) (err error)

func (*UserLogger) FindPermissionForUser

func (l *UserLogger) FindPermissionForUser(ctx context.Context, id platform.ID) (ps influxdb.PermissionSet, err error)

func (*UserLogger) FindUser

func (l *UserLogger) FindUser(ctx context.Context, filter influxdb.UserFilter) (u *influxdb.User, err error)

func (*UserLogger) FindUserByID

func (l *UserLogger) FindUserByID(ctx context.Context, id platform.ID) (u *influxdb.User, err error)

func (*UserLogger) FindUsers

func (l *UserLogger) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) (users []*influxdb.User, n int, err error)

func (*UserLogger) UpdateUser

func (l *UserLogger) UpdateUser(ctx context.Context, id platform.ID, upd influxdb.UserUpdate) (u *influxdb.User, err error)

type UserMetrics

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

func NewUserMetrics

func NewUserMetrics(reg prometheus.Registerer, s influxdb.UserService, opts ...metric.ClientOptFn) *UserMetrics

NewUserMetrics returns a metrics service middleware for the User Service.

func (*UserMetrics) CreateUser

func (m *UserMetrics) CreateUser(ctx context.Context, u *influxdb.User) error

func (*UserMetrics) DeleteUser

func (m *UserMetrics) DeleteUser(ctx context.Context, id platform.ID) error

func (*UserMetrics) FindPermissionForUser

func (m *UserMetrics) FindPermissionForUser(ctx context.Context, id platform.ID) (influxdb.PermissionSet, error)

func (*UserMetrics) FindUser

func (m *UserMetrics) FindUser(ctx context.Context, filter influxdb.UserFilter) (*influxdb.User, error)

func (*UserMetrics) FindUserByID

func (m *UserMetrics) FindUserByID(ctx context.Context, id platform.ID) (*influxdb.User, error)

func (*UserMetrics) FindUsers

func (m *UserMetrics) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) ([]*influxdb.User, int, error)

func (*UserMetrics) UpdateUser

func (m *UserMetrics) UpdateUser(ctx context.Context, id platform.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

type UserResourceMappingClient

type UserResourceMappingClient struct {
	Client *httpc.Client
}

func (*UserResourceMappingClient) CreateUserResourceMapping

func (s *UserResourceMappingClient) CreateUserResourceMapping(ctx context.Context, m *influxdb.UserResourceMapping) error

CreateUserResourceMapping will create a user resource mapping

func (*UserResourceMappingClient) DeleteUserResourceMapping

func (s *UserResourceMappingClient) DeleteUserResourceMapping(ctx context.Context, resourceID platform.ID, userID platform.ID) error

DeleteUserResourceMapping will delete user resource mapping based in criteria.

func (*UserResourceMappingClient) FindUserResourceMappings

func (s *UserResourceMappingClient) FindUserResourceMappings(ctx context.Context, f influxdb.UserResourceMappingFilter, opt ...influxdb.FindOptions) ([]*influxdb.UserResourceMapping, int, error)

FindUserResourceMappings returns the user resource mappings

func (*UserResourceMappingClient) SpecificURMSvc

func (s *UserResourceMappingClient) SpecificURMSvc(rt influxdb.ResourceType, ut influxdb.UserType) *SpecificURMSvc

SpecificURMSvc returns a urm service with specific resource and user types. this will help us stay compatible with the existing service contract but also allow for urm deletes to go through the correct api

type UserSvc

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

func NewUserSvc

func NewUserSvc(st *Store, svc *Service) *UserSvc

func (*UserSvc) CompareAndSetPassword

func (s *UserSvc) CompareAndSetPassword(ctx context.Context, userID platform.ID, old, new string) error

CompareAndSetPassword checks the password and if they match updates to the new password.

func (*UserSvc) ComparePassword

func (s *UserSvc) ComparePassword(ctx context.Context, userID platform.ID, password string) error

ComparePassword checks if the password matches the password recorded. Passwords that do not match return errors.

func (*UserSvc) CreateUser

func (s *UserSvc) CreateUser(ctx context.Context, u *influxdb.User) error

Creates a new user and sets u.ID with the new identifier.

func (*UserSvc) DeleteUser

func (s *UserSvc) DeleteUser(ctx context.Context, id platform.ID) error

Removes a user by ID.

func (*UserSvc) FindPermissionForUser

func (s *UserSvc) FindPermissionForUser(ctx context.Context, uid platform.ID) (influxdb.PermissionSet, error)

FindPermissionForUser gets the full set of permission for a specified user id

func (*UserSvc) FindUser

func (s *UserSvc) FindUser(ctx context.Context, filter influxdb.UserFilter) (*influxdb.User, error)

Returns the first user that matches filter.

func (*UserSvc) FindUserByID

func (s *UserSvc) FindUserByID(ctx context.Context, id platform.ID) (*influxdb.User, error)

Returns a single user by ID.

func (*UserSvc) FindUsers

func (s *UserSvc) FindUsers(ctx context.Context, filter influxdb.UserFilter, opt ...influxdb.FindOptions) ([]*influxdb.User, int, error)

Returns a list of users that match filter and the total count of matching users. Additional options provide pagination & sorting. {

func (*UserSvc) SetPassword

func (s *UserSvc) SetPassword(ctx context.Context, userID platform.ID, password string) error

SetPassword overrides the password of a known user.

func (*UserSvc) UpdateUser

func (s *UserSvc) UpdateUser(ctx context.Context, id platform.ID, upd influxdb.UserUpdate) (*influxdb.User, error)

Updates a single user with changeset. Returns the new user state after update. {

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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