middleware

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsurePeriod

func EnsurePeriod(start time.Time, end time.Time) error

func FilterDeletedEndpoints

func FilterDeletedEndpoints(endpoints []datastore.Endpoint) []datastore.Endpoint

func GetAuthFromRequest

func GetAuthFromRequest(r *http.Request) (*auth.Credential, error)

func GetAuthUserFromContext

func GetAuthUserFromContext(ctx context.Context) *auth.AuthenticatedUser

func GetDeliveryAttemptFromContext

func GetDeliveryAttemptFromContext(ctx context.Context) *datastore.DeliveryAttempt

func GetDeliveryAttemptsFromContext

func GetDeliveryAttemptsFromContext(ctx context.Context) *[]datastore.DeliveryAttempt

func GetEndpointFromContext added in v0.8.0

func GetEndpointFromContext(ctx context.Context) *datastore.Endpoint

func GetEndpointIDFromContext added in v0.8.0

func GetEndpointIDFromContext(r *http.Request) string

func GetEndpointIDsFromContext added in v0.8.0

func GetEndpointIDsFromContext(ctx context.Context) []string

func GetEndpointsFromContext added in v0.8.0

func GetEndpointsFromContext(ctx context.Context) []datastore.Endpoint

func GetEventDeliveryFromContext

func GetEventDeliveryFromContext(ctx context.Context) *datastore.EventDelivery

func GetEventFromContext

func GetEventFromContext(ctx context.Context) *datastore.Event

func GetHostFromContext

func GetHostFromContext(ctx context.Context) string

func GetOrganisationFromContext

func GetOrganisationFromContext(ctx context.Context) *datastore.Organisation

func GetOrganisationMemberFromContext

func GetOrganisationMemberFromContext(ctx context.Context) *datastore.OrganisationMember

func GetPageableFromContext

func GetPageableFromContext(ctx context.Context) datastore.Pageable

func GetPaginationDataFromContext

func GetPaginationDataFromContext(ctx context.Context) *datastore.PaginationData

func GetPortalLinkFromContext added in v0.8.0

func GetPortalLinkFromContext(ctx context.Context) *datastore.PortalLink

func GetProjectFromContext added in v0.8.0

func GetProjectFromContext(ctx context.Context) *datastore.Project

func GetSourceIDFromContext added in v0.7.0

func GetSourceIDFromContext(r *http.Request) string

func GetUserFromContext

func GetUserFromContext(ctx context.Context) *datastore.User

func SetDeliveryAttemptsInContext

func SetDeliveryAttemptsInContext(ctx context.Context,
	attempts *[]datastore.DeliveryAttempt,
) context.Context

func ShouldAuthRoute

func ShouldAuthRoute(r *http.Request) bool

Types

type AuthorizedLogin

type AuthorizedLogin struct {
	Username   string    `json:"username,omitempty"`
	Token      string    `json:"token"`
	ExpiryTime time.Time `json:"expiry_time"`
}

func GetAuthLoginFromContext

func GetAuthLoginFromContext(ctx context.Context) *AuthorizedLogin

type Middleware

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

func NewMiddleware

func NewMiddleware(cs *CreateMiddleware) *Middleware

func (*Middleware) ComputeDashboardMessages

func (m *Middleware) ComputeDashboardMessages(ctx context.Context, projectID string, searchParams datastore.SearchParams, period datastore.Period) (uint64, []datastore.EventInterval, error)

func (*Middleware) InstrumentPath

func (m *Middleware) InstrumentPath(path string) func(http.Handler) http.Handler

func (*Middleware) InstrumentRequests

func (m *Middleware) InstrumentRequests() func(next http.Handler) http.Handler

func (*Middleware) JsonResponse

func (m *Middleware) JsonResponse(next http.Handler) http.Handler

func (*Middleware) LogHttpRequest

func (m *Middleware) LogHttpRequest() func(next http.Handler) http.Handler

func (*Middleware) Pagination

func (m *Middleware) Pagination(next http.Handler) http.Handler

func (*Middleware) RateLimitByProjectID added in v0.8.0

