mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Fix build after swagger codegen (#2201)
This commit is contained in:
committed by
GitHub
parent
25f719b0e2
commit
3b11556f4b
@@ -98,7 +98,7 @@ func buildServer() (*restapi.Server, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
api := operations.NewConsoleAPI(swaggerSpec, nil)
|
api := operations.NewConsoleAPI(swaggerSpec)
|
||||||
api.Logger = restapi.LogInfo
|
api.Logger = restapi.LogInfo
|
||||||
server := restapi.NewServer(api)
|
server := restapi.NewServer(api)
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func initConsoleServer() (*restapi.Server, error) {
|
|||||||
restapi.LogInfo = noLog
|
restapi.LogInfo = noLog
|
||||||
restapi.LogError = noLog
|
restapi.LogError = noLog
|
||||||
|
|
||||||
api := operations.NewConsoleAPI(swaggerSpec, nil)
|
api := operations.NewConsoleAPI(swaggerSpec)
|
||||||
api.Logger = noLog
|
api.Logger = noLog
|
||||||
|
|
||||||
server := restapi.NewServer(api)
|
server := restapi.NewServer(api)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func initConsoleServer() (*restapi.Server, error) {
|
|||||||
restapi.LogInfo = noLog
|
restapi.LogInfo = noLog
|
||||||
restapi.LogError = noLog
|
restapi.LogError = noLog
|
||||||
|
|
||||||
api := operations.NewConsoleAPI(swaggerSpec, nil)
|
api := operations.NewConsoleAPI(swaggerSpec)
|
||||||
api.Logger = noLog
|
api.Logger = noLog
|
||||||
|
|
||||||
server := restapi.NewServer(api)
|
server := restapi.NewServer(api)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func TestRegisterAdminArnsHandlers(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
assert.Fail("Error")
|
assert.Fail("Error")
|
||||||
}
|
}
|
||||||
api := operations.NewConsoleAPI(swaggerSpec, nil)
|
api := operations.NewConsoleAPI(swaggerSpec)
|
||||||
api.SystemArnListHandler = nil
|
api.SystemArnListHandler = nil
|
||||||
registerAdminArnsHandlers(api)
|
registerAdminArnsHandlers(api)
|
||||||
if api.SystemArnListHandler == nil {
|
if api.SystemArnListHandler == nil {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/minio/console/pkg/auth/idp/oauth2"
|
||||||
xcerts "github.com/minio/pkg/certs"
|
xcerts "github.com/minio/pkg/certs"
|
||||||
"github.com/minio/pkg/env"
|
"github.com/minio/pkg/env"
|
||||||
xnet "github.com/minio/pkg/net"
|
xnet "github.com/minio/pkg/net"
|
||||||
@@ -46,6 +47,25 @@ var (
|
|||||||
ConsoleResourceName = "console-ui"
|
ConsoleResourceName = "console-ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// GlobalRootCAs is CA root certificates, a nil value means system certs pool will be used
|
||||||
|
GlobalRootCAs *x509.CertPool
|
||||||
|
// GlobalPublicCerts has certificates Console will use to serve clients
|
||||||
|
GlobalPublicCerts []*x509.Certificate
|
||||||
|
// GlobalTLSCertsManager custom TLS Manager for SNI support
|
||||||
|
GlobalTLSCertsManager *xcerts.Manager
|
||||||
|
)
|
||||||
|
|
||||||
|
// MinIOConfig represents application configuration passed in from the MinIO
|
||||||
|
// server to the console.
|
||||||
|
type MinIOConfig struct {
|
||||||
|
OpenIDProviders oauth2.OpenIDPCfg
|
||||||
|
}
|
||||||
|
|
||||||
|
// GlobalMinIOConfig is the global application configuration passed in from the
|
||||||
|
// MinIO server.
|
||||||
|
var GlobalMinIOConfig MinIOConfig
|
||||||
|
|
||||||
func getMinIOServer() string {
|
func getMinIOServer() string {
|
||||||
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
|
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
|
||||||
}
|
}
|
||||||
@@ -234,12 +254,3 @@ func getPrometheusJobID() string {
|
|||||||
func getPrometheusExtraLabels() string {
|
func getPrometheusExtraLabels() string {
|
||||||
return env.Get(PrometheusExtraLabels, "")
|
return env.Get(PrometheusExtraLabels, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
// GlobalRootCAs is CA root certificates, a nil value means system certs pool will be used
|
|
||||||
GlobalRootCAs *x509.CertPool
|
|
||||||
// GlobalPublicCerts has certificates Console will use to serve clients
|
|
||||||
GlobalPublicCerts []*x509.Certificate
|
|
||||||
// GlobalTLSCertsManager custom TLS Manager for SNI support
|
|
||||||
GlobalTLSCertsManager *xcerts.Manager
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import (
|
|||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
|
|
||||||
"github.com/minio/console/models"
|
"github.com/minio/console/models"
|
||||||
"github.com/minio/console/pkg/auth/idp/oauth2"
|
|
||||||
"github.com/minio/console/restapi/operations/account"
|
"github.com/minio/console/restapi/operations/account"
|
||||||
"github.com/minio/console/restapi/operations/auth"
|
"github.com/minio/console/restapi/operations/auth"
|
||||||
"github.com/minio/console/restapi/operations/bucket"
|
"github.com/minio/console/restapi/operations/bucket"
|
||||||
@@ -59,7 +58,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewConsoleAPI creates a new Console instance
|
// NewConsoleAPI creates a new Console instance
|
||||||
func NewConsoleAPI(spec *loads.Document, openIDProviders oauth2.OpenIDPCfg) *ConsoleAPI {
|
func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||||
return &ConsoleAPI{
|
return &ConsoleAPI{
|
||||||
handlers: make(map[string]map[string]http.Handler),
|
handlers: make(map[string]map[string]http.Handler),
|
||||||
formats: strfmt.Default,
|
formats: strfmt.Default,
|
||||||
@@ -76,8 +75,6 @@ func NewConsoleAPI(spec *loads.Document, openIDProviders oauth2.OpenIDPCfg) *Con
|
|||||||
APIKeyAuthenticator: security.APIKeyAuth,
|
APIKeyAuthenticator: security.APIKeyAuth,
|
||||||
BearerAuthenticator: security.BearerAuth,
|
BearerAuthenticator: security.BearerAuth,
|
||||||
|
|
||||||
OpenIDProviders: openIDProviders,
|
|
||||||
|
|
||||||
JSONConsumer: runtime.JSONConsumer(),
|
JSONConsumer: runtime.JSONConsumer(),
|
||||||
MultipartformConsumer: runtime.DiscardConsumer,
|
MultipartformConsumer: runtime.DiscardConsumer,
|
||||||
|
|
||||||
@@ -484,9 +481,6 @@ type ConsoleAPI struct {
|
|||||||
Middleware func(middleware.Builder) http.Handler
|
Middleware func(middleware.Builder) http.Handler
|
||||||
useSwaggerUI bool
|
useSwaggerUI bool
|
||||||
|
|
||||||
// Configuration passed in from MinIO for MinIO console.
|
|
||||||
OpenIDProviders oauth2.OpenIDPCfg
|
|
||||||
|
|
||||||
// BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
|
// BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function.
|
||||||
// It has a default implementation in the security package, however you can replace it for your particular usage.
|
// It has a default implementation in the security package, however you can replace it for your particular usage.
|
||||||
BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
|
BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import (
|
|||||||
func registerLoginHandlers(api *operations.ConsoleAPI) {
|
func registerLoginHandlers(api *operations.ConsoleAPI) {
|
||||||
// GET login strategy
|
// GET login strategy
|
||||||
api.AuthLoginDetailHandler = authApi.LoginDetailHandlerFunc(func(params authApi.LoginDetailParams) middleware.Responder {
|
api.AuthLoginDetailHandler = authApi.LoginDetailHandlerFunc(func(params authApi.LoginDetailParams) middleware.Responder {
|
||||||
loginDetails, err := getLoginDetailsResponse(params, api.OpenIDProviders, oauth2.DefaultIDPConfig)
|
loginDetails, err := getLoginDetailsResponse(params, GlobalMinIOConfig.OpenIDProviders, oauth2.DefaultIDPConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return authApi.NewLoginDetailDefault(int(err.Code)).WithPayload(err)
|
return authApi.NewLoginDetailDefault(int(err.Code)).WithPayload(err)
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ func registerLoginHandlers(api *operations.ConsoleAPI) {
|
|||||||
})
|
})
|
||||||
// POST login using external IDP
|
// POST login using external IDP
|
||||||
api.AuthLoginOauth2AuthHandler = authApi.LoginOauth2AuthHandlerFunc(func(params authApi.LoginOauth2AuthParams) middleware.Responder {
|
api.AuthLoginOauth2AuthHandler = authApi.LoginOauth2AuthHandlerFunc(func(params authApi.LoginOauth2AuthParams) middleware.Responder {
|
||||||
loginResponse, err := getLoginOauth2AuthResponse(params, api.OpenIDProviders, oauth2.DefaultIDPConfig)
|
loginResponse, err := getLoginOauth2AuthResponse(params, GlobalMinIOConfig.OpenIDProviders, oauth2.DefaultIDPConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return authApi.NewLoginOauth2AuthDefault(int(err.Code)).WithPayload(err)
|
return authApi.NewLoginOauth2AuthDefault(int(err.Code)).WithPayload(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,9 +62,13 @@ func initConsoleServer(consoleIDPURL string) (*restapi.Server, error) {
|
|||||||
restapi.LogInfo = noLog
|
restapi.LogInfo = noLog
|
||||||
restapi.LogError = noLog
|
restapi.LogError = noLog
|
||||||
|
|
||||||
api := operations.NewConsoleAPI(swaggerSpec, pcfg)
|
api := operations.NewConsoleAPI(swaggerSpec)
|
||||||
api.Logger = noLog
|
api.Logger = noLog
|
||||||
|
|
||||||
|
restapi.GlobalMinIOConfig = restapi.MinIOConfig{
|
||||||
|
OpenIDProviders: pcfg,
|
||||||
|
}
|
||||||
|
|
||||||
server := restapi.NewServer(api)
|
server := restapi.NewServer(api)
|
||||||
// register all APIs
|
// register all APIs
|
||||||
server.ConfigureAPI()
|
server.ConfigureAPI()
|
||||||
|
|||||||
Reference in New Issue
Block a user