service

package
v2.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPaginationOpts = PaginationOpts{
	DefaultPageSize: 50,
	MaxPageSize:     1500,
}

DefaultPaginationOpts are sensible defaults for the pagination size.

View Source
var ErrPermissionDenied = status.Errorf(codes.PermissionDenied, "access denied")

ErrPermissionDenied represents an error, where permission to fulfill the request is denied.

Functions

func GetRuntimeInfo

func GetRuntimeInfo() (*runtime.Runtime, error)

GetRuntimeInfo implements method to get Clouditors runtime information

func PaginateSlice

func PaginateSlice[T any](req api.PaginatedRequest, values []T, less func(a T, b T) bool, opts PaginationOpts) (page []T, npt string, err error)

PaginateSlice is a helper function that helps to paginate a slice based on list requests. It parses the necessary information out if a paginated request, e.g. the page token and the desired page size and returns a sliced page as well as the next page token.

func PaginateStorage

func PaginateStorage[T any](req api.PaginatedRequest, storage persistence.Storage, opts PaginationOpts,
	conds ...interface{}) (page []T, npt string, err error)

PaginateStorage is a helper function that helps to paginate records in persisted storage based on list requests. It parses the necessary information out if a paginated request, e.g. the page token and the desired page size and returns a sliced page as well as the next page token.

Types

type AuthorizationStrategy

type AuthorizationStrategy interface {
	CheckAccess(ctx context.Context, typ RequestType, req api.CertificationTargetRequest) bool
	AllowedCertificationTargets(ctx context.Context) (all bool, IDs []string)
}

AuthorizationStrategy is an interface that implements a function which checkers whether the current certification target request can be fulfilled using the supplied context (e.g., based on the authenticated user).

type AuthorizationStrategyAllowAll

type AuthorizationStrategyAllowAll struct{}

AuthorizationStrategyAllowAll is an AuthorizationStrategy that allows all requests.

func (*AuthorizationStrategyAllowAll) AllowedCertificationTargets

func (*AuthorizationStrategyAllowAll) AllowedCertificationTargets(_ context.Context) (all bool, list []string)

AllowedCertificationTargets retrieves a list of allowed certification target IDs according to the current access strategy. Returns `all = true` since strategy is `AuthorizationStrategyAllowAll`

func (*AuthorizationStrategyAllowAll) CheckAccess

CheckAccess checks whether the current request can be fulfilled using the current access strategy. Returns true since strategy is `AuthorizationStrategyAllowAll`

type AuthorizationStrategyJWT

type AuthorizationStrategyJWT struct {
	CertificationTargetsKey string
	AllowAllKey             string
}

AuthorizationStrategyJWT is an AuthorizationStrategy that expects a list of certification target IDs to be in a specific JWT claim key.

func (*AuthorizationStrategyJWT) AllowedCertificationTargets

func (a *AuthorizationStrategyJWT) AllowedCertificationTargets(ctx context.Context) (all bool, list []string)

AllowedCertificationTargets retrieves a list of allowed certification target IDs according to the current access strategy.

func (*AuthorizationStrategyJWT) CheckAccess

CheckAccess checks whether the current request can be fulfilled using the current access strategy.

type Option

type Option[T any] func(T)

Option is a functional option type to configure services.

type PaginationOpts

type PaginationOpts struct {
	// DefaultPageSize is the page size that is used as a default if the request does not specify one
	DefaultPageSize int32

	// MaxPageSize is the maximum page size that can be requested
	MaxPageSize int32
}

PaginationOpts can be used to fine-tune the pagination, especially with regards to the page sizes. This can be important if the messages within a page are extremely large and thus the page size needs to be decreased.

type RequestType

type RequestType int

RequestType specifies the type of request, usually CRUD.

const (
	AccessCreate RequestType = iota
	AccessRead
	AccessUpdate
	AccessDelete
)

type Service

type Service interface {
	Init()
	Shutdown()
}

Directories

Path Synopsis
aws
k8s

Jump to

Keyboard shortcuts

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