middleware

package
v0.0.0-...-cbce884 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIKEY = "apikey"

APIKEY is the key for the apikey authorization token

View Source
var BEARER = "bearer"

BEARER is the key for the bearer authorization token

View Source
var JSONKey = "json"

JSONKey is the constant value for the URL parameter

View Source
var Resources = "api"

Resources is the constant value for the URL parameter

Functions

func AlignTime

func AlignTime(unaligned time.Time, interval int) time.Time

AlignTime returns the aligned `time.Time` based on the `unaligned` parameter and the `interval` to align with (in minutes)

func AppUserJwtAuthzMiddleware

func AppUserJwtAuthzMiddleware(config *config.AppConfig) gin.HandlerFunc

AppUserJwtAuthzMiddleware authorizes the JWT in the Authorization header for application users

func AppUserProjectAuthzMiddleware

func AppUserProjectAuthzMiddleware(store interfaces.Datastore, config *config.AppConfig) gin.HandlerFunc

AppUserProjectAuthzMiddleware validates this app user has access to the project

func JSONStatsMiddleware

func JSONStatsMiddleware(store interfaces.Datastore, emitter *events.Processor) gin.HandlerFunc

JSONStatsMiddleware logs json stats for reporting

func OpenCORSMiddleware

func OpenCORSMiddleware() gin.HandlerFunc

OpenCORSMiddleware controls the cross origin policies.

func ProjectAuthzBuildFiltersMiddleware

func ProjectAuthzBuildFiltersMiddleware(store interfaces.Datastore) gin.HandlerFunc

ProjectAuthzBuildFiltersMiddleware builds the necessary filters based on the requester's role, permissions, as well as the collection/resource's access policies. This middleware requires that the requester `role` has been injected into the context.

func ProjectIDAuthzMiddleware

func ProjectIDAuthzMiddleware(store interfaces.Datastore) gin.HandlerFunc

ProjectIDAuthzMiddleware retrieves the project ID

func ProjectUserAuthzMiddleware

func ProjectUserAuthzMiddleware(store interfaces.Datastore, config *config.AppConfig) gin.HandlerFunc

ProjectUserAuthzMiddleware authenticates the JWT and verifies the requesting user has access to this project. This middleware requires that the `project` has been injected into the context.

func ProjectUserRegistrationMiddleware

func ProjectUserRegistrationMiddleware(store interfaces.Datastore) gin.HandlerFunc

ProjectUserRegistrationMiddleware verifies this project has User Registration enabled

func RequestRateLimit

func RequestRateLimit(store interfaces.Datastore, cache redis.UniversalClient) gin.HandlerFunc

RequestRateLimit checks the account rate limit and returns 429 if over app tier limit

func ResourceStatsMiddleware

func ResourceStatsMiddleware(store interfaces.Datastore, emitter *events.Processor) gin.HandlerFunc

ResourceStatsMiddleware logs resource stats and logging for reporting

func SubDomainMiddleware

func SubDomainMiddleware() gin.HandlerFunc

SubDomainMiddleware controls the cross origin policies.

func ValidateRefreshToken

func ValidateRefreshToken(store interfaces.Datastore, config *config.AppConfig) gin.HandlerFunc

ValidateRefreshToken validates the refresh token

Types

type StoreConfig

type StoreConfig struct {
	Create        bool
	Read          bool
	Update        bool
	Delete        bool
	ParallelRead  bool
	ParallelWrite bool
	Headers       map[string]string
}

StoreConfig holds the middleware-relevant config for a collection/resource

func (*StoreConfig) VerbRequiresAuthn

func (s *StoreConfig) VerbRequiresAuthn(verb string) (bool, error)

VerbRequiresAuthn returns if the provided HTTP Verb requires authentication for this endpoint

Jump to

Keyboard shortcuts

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