restapi

package
v0.0.0-...-6cfc1b2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package restapi provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version v1.11.1-0.20220609223533-7da811e1cf30 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type APIEventAnnotations

type APIEventAnnotations struct {
	BflaStatus           BFLAStatus    `json:"bflaStatus"`
	DestinationK8sObject *K8sObjectRef `json:"destinationK8sObject,omitempty"`
	DetectedUser         *DetectedUser `json:"detectedUser,omitempty"`
	External             bool          `json:"external"`
	MismatchedScopes     bool          `json:"mismatchedScopes"`
	SourceK8sObject      *K8sObjectRef `json:"sourceK8sObject,omitempty"`
}

APIEventAnnotations defines model for APIEventAnnotations.

type AuthorizationModel

type AuthorizationModel struct {
	Learning   bool                          `json:"learning"`
	Operations []AuthorizationModelOperation `json:"operations"`
	SpecType   SpecType                      `json:"specType"`
}

AuthorizationModel defines model for AuthorizationModel.

type AuthorizationModelAudience

type AuthorizationModelAudience struct {
	Authorized    bool           `json:"authorized"`
	EndUsers      []DetectedUser `json:"end_users"`
	External      bool           `json:"external"`
	K8sObject     *K8sObjectRef  `json:"k8s_object,omitempty"`
	LastTime      *time.Time     `json:"lastTime,omitempty"`
	StatusCode    int            `json:"statusCode"`
	WarningStatus BFLAStatus     `json:"warningStatus"`
}

AuthorizationModelAudience defines model for AuthorizationModelAudience.

type AuthorizationModelNotification

type AuthorizationModelNotification struct {
	Learning         bool                          `json:"learning"`
	NotificationType string                        `json:"notificationType"`
	Operations       []AuthorizationModelOperation `json:"operations"`
	SpecType         SpecType                      `json:"specType"`
}

AuthorizationModelNotification defines model for AuthorizationModelNotification.

type AuthorizationModelOperation

type AuthorizationModelOperation struct {
	Audience []AuthorizationModelAudience `json:"audience"`
	Method   string                       `json:"method"`
	Path     string                       `json:"path"`
	Tags     []string                     `json:"tags"`
}

AuthorizationModelOperation defines model for AuthorizationModelOperation.

type BFLAState

type BFLAState string

BFLAState defines model for BFLAState.

const (
	BFLADETECTING BFLAState = "BFLA_DETECTING"
	BFLALEARNING  BFLAState = "BFLA_LEARNING"
	BFLALEARNT    BFLAState = "BFLA_LEARNT"
	BFLASTART     BFLAState = "BFLA_START"
)

Defines values for BFLAState.

type BFLAStatus

type BFLAStatus string

BFLAStatus defines model for BFLAStatus.

const (
	LEARNING         BFLAStatus = "LEARNING"
	LEGITIMATE       BFLAStatus = "LEGITIMATE"
	NOSPEC           BFLAStatus = "NO_SPEC"
	SUSPICIOUSHIGH   BFLAStatus = "SUSPICIOUS_HIGH"
	SUSPICIOUSMEDIUM BFLAStatus = "SUSPICIOUS_MEDIUM"
)

Defines values for BFLAStatus.

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type DetectedUser

type DetectedUser struct {
	Id        string             `json:"id"`
	IpAddress string             `json:"ip_address"`
	Source    DetectedUserSource `json:"source"`
}

DetectedUser defines model for DetectedUser.

type DetectedUserSource

type DetectedUserSource string

DetectedUserSource defines model for DetectedUser.Source.

const (
	BASIC           DetectedUserSource = "BASIC"
	JWT             DetectedUserSource = "JWT"
	KONGXCONSUMERID DetectedUserSource = "KONG_X_CONSUMER_ID"
)

Defines values for DetectedUserSource.

type GetApiFindingsParams

type GetApiFindingsParams struct {
	// Should findings include sensitive data ?
	Sensitive *externalRef0.Sensitive `form:"sensitive,omitempty" json:"sensitive,omitempty"`
}

GetApiFindingsParams defines parameters for GetApiFindings.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type K8sObjectRef

type K8sObjectRef struct {
	ApiVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	Uid        string `json:"uid"`
}

K8sObjectRef defines model for K8sObjectRef.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type OperationEnum

type OperationEnum string

OperationEnum defines model for OperationEnum.

const (
	Approve     OperationEnum = "approve"
	ApproveUser OperationEnum = "approve_user"
	Deny        OperationEnum = "deny"
	DenyUser    OperationEnum = "deny_user"
)

Defines values for OperationEnum.

type PostAuthorizationModelApiIDJSONBody

type PostAuthorizationModelApiIDJSONBody = AuthorizationModel

PostAuthorizationModelApiIDJSONBody defines parameters for PostAuthorizationModelApiID.

type PostAuthorizationModelApiIDJSONRequestBody

type PostAuthorizationModelApiIDJSONRequestBody = PostAuthorizationModelApiIDJSONBody

PostAuthorizationModelApiIDJSONRequestBody defines body for PostAuthorizationModelApiID for application/json ContentType.

type PutAuthorizationModelApiIDApproveParams

type PutAuthorizationModelApiIDApproveParams struct {
	Method       string `form:"method" json:"method"`
	Path         string `form:"path" json:"path"`
	K8sClientUid string `form:"k8sClientUid" json:"k8sClientUid"`
}