func (m *Middleware) RateLimitByProjectID() func(next http.Handler) http.Handler

func (*Middleware) RateLimitByProjectWithParams added in v0.8.0

func (m *Middleware) RateLimitByProjectWithParams(requestLimit int, windowLength time.Duration) func(next http.Handler) http.Handler

func (*Middleware) RejectAppPortalKey added in v0.7.0

func (m *Middleware) RejectAppPortalKey() func(next http.Handler) http.Handler

RejectAppPortalKey ensures that an app portal api key was not used for authentication

func (*Middleware) RequireApp

func (m *Middleware) RequireApp() func(next http.Handler) http.Handler

func (*Middleware) RequireAppBelongsToProject added in v0.8.0

func (m *Middleware) RequireAppBelongsToProject() func(next http.Handler) http.Handler

func (*Middleware) RequireAppEndpoint

func (m *Middleware) RequireAppEndpoint() func(next http.Handler) http.Handler

func (*Middleware) RequireAuth

func (m *Middleware) RequireAuth() func(next http.Handler) http.Handler

func (*Middleware) RequireAuthUserMetadata

func (m *Middleware) RequireAuthUserMetadata() func(next http.Handler) http.Handler

func (*Middleware) RequireAuthorizedUser

func (m *Middleware) RequireAuthorizedUser() func(next http.Handler) http.Handler

func (*Middleware) RequireBaseUrl

func (m *Middleware) RequireBaseUrl() func(next http.Handler) http.Handler

func (*Middleware) RequireDeliveryAttempt

func (m *Middleware) RequireDeliveryAttempt() func(next http.Handler) http.Handler

func (*Middleware) RequireEndpoint added in v0.8.0

func (m *Middleware) RequireEndpoint() func(next http.Handler) http.Handler

func (*Middleware) RequireEndpointBelongsToProject added in v0.8.0

func (m *Middleware) RequireEndpointBelongsToProject() func(next http.Handler) http.Handler

func (*Middleware) RequireEndpointID added in v0.8.2

func (m *Middleware) RequireEndpointID() func(next http.Handler) http.Handler

func (*Middleware) RequireEvent

func (m *Middleware) RequireEvent() func(next http.Handler) http.Handler

func (*Middleware) RequireEventDelivery

func (m *Middleware) RequireEventDelivery() func(next http.Handler) http.Handler

func (*Middleware) RequireOrganisation

func (m *Middleware) RequireOrganisation() func(next http.Handler) http.Handler

func (*Middleware) RequireOrganisationMemberRole

func (m *Middleware) RequireOrganisationMemberRole(roleType auth.RoleType) func(next http.Handler) http.Handler

func (*Middleware) RequireOrganisationMembership

func (m *Middleware) RequireOrganisationMembership() func(next http.Handler) http.Handler

func (*Middleware) RequireOrganisationProjectMember added in v0.8.0

func (m *Middleware) RequireOrganisationProjectMember() func(next http.Handler) http.Handler

func (*Middleware) RequirePermission

func (m *Middleware) RequirePermission(role auth.RoleType) func(next http.Handler) http.Handler

func (*Middleware) RequirePersonalAccessToken added in v0.8.2

func (m *Middleware) RequirePersonalAccessToken() func(next http.Handler) http.Handler
func (m *Middleware) RequirePortalLink() func(next http.Handler) http.Handler

func (*Middleware) RequirePortalLinkEndpoint added in v0.8.0

func (m *Middleware) RequirePortalLinkEndpoint() func(next http.Handler) http.Handler

func (*Middleware) RequireProject added in v0.8.0

func (m *Middleware) RequireProject() func(next http.Handler) http.Handler

func (*Middleware) RequireProjectAccess added in v0.8.0

func (m *Middleware) RequireProjectAccess() func(next http.Handler) http.Handler

RequireProjectAccess checks if the given authentication creds can access the project. It handles PATs as well

func (*Middleware) SetupCORS

func (m *Middleware) SetupCORS(next http.Handler) http.Handler

func (*Middleware) WriteRequestIDHeader

func (m *Middleware) WriteRequestIDHeader(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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