registry

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CookieTokenName = "token"
	CookieLoginName = "login"
	CookieDomain    = ""
	CookiePath      = "/"
	// while these vars look goofy, they avoid "magic number" arguments to SetCookie
	CookieHTTPOnlyJavascriptAccessible    = false   // setting HttpOnly to false means JS can access it.
	CookieHTTPOnlyNotJavascriptAccessible = true    // setting HttpOnly to true means JS can't access it.
	CookieSecureHTTPSOnly                 = true    // setting Secure to true means the cookie is only sent over https connections
	CookieSecureHttpOrHTTPS               = false   // setting Secure to false means the cookie will be sent over http or https connections
	CookieMaxAgeDeleteImmediately         = int(-1) // <0: delete immediately
	CookieMaxAgeNoExpiry                  = int(0)  // zero has special meaning of "no expiry"
)

Functions

func AuthenticationMiddleware added in v0.5.0

func AuthenticationMiddleware() gin.HandlerFunc

AuthenticationMiddleware validates the incoming token and adds their permissions to the context

func DatabaseMiddleware added in v0.5.0

func DatabaseMiddleware(db *gorm.DB) gin.HandlerFunc

DatabaseMiddleware injects a `db` object into the Gin context.

func MetricsMiddleware added in v0.5.0

func MetricsMiddleware(path string) gin.HandlerFunc

MetricsMiddleware wraps the request with a standard set of Prometheus metrics. It has an additional responsibility of stripping out any unique identifiers as it will drastically increase the cardinality, and cost, of produced metrics.

func NewAPIMux added in v0.4.0

func NewAPIMux(reg *Registry, router *gin.RouterGroup)

func RequestTimeoutMiddleware added in v0.4.13

func RequestTimeoutMiddleware() gin.HandlerFunc

RequestTimeoutMiddleware adds a timeout to the request context within the Gin context. To correctly abort long-running requests, this depends on the users of the context to stop working when the context cancels. Note: The goroutine for the request is never halted; if the context is not passed down to lower packages and long-running tasks, then the app will not magically stop working on the request. No effort should be made to write an early http response here; it's up to the users of the context to watch for c.Request.Context().Err() or <-c.Request.Context().Done()

func RequireAPIToken added in v0.5.0

func RequireAPIToken(c *gin.Context) error

RequireAPIToken checks the bearer token is present and valid then adds its permissions to the context

func Run

func Run(options Options) (err error)

func SetupMetrics added in v0.5.0

func SetupMetrics(db *gorm.DB) error

Types

type API added in v0.4.0

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

func (*API) CreateAPIToken added in v0.5.0

func (a *API) CreateAPIToken(c *gin.Context, r *api.CreateAPITokenRequest) (*api.CreateAPITokenResponse, error)

func (*API) CreateDestination added in v0.4.0

func (a *API) CreateDestination(c *gin.Context, r *api.CreateDestinationRequest) (*api.Destination, error)

func (*API) CreateGrant added in v0.5.0

func (a *API) CreateGrant(c *gin.Context, r *api.CreateGrantRequest) (*api.Grant, error)

func (*API) CreateGroup added in v0.5.0

func (a *API) CreateGroup(c *gin.Context, r *api.CreateGroupRequest) (*api.Group, error)

func (*API) CreateProvider added in v0.5.0

func (a *API) CreateProvider(c *gin.Context, r *api.CreateProviderRequest) (*api.Provider, error)

func (*API) CreateToken added in v0.4.0

func (a *API) CreateToken(c *gin.Context, r *api.CreateTokenRequest) (*api.CreateTokenResponse, error)

func (*API) CreateUser added in v0.5.0

func (a *API) CreateUser(c *gin.Context, r *api.CreateUserRequest) (*api.User, error)

func (*API) DeleteAPIToken added in v0.5.0

func (a *API) DeleteAPIToken(c *gin.Context, r *api.Resource) error

func (*API) DeleteDestination added in v0.5.0

func (a *API) DeleteDestination(c *gin.Context, r *api.Resource) error

func (*API) DeleteGrant added in v0.5.0

func (a *API) DeleteGrant(c *gin.Context, r *api.Resource) error

func (*API) DeleteProvider added in v0.5.0

func (a *API) DeleteProvider(c *gin.Context, r *api.Resource) error

func (*API) GetDestination added in v0.4.0

func (a *API) GetDestination(c *gin.Context, r *api.Resource) (*api.Destination, error)

func (*API) GetGrant added in v0.5.0

func (a *API) GetGrant(c *gin.Context, r *api.Resource) (*api.Grant, error)

func (*API) GetGroup added in v0.4.0

func (a *API) GetGroup(c *gin.Context, r *api.Resource) (*api.Group, error)

func (*API) GetProvider added in v0.4.0

func (a *API) GetProvider(c *gin.Context, r *api.Resource) (*api.Provider, error)

caution: this endpoint is unauthenticated, do not return sensitive info

func (*API) GetUser added in v0.4.0

func (a *API) GetUser(c *gin.Context, r *api.Resource) (*api.User, error)

func (*API) ListAPITokens added in v0.5.0

func (a *API) ListAPITokens(c *gin.Context, r *api.EmptyRequest) ([]api.APIToken, error)

func (*API) ListDestinations added in v0.4.0

func (a *API) ListDestinations(c *gin.Context, r *api.ListDestinationsRequest) ([]api.Destination, error)

