tenant

package
v2.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 25 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

Variables

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

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

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

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

	ErrOnboardInvalid = &influxdb.Error{
		Code: influxdb.EEmptyValue,
		Msg:  "onboard failed, missing value",
	}

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

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

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

	// EIncorrectPassword is returned when any password operation fails in which
	// we do not want to leak information.
	EIncorrectPassword = &influxdb.Error{
		Code: influxdb.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 = &influxdb.Error{
		Code: influxdb.EForbidden,
		Msg:  "your userID is incorrect",
	}

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

Functions

func BucketAlreadyExistsError

func BucketAlreadyExistsError(n string) *influxdb.Error

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

func CorruptURMError

func CorruptURMError(err error) *influxdb.Error

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

func ErrBucketNotFoundByName

func ErrBucketNotFoundByName(n string) *influxdb.Error

ErrBucketNotFoundByName is used when the user is not found.

func ErrCorruptBucket

func ErrCorruptBucket(err error) *influxdb.Error

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

func ErrCorruptOrg

func ErrCorruptOrg(err error) *influxdb.Error

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

func ErrCorruptUser

func ErrCorruptUser(err error) *influxdb.Error

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

func ErrInternalServiceError

func ErrInternalServiceError(err error) *influxdb.Error

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

func ErrUnprocessableBucket

func ErrUnprocessableBucket(err error) *influxdb.Error

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

func ErrUnprocessableMapping

func ErrUnprocessableMapping(err error) *influxdb.Error

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

func ErrUnprocessableOrg

func ErrUnprocessableOrg(err error) *influxdb.Error

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

func ErrUnprocessableUser

func ErrUnprocessableUser(err error) *influxdb.Error

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

func InvalidOrgIDError

func InvalidOrgIDError(err error) *influxdb.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) *influxdb.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 influxdb.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) *influxdb.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) *influxdb.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) *influxdb.Error

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

func UnexpectedUserIndexError

func UnexpectedUserIndexError(err error) *influxdb.Error

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

func UserAlreadyExistsError

func UserAlreadyExistsError(n string) *influxdb.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 serivce.

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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 serivce.

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

func (*AuthedOnboardSvc) OnboardUser

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

OnboardUser needs to confirm this user has access to do global create for multiple resources

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 serivce.

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 influxdb.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 influxdb.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 influxdb.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 middlware.

func (*AuthedPasswordService) CompareAndSetPassword

func (s *AuthedPasswordService) CompareAndSetPassword(ctx context.Context, userID influxdb.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 influxdb.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 influxdb.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 influxdb.ID, userID influxdb.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 serivce.

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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.ID) (*influxdb.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketClientService) FindBucketByName

func (s *BucketClientService) FindBucketByName(ctx context.Context, orgID influxdb.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 influxdb.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 *influxdb.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 influxdb.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 influxdb.ID) (u *influxdb.Bucket, err error)

func (*BucketLogger) FindBucketByName

func (l *BucketLogger) FindBucketByName(ctx context.Context, orgID influxdb.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 influxdb.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 influxdb.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 influxdb.ID) (*influxdb.Bucket, error)

Returns a single bucket by ID.

func (*BucketMetrics) FindBucketByName

func (m *BucketMetrics) FindBucketByName(ctx context.Context, orgID influxdb.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 influxdb.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 influxdb.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 influxdb.ID) (*influxdb.Bucket, error)

FindBucketByID returns a single bucket by ID.

func (*BucketSvc) FindBucketByName

func (s *BucketSvc) FindBucketByName(ctx context.Context, orgID influxdb.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 influxdb.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.

func (*OnboardClientService) OnboardUser

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

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 allowd

func (*OnboardService) OnboardUser

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

OnboardUser 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.

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)

func (*OnboardingLogger) OnboardUser

func (l *OnboardingLogger) OnboardUser(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)

func (*OnboardingMetrics) OnboardUser

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

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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.ID, old string, new string) error

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

func (*PasswordClientService) ComparePassword

func (s *PasswordClientService) ComparePassword(ctx context.Context, userID influxdb.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 influxdb.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 influxdb.ID, old, new string) (err error)

func (*PasswordLogger) ComparePassword

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

func (*PasswordLogger) SetPassword

func (l *PasswordLogger) SetPassword(ctx context.Context, userID influxdb.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 influxdb.ID, old, new string) error

func (*PasswordMetrics) ComparePassword

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

func (*PasswordMetrics) SetPassword

func (m *PasswordMetrics) SetPassword(ctx context.Context, userID influxdb.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

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 influxdb.ID, userID influxdb.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       influxdb.IDGenerator
	OrgIDGen    influxdb.IDGenerator
	BucketIDGen influxdb.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 influxdb.ID) error

func (*Store) DeleteOrg

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

func (*Store) DeletePassword

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

func (*Store) DeleteURM

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

func (*Store) DeleteUser

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

func (*Store) GetBucket

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

func (*Store) GetBucketByName

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

func (*Store) GetOrg

func (s *Store) GetOrg(ctx context.Context, tx kv.Tx, id influxdb.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 influxdb.ID) (string, error)

func (*Store) GetURM

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

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, tx kv.Tx, id influxdb.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) SetPassword

func (s *Store) SetPassword(ctx context.Context, tx kv.Tx, id influxdb.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 influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error)

func (*Store) UpdateOrg

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

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, tx kv.Tx, id influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.ID) error

DeleteUser removes a user by ID.

func (*UserClientService) FindMe

func (s *UserClientService) FindMe(ctx context.Context, id influxdb.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 influxdb.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 influxdb.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 influxdb.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 influxdb.ID) (err error)

func (*UserLogger) FindPermissionForUser

func (l *UserLogger) FindPermissionForUser(ctx context.Context, id influxdb.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 influxdb.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 influxdb.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 influxdb.ID) error

func (*UserMetrics) FindPermissionForUser

func (m *UserMetrics) FindPermissionForUser(ctx context.Context, id influxdb.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 influxdb.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 influxdb.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 influxdb.ID, userID influxdb.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 UserResponse

type UserResponse struct {
	Links map[string]string `json:"links"`
	influxdb.User
}

UserResponse is the response of user

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 influxdb.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 influxdb.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 influxdb.ID) error

Removes a user by ID.

func (*UserSvc) FindPermissionForUser

func (s *UserSvc) FindPermissionForUser(ctx context.Context, uid influxdb.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 influxdb.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 influxdb.ID, password string) error

SetPassword overrides the password of a known user.

func (*UserSvc) UpdateUser

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

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

Jump to

Keyboard shortcuts

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