func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) { v := cfg.Version exp := middleware.NewExperimentalMiddleware(cli.d.HasExperimental()) s.UseMiddleware(exp) vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion) s.UseMiddleware(vm) if cfg.EnableCors { c := middleware.NewCORSMiddleware(cfg.CorsHeaders) s.UseMiddleware(c) } u := middleware.NewUserAgentMiddleware(v) s.UseMiddleware(u) cli.authzMiddleware = authorization.NewMiddleware(cli.Config.AuthorizationPlugins, cli.d.PluginStore) s.UseMiddleware(cli.authzMiddleware) }
func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) error { v := cfg.Version exp := middleware.NewExperimentalMiddleware(cli.d.HasExperimental()) s.UseMiddleware(exp) vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion) s.UseMiddleware(vm) if cfg.EnableCors { c := middleware.NewCORSMiddleware(cfg.CorsHeaders) s.UseMiddleware(c) } u := middleware.NewUserAgentMiddleware(v) s.UseMiddleware(u) if err := validateAuthzPlugins(cli.Config.AuthorizationPlugins, cli.d.PluginStore); err != nil { return fmt.Errorf("Error validating authorization plugin: %v", err) } cli.authzMiddleware = authorization.NewMiddleware(cli.Config.AuthorizationPlugins, cli.d.PluginStore) s.UseMiddleware(cli.authzMiddleware) return nil }
func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config) { v := cfg.Version vm := middleware.NewVersionMiddleware(v, api.DefaultVersion, api.MinVersion) s.UseMiddleware(vm) if cfg.EnableCors { c := middleware.NewCORSMiddleware(cfg.CorsHeaders) s.UseMiddleware(c) } u := middleware.NewUserAgentMiddleware(v) s.UseMiddleware(u) if len(cli.Config.AuthorizationPlugins) > 0 { authZPlugins := authorization.NewPlugins(cli.Config.AuthorizationPlugins) handleAuthorization := authorization.NewMiddleware(authZPlugins) s.UseMiddleware(handleAuthorization) } }