Documentation ¶
Index ¶
- Variables
- func GetRuntimeInfo() (*runtime.Runtime, error)
- func PaginateSlice[T any](req api.PaginatedRequest, values []T, less func(a T, b T) bool, ...) (page []T, npt string, err error)
- func PaginateStorage[T any](req api.PaginatedRequest, storage persistence.Storage, opts PaginationOpts, ...) (page []T, npt string, err error)
- type AuthorizationStrategy
- type AuthorizationStrategyAllowAll
- type AuthorizationStrategyJWT
- type Option
- type PaginationOpts
- type RequestType
- type Service
Constants ¶
This section is empty.
Variables ¶
var DefaultPaginationOpts = PaginationOpts{
DefaultPageSize: 50,
MaxPageSize: 1500,
}
DefaultPaginationOpts are sensible defaults for the pagination size.
var ErrPermissionDenied = status.Errorf(codes.PermissionDenied, "access denied")
ErrPermissionDenied represents an error, where permission to fulfill the request is denied.
Functions ¶
func GetRuntimeInfo ¶
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 ¶
func (*AuthorizationStrategyAllowAll) CheckAccess(_ context.Context, _ RequestType, _ api.CertificationTargetRequest) bool
CheckAccess checks whether the current request can be fulfilled using the current access strategy. Returns true since strategy is `AuthorizationStrategyAllowAll`
type AuthorizationStrategyJWT ¶
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 ¶
func (a *AuthorizationStrategyJWT) CheckAccess(ctx context.Context, _ RequestType, req api.CertificationTargetRequest) bool
CheckAccess checks whether the current request can be fulfilled using the current access strategy.
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 )