PutAuthorizationModelApiIDApproveParams defines parameters for PutAuthorizationModelApiIDApprove.

type PutAuthorizationModelApiIDDenyParams

type PutAuthorizationModelApiIDDenyParams struct {
	Method       string `form:"method" json:"method"`
	Path         string `form:"path" json:"path"`
	K8sClientUid string `form:"k8sClientUid" json:"k8sClientUid"`
}

PutAuthorizationModelApiIDDenyParams defines parameters for PutAuthorizationModelApiIDDeny.

type PutAuthorizationModelApiIDLearningStartParams

type PutAuthorizationModelApiIDLearningStartParams struct {
	NrTraces *int `form:"nr_traces,omitempty" json:"nr_traces,omitempty"`
}

PutAuthorizationModelApiIDLearningStartParams defines parameters for PutAuthorizationModelApiIDLearningStart.

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServerInterface

type ServerInterface interface {
	// Get findings for an API and module
	// (GET /apiFindings/{apiID})
	GetApiFindings(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, params GetApiFindingsParams)

	// (GET /authorizationModel/{apiID})
	GetAuthorizationModelApiID(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (POST /authorizationModel/{apiID})
	PostAuthorizationModelApiID(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (PUT /authorizationModel/{apiID}/approve)
	PutAuthorizationModelApiIDApprove(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, params PutAuthorizationModelApiIDApproveParams)

	// (PUT /authorizationModel/{apiID}/deny)
	PutAuthorizationModelApiIDDeny(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, params PutAuthorizationModelApiIDDenyParams)

	// (PUT /authorizationModel/{apiID}/detection/start)
	PutAuthorizationModelApiIDDetectionStart(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (PUT /authorizationModel/{apiID}/detection/stop)
	PutAuthorizationModelApiIDDetectionStop(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (PUT /authorizationModel/{apiID}/learning/start)
	PutAuthorizationModelApiIDLearningStart(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID, params PutAuthorizationModelApiIDLearningStartParams)

	// (PUT /authorizationModel/{apiID}/learning/stop)
	PutAuthorizationModelApiIDLearningStop(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (POST /authorizationModel/{apiID}/reset)
	PostAuthorizationModelApiIDReset(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)

	// (GET /authorizationModel/{apiID}/state)
	GetAuthorizationModelApiIDState(w http.ResponseWriter, r *http.Request, apiID externalRef0.ApiID)
	// Get the event with the annotations and bfla status
	// (GET /event/{id})
	GetEvent(w http.ResponseWriter, r *http.Request, id int)

	// (PUT /event/{id}/{operation})
	PutEventIdOperation(w http.ResponseWriter, r *http.Request, id int, operation OperationEnum)
	// Get the version of this Module
	// (GET /version)
	GetVersion(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetApiFindings

func (siw *ServerInterfaceWrapper) GetApiFindings(w http.ResponseWriter, r *http.Request)

GetApiFindings operation middleware

func (*ServerInterfaceWrapper) GetAuthorizationModelApiID

func (siw *ServerInterfaceWrapper) GetAuthorizationModelApiID(w http.ResponseWriter, r *http.Request)

GetAuthorizationModelApiID operation middleware

func (*ServerInterfaceWrapper) GetAuthorizationModelApiIDState

func (siw *ServerInterfaceWrapper) GetAuthorizationModelApiIDState(w http.ResponseWriter, r *http.Request)

GetAuthorizationModelApiIDState operation middleware

func (*ServerInterfaceWrapper) GetEvent

func (siw *ServerInterfaceWrapper) GetEvent(w http.ResponseWriter, r *http.Request)

GetEvent operation middleware

func (*ServerInterfaceWrapper) GetVersion

func (siw *ServerInterfaceWrapper) GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion operation middleware

func (*ServerInterfaceWrapper) PostAuthorizationModelApiID

func (siw *ServerInterfaceWrapper) PostAuthorizationModelApiID(w http.ResponseWriter, r *http.Request)

PostAuthorizationModelApiID operation middleware

func (*ServerInterfaceWrapper) PostAuthorizationModelApiIDReset

func (siw *ServerInterfaceWrapper) PostAuthorizationModelApiIDReset(w http.ResponseWriter, r *http.Request)

PostAuthorizationModelApiIDReset operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDApprove

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDApprove(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDApprove operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDDeny

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDDeny(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDDeny operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDDetectionStart

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDDetectionStart(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDDetectionStart operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDDetectionStop

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDDetectionStop(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDDetectionStop operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDLearningStart

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDLearningStart(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDLearningStart operation middleware

func (*ServerInterfaceWrapper) PutAuthorizationModelApiIDLearningStop

func (siw *ServerInterfaceWrapper) PutAuthorizationModelApiIDLearningStop(w http.ResponseWriter, r *http.Request)

PutAuthorizationModelApiIDLearningStop operation middleware

func (*ServerInterfaceWrapper) PutEventIdOperation

func (siw *ServerInterfaceWrapper) PutEventIdOperation(w http.ResponseWriter, r *http.Request)

PutEventIdOperation operation middleware

type SpecType

type SpecType string

SpecType defines model for SpecType.

const (
	NONE          SpecType = "NONE"
	PROVIDED      SpecType = "PROVIDED"
	RECONSTRUCTED SpecType = "RECONSTRUCTED"
)

Defines values for SpecType.

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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