apiToken

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ConcurrentTokenUpdateRequest  = "there is an ongoing request for the token with the same name, please try again after some time"
	UniqueKeyViolationPgErrorCode = 23505
	TokenVersionMismatch          = "token version mismatch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiToken

type ApiToken struct {
	Id           int    `sql:"id,pk"`
	UserId       int32  `sql:"user_id, notnull"`
	Name         string `sql:"name, notnull"`
	Version      int    `sql:"version, notnull"`
	Description  string `sql:"description, notnull"`
	ExpireAtInMs int64  `sql:"expire_at_in_ms"`
	Token        string `sql:"token, notnull"`
	User         *repository.UserModel
	sql.AuditLog
	// contains filtered or unexported fields
}

type ApiTokenCustomClaims

type ApiTokenCustomClaims struct {
	Email   string `json:"email"`
	Version string `json:"version"`
	jwt.RegisteredClaims
}

type ApiTokenRepository

type ApiTokenRepository interface {
	Save(apiToken *ApiToken) error
	Update(apiToken *ApiToken) error
	FindAllActive() ([]*ApiToken, error)
	FindActiveById(id int) (*ApiToken, error)
	FindByName(name string) (*ApiToken, error)
	UpdateIf(apiToken *ApiToken, previousTokenVersion int) error
}

type ApiTokenRepositoryImpl

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

func NewApiTokenRepositoryImpl

func NewApiTokenRepositoryImpl(dbConnection *pg.DB) *ApiTokenRepositoryImpl

func (ApiTokenRepositoryImpl) FindActiveById

func (impl ApiTokenRepositoryImpl) FindActiveById(id int) (*ApiToken, error)

func (ApiTokenRepositoryImpl) FindAllActive

func (impl ApiTokenRepositoryImpl) FindAllActive() ([]*ApiToken, error)

func (ApiTokenRepositoryImpl) FindByName

func (impl ApiTokenRepositoryImpl) FindByName(name string) (*ApiToken, error)

func (ApiTokenRepositoryImpl) Save

func (impl ApiTokenRepositoryImpl) Save(apiToken *ApiToken) error

func (ApiTokenRepositoryImpl) Update

func (impl ApiTokenRepositoryImpl) Update(apiToken *ApiToken) error

func (ApiTokenRepositoryImpl) UpdateIf added in v0.7.0

func (impl ApiTokenRepositoryImpl) UpdateIf(apiToken *ApiToken, previousTokenVersion int) error

type ApiTokenSecretService

type ApiTokenSecretService interface {
	GetApiTokenSecretByteArr() ([]byte, error)
}

type ApiTokenSecretServiceImpl

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

func NewApiTokenSecretServiceImpl

func NewApiTokenSecretServiceImpl(logger *zap.SugaredLogger, attributesService attributes.AttributesService, apiTokenSecretStore *apiTokenAuth.ApiTokenSecretStore) (*ApiTokenSecretServiceImpl, error)

func (ApiTokenSecretServiceImpl) GetApiTokenSecretByteArr

func (impl ApiTokenSecretServiceImpl) GetApiTokenSecretByteArr() ([]byte, error)

type ApiTokenService

type ApiTokenService interface {
	GetAllActiveApiTokens() ([]*openapi.ApiToken, error)
	CreateApiToken(request *openapi.CreateApiTokenRequest, createdBy int32, managerAuth func(resource, token, object string) bool) (*openapi.CreateApiTokenResponse, error)
	UpdateApiToken(apiTokenId int, request *openapi.UpdateApiTokenRequest, updatedBy int32) (*openapi.UpdateApiTokenResponse, error)
	DeleteApiToken(apiTokenId int, deletedBy int32) (*openapi.ActionResponse, error)
	GetAllApiTokensForWebhook(projectName string, environmentName string, appName string, auth func(token string, projectObject string, envObject string) bool) ([]*openapi.ApiToken, error)
}

type ApiTokenServiceImpl

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

func NewApiTokenServiceImpl

func NewApiTokenServiceImpl(logger *zap.SugaredLogger, apiTokenSecretService ApiTokenSecretService, userService user2.UserService, userAuditService user2.UserAuditService,
	apiTokenRepository ApiTokenRepository) *ApiTokenServiceImpl

func (ApiTokenServiceImpl) CreateApiToken

func (impl ApiTokenServiceImpl) CreateApiToken(request *openapi.CreateApiTokenRequest, createdBy int32, managerAuth func(resource, token string, object string) bool) (*openapi.CreateApiTokenResponse, error)

func (ApiTokenServiceImpl) DeleteApiToken

func (impl ApiTokenServiceImpl) DeleteApiToken(apiTokenId int, deletedBy int32) (*openapi.ActionResponse, error)

func (ApiTokenServiceImpl) GetAllActiveApiTokens

func (impl ApiTokenServiceImpl) GetAllActiveApiTokens() ([]*openapi.ApiToken, error)

func (ApiTokenServiceImpl) GetAllApiTokensForWebhook added in v0.6.9

func (impl ApiTokenServiceImpl) GetAllApiTokensForWebhook(projectName string, environmentName string, appName string, auth func(token string, projectObject string, envObject string) bool) ([]*openapi.ApiToken, error)

func (ApiTokenServiceImpl) UpdateApiToken

func (impl ApiTokenServiceImpl) UpdateApiToken(apiTokenId int, request *openapi.UpdateApiTokenRequest, updatedBy int32) (*openapi.UpdateApiTokenResponse, error)

Jump to

Keyboard shortcuts

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