Documentation ¶
Index ¶
- Constants
- func GetSessionKeyVar(logger zerolog.Logger) []byte
- func RegisterRoutes(ctx context.Context, conf config.CanopsisConf, router gin.IRouter, ...)
- func RegisterValidators(client mongo.DbClient)
- type API
- type ConfigProviders
- type CookieOptions
- type DeferFunc
- type FatalWorkerError
- type Flags
- type Router
- type Security
- type Worker
Constants ¶
View Source
const BaseUrl = "/api/v4"
View Source
const JwtSecretEnv = "CPS_JWT_SECRET" //nolint:gosec
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes( ctx context.Context, conf config.CanopsisConf, router gin.IRouter, security Security, enforcer libsecurity.Enforcer, linkGenerator link.Generator, dbClient mongo.DbClient, dbExportClient mongo.DbClient, pgPoolProvider postgres.PoolProvider, amqpChannel amqp.Channel, apiConfigProvider config.ApiConfigProvider, timezoneConfigProvider config.TimezoneConfigProvider, templateConfigProvider config.TemplateConfigProvider, pbhEntityTypeResolver libpbehavior.EntityTypeResolver, pbhComputeChan chan<- rpc.PbehaviorRecomputeEvent, entityPublChan chan<- libentityservice.ChangeEntityMessage, entityCleanerTaskChan chan<- entity.CleanTask, exportExecutor export.TaskExecutor, techMetricsTaskExecutor techmetrics.TaskExecutor, publisher amqp.Publisher, userInterfaceConfig config.UserInterfaceConfigProvider, websocketHub websocket.Hub, websocketStore websocket.Store, broadcastMessageChan chan<- bool, metricsEntityMetaUpdater metrics.MetaUpdater, metricsUserMetaUpdater metrics.MetaUpdater, authorProvider author.Provider, healthcheckStore healthcheck.Store, tplExecutor libtemplate.Executor, stateSettingsUpdatesChan chan statesetting.RuleUpdatedMessage, enableSameServiceNames bool, eventGenerator libevent.Generator, logger zerolog.Logger, )
RegisterRoutes nolint: contextcheck
Types ¶
type API ¶
type API interface { // Run starts http server. Run(context.Context) error // AddRouter adds new routes. AddRouter(Router) // AddWorker adds new worker. AddWorker(string, Worker) // AddNoRoute adds handlers for no route. AddNoRoute(...gin.HandlerFunc) // AddNoMethod adds handlers for no method. AddNoMethod(...gin.HandlerFunc) // SetWebsocketHub sets websocket hub. SetWebsocketHub(websocket.Hub) // GetWebsocketHub gets websocket hub. GetWebsocketHub() websocket.Hub }
API is used to implement API http server.
func Default ¶
func Default( ctx context.Context, flags Flags, enforcer libsecurity.Enforcer, p *ConfigProviders, logger zerolog.Logger, pgPoolProvider postgres.PoolProvider, metricsEntityMetaUpdater metrics.MetaUpdater, metricsUserMetaUpdater metrics.MetaUpdater, exportExecutor export.TaskExecutor, linkGenerator link.Generator, deferFunc DeferFunc, overrideDocs bool, ) (API, fs.ReadFileFS, error)
type ConfigProviders ¶
type ConfigProviders struct { DataStorageConfigProvider *config.BaseDataStorageConfigProvider TimezoneConfigProvider *config.BaseTimezoneConfigProvider ApiConfigProvider *config.BaseApiConfigProvider TemplateConfigProvider *config.BaseTemplateConfigProvider UserInterfaceConfigProvider *config.BaseUserInterfaceConfigProvider }
type CookieOptions ¶
func DefaultCookieOptions ¶
func DefaultCookieOptions() CookieOptions
type FatalWorkerError ¶
type FatalWorkerError struct {
// contains filtered or unexported fields
}
FatalWorkerError should be used in the Worker function with panic() call, when there is a need to stop the api, when worker fails. the worker will be recovered from the panic, but it won't be restarted and the api will be stopped normally.
func (FatalWorkerError) Error ¶
func (e FatalWorkerError) Error() string
type Flags ¶
type Flags struct { Version bool Port int64 ConfigDir string Debug bool SecureSession bool EnableDocs bool PeriodicalWaitTime time.Duration IntegrationPeriodicalWaitTime time.Duration EntityCategoryMetaPeriodicalWaitTime time.Duration StateSettingRecomputeDelay time.Duration // EnableSameServiceNames affects entityservice Create/Update payload validation EnableSameServiceNames bool LogBody bool LogBodyOnError bool }
type Security ¶
type Security interface { // GetHttpAuthProviders creates http providers which authenticates each API request. GetHttpAuthProviders() []libsecurity.HttpProvider // GetAuthProviders creates providers which are used in auth API request. GetAuthProviders() []libsecurity.Provider // RegisterCallbackRoutes registers callback routes for auth methods. RegisterCallbackRoutes(ctx context.Context, router gin.IRouter, client mongo.DbClient, sessionStore sessions.Store) // GetAuthMiddleware returns corresponding config auth middlewares. GetAuthMiddleware() []gin.HandlerFunc // GetFileAuthMiddleware returns auth middleware for files. GetFileAuthMiddleware() gin.HandlerFunc GetSessionStore() libsession.Store GetConfig() libsecurity.Config GetPasswordEncoder() password.Encoder GetTokenService() apisecurity.TokenService GetTokenGenerator() token.Generator GetTokenProviders() []libsecurity.TokenProvider GetCookieOptions() CookieOptions }
Security is used to init auth methods by config.
func NewSecurity ¶
func NewSecurity( config libsecurity.Config, globalConfig config.CanopsisConf, dbClient mongo.DbClient, sessionStore libsession.Store, enforcer libsecurity.Enforcer, apiConfigProvider config.ApiConfigProvider, maintenanceAdapter config.MaintenanceAdapter, cookieOptions CookieOptions, logger zerolog.Logger, ) Security
NewSecurity creates new security.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package sessionauth contains authentication by session.
|
Package sessionauth contains authentication by session. |
Package websocket contains implementation of websocket.
|
Package websocket contains implementation of websocket. |
Click to show internal directories.
Click to hide internal directories.