service

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyService

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

func NewAPIKeyService

func NewAPIKeyService(db *gorm.DB) APIKeyService

func (APIKeyService) CreateAPIKey

func (svc APIKeyService) CreateAPIKey(ctx context.Context, params model.CreateAPIKeyParams) (model.APIKey, string, error)

func (APIKeyService) DeleteAPIKeyByID

func (svc APIKeyService) DeleteAPIKeyByID(ctx context.Context, id uint) error

func (APIKeyService) FindAPIKeyByID

func (svc APIKeyService) FindAPIKeyByID(ctx context.Context, id uint) (model.APIKey, error)

func (APIKeyService) FindAPIKeyByName

func (svc APIKeyService) FindAPIKeyByName(ctx context.Context, name string) (model.APIKey, error)

func (APIKeyService) GetAllAPIKeys

func (svc APIKeyService) GetAllAPIKeys(ctx context.Context) ([]model.APIKey, error)

type AdhocService added in v0.30.0

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

func NewAdhocService added in v0.30.0

func NewAdhocService(maxNodes int, dataDir string) *AdhocService

func (*AdhocService) GetAllProfiles added in v0.30.0

func (svc *AdhocService) GetAllProfiles(_ context.Context) ([]model.AdhocProfile, error)

GetAllProfiles retrieves the list of profiles for the local pyroscope data directory. The profiles are assigned a unique ID (hash based) which is then used for retrieval. This requires a bit of extra work to setup the IDs but prevents the clients from accesing the filesystem directly, removing that whole attack vector.

The profiles are retrieved every time the endpoint is requested, which should be good enough as massive access to this auth endpoint is not expected.

func (*AdhocService) GetProfileByID added in v0.30.0

func (svc *AdhocService) GetProfileByID(_ context.Context, id string) (*flamebearer.FlamebearerProfile, error)

func (*AdhocService) GetProfileDiffByID added in v0.30.0

func (*AdhocService) UploadProfile added in v0.30.0

type AnnotationsService added in v0.29.0

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

func NewAnnotationsService added in v0.29.0

func NewAnnotationsService(db *gorm.DB) AnnotationsService

func (AnnotationsService) CreateAnnotation added in v0.29.0

func (svc AnnotationsService) CreateAnnotation(ctx context.Context, params model.CreateAnnotation) (*model.Annotation, error)

CreateAnnotation creates a single annotation for a given application It does not check if the application has consumed any data

func (AnnotationsService) FindAnnotationsByTimeRange added in v0.29.0

func (svc AnnotationsService) FindAnnotationsByTimeRange(ctx context.Context, appName string, startTime time.Time, endTime time.Time) ([]model.Annotation, error)

FindAnnotationsByTimeRange finds all annotations for an app in a time range

type AppDeleter added in v0.34.1

type AppDeleter interface {
	DeleteApp(ctx context.Context, appName string) error
}

type ApplicationMetadataCacheService added in v0.34.0

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

func (*ApplicationMetadataCacheService) CreateOrUpdate added in v0.34.0

CreateOrUpdate delegates to the underlying service in the following cases: * item is not in the cache * data is different from what's in the cache Otherwise it does nothing

type ApplicationMetadataCacheServiceConfig added in v0.34.0

type ApplicationMetadataCacheServiceConfig struct {
	Size int
	TTL  time.Duration
}

type ApplicationMetadataService added in v0.34.0

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

func NewApplicationMetadataService added in v0.34.0

func NewApplicationMetadataService(db *gorm.DB) ApplicationMetadataService

func (ApplicationMetadataService) CreateOrUpdate added in v0.34.0

func (svc ApplicationMetadataService) CreateOrUpdate(ctx context.Context, application appmetadata.ApplicationMetadata) error

func (ApplicationMetadataService) Delete added in v0.34.0

func (svc ApplicationMetadataService) Delete(ctx context.Context, name string) error

func (ApplicationMetadataService) Get added in v0.34.0

func (ApplicationMetadataService) List added in v0.34.0

type ApplicationMetadataWriter added in v0.34.0

type ApplicationMetadataWriter interface {
	CreateOrUpdate(ctx context.Context, application appmetadata.ApplicationMetadata) error
}

type ApplicationService added in v0.34.1

type ApplicationService struct {
	ApplicationMetadataService
	// contains filtered or unexported fields
}

func NewApplicationService added in v0.34.1

