Skip to content

Commit

Permalink
Fix build after swagger codegen (#2201)
Browse files Browse the repository at this point in the history
  • Loading branch information
donatello authored Jul 28, 2022
1 parent 25f719b commit 3b11556
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmd/console/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func buildServer() (*restapi.Server, error) {
return nil, err
}

api := operations.NewConsoleAPI(swaggerSpec, nil)
api := operations.NewConsoleAPI(swaggerSpec)
api.Logger = restapi.LogInfo
server := restapi.NewServer(api)

Expand Down
2 changes: 1 addition & 1 deletion integration/buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func initConsoleServer() (*restapi.Server, error) {
restapi.LogInfo = noLog
restapi.LogError = noLog

api := operations.NewConsoleAPI(swaggerSpec, nil)
api := operations.NewConsoleAPI(swaggerSpec)
api.Logger = noLog

server := restapi.NewServer(api)
Expand Down
2 changes: 1 addition & 1 deletion replication/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func initConsoleServer() (*restapi.Server, error) {
restapi.LogInfo = noLog
restapi.LogError = noLog

api := operations.NewConsoleAPI(swaggerSpec, nil)
api := operations.NewConsoleAPI(swaggerSpec)
api.Logger = noLog

server := restapi.NewServer(api)
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_arns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestRegisterAdminArnsHandlers(t *testing.T) {
if err != nil {
assert.Fail("Error")
}
api := operations.NewConsoleAPI(swaggerSpec, nil)
api := operations.NewConsoleAPI(swaggerSpec)
api.SystemArnListHandler = nil
registerAdminArnsHandlers(api)
if api.SystemArnListHandler == nil {
Expand Down
29 changes: 20 additions & 9 deletions restapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strconv"
"strings"

"github.com/minio/console/pkg/auth/idp/oauth2"
xcerts "github.com/minio/pkg/certs"
"github.com/minio/pkg/env"
xnet "github.com/minio/pkg/net"
Expand All @@ -46,6 +47,25 @@ var (
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 {
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
}
Expand Down Expand Up @@ -234,12 +254,3 @@ func getPrometheusJobID() string {
func getPrometheusExtraLabels() string {
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
)
8 changes: 1 addition & 7 deletions restapi/operations/console_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions restapi/user_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
func registerLoginHandlers(api *operations.ConsoleAPI) {
// GET login strategy
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 {
return authApi.NewLoginDetailDefault(int(err.Code)).WithPayload(err)
}
Expand All @@ -56,7 +56,7 @@ func registerLoginHandlers(api *operations.ConsoleAPI) {
})
// POST login using external IDP
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 {
return authApi.NewLoginOauth2AuthDefault(int(err.Code)).WithPayload(err)
}
Expand Down
6 changes: 5 additions & 1 deletion sso-integration/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ func initConsoleServer(consoleIDPURL string) (*restapi.Server, error) {
restapi.LogInfo = noLog
restapi.LogError = noLog

api := operations.NewConsoleAPI(swaggerSpec, pcfg)
api := operations.NewConsoleAPI(swaggerSpec)
api.Logger = noLog

restapi.GlobalMinIOConfig = restapi.MinIOConfig{
OpenIDProviders: pcfg,
}

server := restapi.NewServer(api)
// register all APIs
server.ConfigureAPI()
Expand Down

0 comments on commit 3b11556

Please sign in to comment.