func (*API) ListGrants added in v0.5.0

func (a *API) ListGrants(c *gin.Context, r *api.ListGrantsRequest) ([]api.Grant, error)

func (*API) ListGroupGrants added in v0.5.0

func (a *API) ListGroupGrants(c *gin.Context, r *api.Resource) ([]api.Grant, error)

func (*API) ListGroups added in v0.4.0

func (a *API) ListGroups(c *gin.Context, r *api.ListGroupsRequest) ([]api.Group, error)

func (*API) ListProviders added in v0.4.0

func (a *API) ListProviders(c *gin.Context, r *api.ListProvidersRequest) ([]api.Provider, error)

caution: this endpoint is unauthenticated, do not return sensitive info

func (*API) ListUserGrants added in v0.5.0

func (a *API) ListUserGrants(c *gin.Context, r *api.Resource) ([]api.Grant, error)

func (*API) ListUserGroups added in v0.5.0

func (a *API) ListUserGroups(c *gin.Context, r *api.Resource) ([]api.Group, error)

func (*API) ListUsers added in v0.4.0

func (a *API) ListUsers(c *gin.Context, r *api.ListUsersRequest) ([]api.User, error)

func (*API) Login added in v0.4.0

func (a *API) Login(c *gin.Context, r *api.LoginRequest) (*api.LoginResponse, error)

func (*API) Logout added in v0.4.0

func (a *API) Logout(c *gin.Context, r *api.EmptyRequest) (*api.EmptyResponse, error)

func (*API) UpdateDestination added in v0.5.0

func (a *API) UpdateDestination(c *gin.Context, r *api.UpdateDestinationRequest) (*api.Destination, error)

func (*API) UpdateProvider added in v0.5.0

func (a *API) UpdateProvider(c *gin.Context, r *api.UpdateProviderRequest) (*api.Provider, error)

func (*API) Version added in v0.4.0

func (a *API) Version(c *gin.Context, r *api.EmptyRequest) (*api.Version, error)

type KeyProvider added in v0.5.0

type KeyProvider struct {
	Kind   string      `yaml:"kind" validate:"required"`
	Config interface{} // contains secret-provider-specific config
}

func (*KeyProvider) UnmarshalYAML added in v0.5.0

func (sp *KeyProvider) UnmarshalYAML(unmarshal func(interface{}) error) error

type Options

type Options struct {
	Import                  *config.Config   `yaml:"import"`
	Secrets                 []SecretProvider `yaml:"secrets" validate:"dive"`
	Keys                    []KeyProvider    `yaml:"keys" validate:"dive"`
	TLSCache                string           `yaml:"tlsCache"`
	RootAPIToken            string           `yaml:"rootAPIToken"`
	EngineAPIToken          string           `yaml:"engineAPIToken"`
	DBFile                  string           `yaml:"dbFile" `
	DBEncryptionKey         string           `yaml:"dbEncryptionKey"`
	DBEncryptionKeyProvider string           `yaml:"dbEncryptionKeyProvider"`
	DBHost                  string           `yaml:"dbHost" `
	DBPort                  int              `yaml:"dbPort"`
	DBName                  string           `yaml:"dbName"`
	DBUser                  string           `yaml:"dbUser"`
	DBPassword              string           `yaml:"dbPassword"`
	DBParameters            string           `yaml:"dbParameters"`
	EnableTelemetry         bool             `yaml:"enableTelemetry"`
	EnableCrashReporting    bool             `yaml:"enableCrashReporting"`
	SessionDuration         time.Duration    `yaml:"sessionDuration"`
}

type Registry added in v0.4.0

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

func (*Registry) GetSecret added in v0.4.0

func (r *Registry) GetSecret(name string) (string, error)

GetSecret implements the secret definition scheme for Infra. eg plaintext:pass123, or kubernetes:infra-okta/apiToken it's an abstraction around all secret providers

func (*Registry) SetSecret added in v0.5.0

func (r *Registry) SetSecret(name string, value string) error

type ReqHandlerFunc added in v0.5.0

type ReqHandlerFunc[Req any] func(c *gin.Context, req *Req) error

type ReqResHandlerFunc added in v0.5.0

type ReqResHandlerFunc[Req, Res any] func(c *gin.Context, req *Req) (Res, error)

type ResHandlerFunc added in v0.5.0

type ResHandlerFunc[Res any] func(c *gin.Context) (Res, error)

type SecretProvider added in v0.5.0

type SecretProvider struct {
	Kind   string      `yaml:"kind" validate:"required"`
	Name   string      `yaml:"name"` // optional
	Config interface{} // contains secret-provider-specific config
}

func (*SecretProvider) UnmarshalYAML added in v0.5.0

func (sp *SecretProvider) UnmarshalYAML(unmarshal func(interface{}) error) error

type Telemetry added in v0.3.3

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

func NewTelemetry added in v0.3.3

func NewTelemetry(db *gorm.DB) (*Telemetry, error)

func (*Telemetry) Close added in v0.3.3

func (t *Telemetry) Close()

func (*Telemetry) Enqueue added in v0.3.3

func (t *Telemetry) Enqueue(track analytics.Track) error

func (*Telemetry) EnqueueHeartbeat added in v0.3.3

func (t *Telemetry) EnqueueHeartbeat() error

func (*Telemetry) SetEnabled added in v0.3.3

func (t *Telemetry) SetEnabled(enabled bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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