apikey

package
v0.0.1-test Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = errors.New("API key not found")
	ErrInvalid           = errors.New("invalid API key")
	ErrInvalidExpiration = errors.New("negative value for SecondsToLive")
	ErrDuplicate         = errors.New("API key, organization ID and name must be unique")
)

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Id               int64        `db:"id"`
	OrgId            int64        `db:"org_id"`
	Name             string       `db:"name"`
	Key              string       `db:"key"`
	Role             org.RoleType `db:"role"`
	Created          time.Time    `db:"created"`
	Updated          time.Time    `db:"updated"`
	LastUsedAt       *time.Time   `xorm:"last_used_at" db:"last_used_at"`
	Expires          *int64       `db:"expires"`
	ServiceAccountId *int64       `db:"service_account_id"`
	IsRevoked        *bool        `xorm:"is_revoked" db:"is_revoked"`
}

func (APIKey) TableName

func (k APIKey) TableName() string

type AddCommand

type AddCommand struct {
	Name             string       `json:"name" binding:"Required"`
	Role             org.RoleType `json:"role" binding:"Required"`
	OrgId            int64        `json:"-"`
	Key              string       `json:"-"`
	SecondsToLive    int64        `json:"secondsToLive"`
	ServiceAccountID *int64       `json:"-"`

	Result *APIKey `json:"-"`
}

swagger:model

type DeleteCommand

type DeleteCommand struct {
	Id    int64 `json:"id"`
	OrgId int64 `json:"-"`
}

type GetApiKeysQuery

type GetApiKeysQuery struct {
	OrgId          int64
	IncludeExpired bool
	User           *user.SignedInUser
	Result         []*APIKey
}

type GetByIDQuery

type GetByIDQuery struct {
	ApiKeyId int64
	Result   *APIKey
}

type GetByNameQuery

type GetByNameQuery struct {
	KeyName string
	OrgId   int64
	Result  *APIKey
}

type Service

type Service interface {
	GetAPIKeys(ctx context.Context, query *GetApiKeysQuery) error
	GetAllAPIKeys(ctx context.Context, orgID int64) ([]*APIKey, error)
	DeleteApiKey(ctx context.Context, cmd *DeleteCommand) error
	AddAPIKey(ctx context.Context, cmd *AddCommand) error
	GetApiKeyById(ctx context.Context, query *GetByIDQuery) error
	GetApiKeyByName(ctx context.Context, query *GetByNameQuery) error
	GetAPIKeyByHash(ctx context.Context, hash string) (*APIKey, error)
	UpdateAPIKeyLastUsedDate(ctx context.Context, tokenID int64) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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