Fix Session validation for MCS Operator Mode (#191)
* Fix Session validation for MCS Operator Mode * Updated assets
This commit is contained in:
@@ -156,12 +156,12 @@ func NewMcsAPI(spec *loads.Document) *McsAPI {
|
||||
UserAPILoginDetailHandler: user_api.LoginDetailHandlerFunc(func(params user_api.LoginDetailParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.LoginDetail has not yet been implemented")
|
||||
}),
|
||||
UserAPILoginMkubeHandler: user_api.LoginMkubeHandlerFunc(func(params user_api.LoginMkubeParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.LoginMkube has not yet been implemented")
|
||||
}),
|
||||
UserAPILoginOauth2AuthHandler: user_api.LoginOauth2AuthHandlerFunc(func(params user_api.LoginOauth2AuthParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.LoginOauth2Auth has not yet been implemented")
|
||||
}),
|
||||
UserAPILoginOperatorHandler: user_api.LoginOperatorHandlerFunc(func(params user_api.LoginOperatorParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.LoginOperator has not yet been implemented")
|
||||
}),
|
||||
UserAPILogoutHandler: user_api.LogoutHandlerFunc(func(params user_api.LogoutParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.Logout has not yet been implemented")
|
||||
}),
|
||||
@@ -327,10 +327,10 @@ type McsAPI struct {
|
||||
UserAPILoginHandler user_api.LoginHandler
|
||||
// UserAPILoginDetailHandler sets the operation handler for the login detail operation
|
||||
UserAPILoginDetailHandler user_api.LoginDetailHandler
|
||||
// UserAPILoginMkubeHandler sets the operation handler for the login mkube operation
|
||||
UserAPILoginMkubeHandler user_api.LoginMkubeHandler
|
||||
// UserAPILoginOauth2AuthHandler sets the operation handler for the login oauth2 auth operation
|
||||
UserAPILoginOauth2AuthHandler user_api.LoginOauth2AuthHandler
|
||||
// UserAPILoginOperatorHandler sets the operation handler for the login operator operation
|
||||
UserAPILoginOperatorHandler user_api.LoginOperatorHandler
|
||||
// UserAPILogoutHandler sets the operation handler for the logout operation
|
||||
UserAPILogoutHandler user_api.LogoutHandler
|
||||
// UserAPIMakeBucketHandler sets the operation handler for the make bucket operation
|
||||
@@ -533,12 +533,12 @@ func (o *McsAPI) Validate() error {
|
||||
if o.UserAPILoginDetailHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.LoginDetailHandler")
|
||||
}
|
||||
if o.UserAPILoginMkubeHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.LoginMkubeHandler")
|
||||
}
|
||||
if o.UserAPILoginOauth2AuthHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.LoginOauth2AuthHandler")
|
||||
}
|
||||
if o.UserAPILoginOperatorHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.LoginOperatorHandler")
|
||||
}
|
||||
if o.UserAPILogoutHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.LogoutHandler")
|
||||
}
|
||||
@@ -820,11 +820,11 @@ func (o *McsAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/login/mkube"] = user_api.NewLoginMkube(o.context, o.UserAPILoginMkubeHandler)
|
||||
o.handlers["POST"]["/login/oauth2/auth"] = user_api.NewLoginOauth2Auth(o.context, o.UserAPILoginOauth2AuthHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/login/oauth2/auth"] = user_api.NewLoginOauth2Auth(o.context, o.UserAPILoginOauth2AuthHandler)
|
||||
o.handlers["POST"]["/login/operator"] = user_api.NewLoginOperator(o.context, o.UserAPILoginOperatorHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -28,40 +28,40 @@ import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// LoginMkubeHandlerFunc turns a function with the right signature into a login mkube handler
|
||||
type LoginMkubeHandlerFunc func(LoginMkubeParams) middleware.Responder
|
||||
// LoginOperatorHandlerFunc turns a function with the right signature into a login operator handler
|
||||
type LoginOperatorHandlerFunc func(LoginOperatorParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn LoginMkubeHandlerFunc) Handle(params LoginMkubeParams) middleware.Responder {
|
||||
func (fn LoginOperatorHandlerFunc) Handle(params LoginOperatorParams) middleware.Responder {
|
||||
return fn(params)
|
||||
}
|
||||
|
||||
// LoginMkubeHandler interface for that can handle valid login mkube params
|
||||
type LoginMkubeHandler interface {
|
||||
Handle(LoginMkubeParams) middleware.Responder
|
||||
// LoginOperatorHandler interface for that can handle valid login operator params
|
||||
type LoginOperatorHandler interface {
|
||||
Handle(LoginOperatorParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewLoginMkube creates a new http.Handler for the login mkube operation
|
||||
func NewLoginMkube(ctx *middleware.Context, handler LoginMkubeHandler) *LoginMkube {
|
||||
return &LoginMkube{Context: ctx, Handler: handler}
|
||||
// NewLoginOperator creates a new http.Handler for the login operator operation
|
||||
func NewLoginOperator(ctx *middleware.Context, handler LoginOperatorHandler) *LoginOperator {
|
||||
return &LoginOperator{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*LoginMkube swagger:route POST /login/mkube UserAPI loginMkube
|
||||
/*LoginOperator swagger:route POST /login/operator UserAPI loginOperator
|
||||
|
||||
Login to Mkube.
|
||||
Login to Operator Console.
|
||||
|
||||
*/
|
||||
type LoginMkube struct {
|
||||
type LoginOperator struct {
|
||||
Context *middleware.Context
|
||||
Handler LoginMkubeHandler
|
||||
Handler LoginOperatorHandler
|
||||
}
|
||||
|
||||
func (o *LoginMkube) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
func (o *LoginOperator) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewLoginMkubeParams()
|
||||
var Params = NewLoginOperatorParams()
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
@@ -33,18 +33,18 @@ import (
|
||||
"github.com/minio/mcs/models"
|
||||
)
|
||||
|
||||
// NewLoginMkubeParams creates a new LoginMkubeParams object
|
||||
// NewLoginOperatorParams creates a new LoginOperatorParams object
|
||||
// no default values defined in spec.
|
||||
func NewLoginMkubeParams() LoginMkubeParams {
|
||||
func NewLoginOperatorParams() LoginOperatorParams {
|
||||
|
||||
return LoginMkubeParams{}
|
||||
return LoginOperatorParams{}
|
||||
}
|
||||
|
||||
// LoginMkubeParams contains all the bound params for the login mkube operation
|
||||
// LoginOperatorParams contains all the bound params for the login operator operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters LoginMkube
|
||||
type LoginMkubeParams struct {
|
||||
// swagger:parameters LoginOperator
|
||||
type LoginOperatorParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
@@ -53,21 +53,21 @@ type LoginMkubeParams struct {
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.LoginMkubeRequest
|
||||
Body *models.LoginOperatorRequest
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewLoginMkubeParams() beforehand.
|
||||
func (o *LoginMkubeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewLoginOperatorParams() beforehand.
|
||||
func (o *LoginOperatorParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.LoginMkubeRequest
|
||||
var body models.LoginOperatorRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
@@ -30,14 +30,14 @@ import (
|
||||
"github.com/minio/mcs/models"
|
||||
)
|
||||
|
||||
// LoginMkubeCreatedCode is the HTTP code returned for type LoginMkubeCreated
|
||||
const LoginMkubeCreatedCode int = 201
|
||||
// LoginOperatorCreatedCode is the HTTP code returned for type LoginOperatorCreated
|
||||
const LoginOperatorCreatedCode int = 201
|
||||
|
||||
/*LoginMkubeCreated A successful login.
|
||||
/*LoginOperatorCreated A successful login.
|
||||
|
||||
swagger:response loginMkubeCreated
|
||||
swagger:response loginOperatorCreated
|
||||
*/
|
||||
type LoginMkubeCreated struct {
|
||||
type LoginOperatorCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
@@ -45,25 +45,25 @@ type LoginMkubeCreated struct {
|
||||
Payload *models.LoginResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewLoginMkubeCreated creates LoginMkubeCreated with default headers values
|
||||
func NewLoginMkubeCreated() *LoginMkubeCreated {
|
||||
// NewLoginOperatorCreated creates LoginOperatorCreated with default headers values
|
||||
func NewLoginOperatorCreated() *LoginOperatorCreated {
|
||||
|
||||
return &LoginMkubeCreated{}
|
||||
return &LoginOperatorCreated{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the login mkube created response
|
||||
func (o *LoginMkubeCreated) WithPayload(payload *models.LoginResponse) *LoginMkubeCreated {
|
||||
// WithPayload adds the payload to the login operator created response
|
||||
func (o *LoginOperatorCreated) WithPayload(payload *models.LoginResponse) *LoginOperatorCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the login mkube created response
|
||||
func (o *LoginMkubeCreated) SetPayload(payload *models.LoginResponse) {
|
||||
// SetPayload sets the payload to the login operator created response
|
||||
func (o *LoginOperatorCreated) SetPayload(payload *models.LoginResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginMkubeCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *LoginOperatorCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
@@ -74,11 +74,11 @@ func (o *LoginMkubeCreated) WriteResponse(rw http.ResponseWriter, producer runti
|
||||
}
|
||||
}
|
||||
|
||||
/*LoginMkubeDefault Generic error response.
|
||||
/*LoginOperatorDefault Generic error response.
|
||||
|
||||
swagger:response loginMkubeDefault
|
||||
swagger:response loginOperatorDefault
|
||||
*/
|
||||
type LoginMkubeDefault struct {
|
||||
type LoginOperatorDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
@@ -87,41 +87,41 @@ type LoginMkubeDefault struct {
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewLoginMkubeDefault creates LoginMkubeDefault with default headers values
|
||||
func NewLoginMkubeDefault(code int) *LoginMkubeDefault {
|
||||
// NewLoginOperatorDefault creates LoginOperatorDefault with default headers values
|
||||
func NewLoginOperatorDefault(code int) *LoginOperatorDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &LoginMkubeDefault{
|
||||
return &LoginOperatorDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the login mkube default response
|
||||
func (o *LoginMkubeDefault) WithStatusCode(code int) *LoginMkubeDefault {
|
||||
// WithStatusCode adds the status to the login operator default response
|
||||
func (o *LoginOperatorDefault) WithStatusCode(code int) *LoginOperatorDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the login mkube default response
|
||||
func (o *LoginMkubeDefault) SetStatusCode(code int) {
|
||||
// SetStatusCode sets the status to the login operator default response
|
||||
func (o *LoginOperatorDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the login mkube default response
|
||||
func (o *LoginMkubeDefault) WithPayload(payload *models.Error) *LoginMkubeDefault {
|
||||
// WithPayload adds the payload to the login operator default response
|
||||
func (o *LoginOperatorDefault) WithPayload(payload *models.Error) *LoginOperatorDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the login mkube default response
|
||||
func (o *LoginMkubeDefault) SetPayload(payload *models.Error) {
|
||||
// SetPayload sets the payload to the login operator default response
|
||||
func (o *LoginOperatorDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginMkubeDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *LoginOperatorDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// LoginMkubeURL generates an URL for the login mkube operation
|
||||
type LoginMkubeURL struct {
|
||||
// LoginOperatorURL generates an URL for the login operator operation
|
||||
type LoginOperatorURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *LoginMkubeURL) WithBasePath(bp string) *LoginMkubeURL {
|
||||
func (o *LoginOperatorURL) WithBasePath(bp string) *LoginOperatorURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
@@ -44,15 +44,15 @@ func (o *LoginMkubeURL) WithBasePath(bp string) *LoginMkubeURL {
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *LoginMkubeURL) SetBasePath(bp string) {
|
||||
func (o *LoginOperatorURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *LoginMkubeURL) Build() (*url.URL, error) {
|
||||
func (o *LoginOperatorURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/login/mkube"
|
||||
var _path = "/login/operator"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,7 +64,7 @@ func (o *LoginMkubeURL) Build() (*url.URL, error) {
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *LoginMkubeURL) Must(u *url.URL, err error) *url.URL {
|
||||
func (o *LoginOperatorURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -75,17 +75,17 @@ func (o *LoginMkubeURL) Must(u *url.URL, err error) *url.URL {
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *LoginMkubeURL) String() string {
|
||||
func (o *LoginOperatorURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *LoginMkubeURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
func (o *LoginOperatorURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on LoginMkubeURL")
|
||||
return nil, errors.New("scheme is required for a full url on LoginOperatorURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on LoginMkubeURL")
|
||||
return nil, errors.New("host is required for a full url on LoginOperatorURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
@@ -99,6 +99,6 @@ func (o *LoginMkubeURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *LoginMkubeURL) StringFull(scheme, host string) string {
|
||||
func (o *LoginOperatorURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
Reference in New Issue
Block a user