func NewApplicationService(appMetadataSvc ApplicationMetadataService, storageDeleter AppDeleter) ApplicationService

NewApplicationService creates an ApplicationService Which just delegates to its underlying ApplicationMetadataService Except when deleting, which is then forward to both ApplicationMetadataService and storageDeleter

func (ApplicationService) Delete added in v0.34.1

func (svc ApplicationService) Delete(ctx context.Context, name string) error

Delete deletes apps from both storage and ApplicationMetadata It first deletes from storage and only then deletes its metadata

type AuthService

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

func NewAuthService

func NewAuthService(db *gorm.DB, jwtTokenService JWTTokenService) AuthService

func (AuthService) APIKeyFromToken

func (svc AuthService) APIKeyFromToken(ctx context.Context, t string) (model.APIKey, error)

func (AuthService) AuthenticateUser

func (svc AuthService) AuthenticateUser(ctx context.Context, name string, password string) (model.User, error)

AuthenticateUser returns User with the given login if its password hash matches the given one. If user cannot be found or the password does not match the function returns ErrCredentialsInvalid.

External users are not allowed to use password authentication. TODO(kolesnikovae): It's true for "some" authentication providers. Others may need us to pass through the credentials (e.g. LDAP).

func (AuthService) UserFromJWTToken

func (svc AuthService) UserFromJWTToken(ctx context.Context, t string) (model.User, error)

type CachingAuthService

type CachingAuthService struct {
	AuthService
	// contains filtered or unexported fields
}

func NewCachingAuthService

func NewCachingAuthService(authService AuthService, c CachingAuthServiceConfig) CachingAuthService

func (CachingAuthService) APIKeyFromToken

func (svc CachingAuthService) APIKeyFromToken(ctx context.Context, t string) (model.APIKey, error)

func (CachingAuthService) DeleteAPIKey

func (svc CachingAuthService) DeleteAPIKey(t string)

func (CachingAuthService) PutAPIKey

func (svc CachingAuthService) PutAPIKey(t string, k model.APIKey)

type CachingAuthServiceConfig

type CachingAuthServiceConfig struct {
	Size int
	TTL  time.Duration
}

type JWTTokenService

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

func NewJWTTokenService

func NewJWTTokenService(signingKey []byte, tokenTTL time.Duration) JWTTokenService

func (JWTTokenService) GenerateUserJWTToken

func (svc JWTTokenService) GenerateUserJWTToken(name string, role model.Role) *jwt.Token

func (JWTTokenService) Parse

func (svc JWTTokenService) Parse(t string) (*jwt.Token, error)

Parse parses the token and validates it using the signing key.

func (JWTTokenService) Sign

func (svc JWTTokenService) Sign(t *jwt.Token) (string, error)

func (JWTTokenService) UserFromJWTToken

func (JWTTokenService) UserFromJWTToken(t *jwt.Token) (model.TokenUser, bool)

UserFromJWTToken retrieves user info from the given JWT token. 'name' claim must be present and valid, otherwise the function returns false. The function does not validate the token.

type UserService

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

func NewUserService

func NewUserService(db *gorm.DB) UserService

func (UserService) CreateUser

func (svc UserService) CreateUser(ctx context.Context, params model.CreateUserParams) (model.User, error)

func (UserService) DeleteUserByID

func (svc UserService) DeleteUserByID(ctx context.Context, id uint) error

func (UserService) FindUserByEmail

func (svc UserService) FindUserByEmail(ctx context.Context, email string) (model.User, error)

func (UserService) FindUserByID

func (svc UserService) FindUserByID(ctx context.Context, id uint) (model.User, error)

func (UserService) FindUserByName

func (svc UserService) FindUserByName(ctx context.Context, name string) (model.User, error)

func (UserService) GetAllUsers

func (svc UserService) GetAllUsers(ctx context.Context) ([]model.User, error)

func (UserService) UpdateUserByID

func (svc UserService) UpdateUserByID(ctx context.Context, id uint, params model.UpdateUserParams) (model.User, error)

func (UserService) UpdateUserByName

func (svc UserService) UpdateUserByName(ctx context.Context, name string, params model.UpdateUserParams) (model.User, error)

func (UserService) UpdateUserPasswordByID

func (svc UserService) UpdateUserPasswordByID(ctx context.Context, id uint, params model.UpdateUserPasswordParams) error

Jump to

Keyboard shortcuts

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