Fixed broken oauth2 login for operator (#1217)
This PR includes many fixes and refactors for oauth2 authentication and login endpoints, ie: - Invalid login returns `403` instead of `500` error - Removed the session token from console/operator `user credentials login`, `oauth flow login` and `change-password` api responses - Removed session token from localStorage - Added styles for oauth_callback page and display more descriptive errors for debugging - Success logins returns `204` instead of `200` - Removed unused swagger apis and code from both, operator and console projects - Operator `Oauth2` login flow was not validating anything, now it does Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
@@ -263,9 +263,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
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")
|
||||
}),
|
||||
@@ -549,8 +546,6 @@ type ConsoleAPI struct {
|
||||
UserAPILoginDetailHandler user_api.LoginDetailHandler
|
||||
// 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
|
||||
@@ -900,9 +895,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
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")
|
||||
}
|
||||
@@ -1368,10 +1360,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
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)
|
||||
}
|
||||
o.handlers["POST"]["/logout"] = user_api.NewLogout(o.context, o.UserAPILogoutHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
|
||||
@@ -30,48 +30,28 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AccountChangePasswordCreatedCode is the HTTP code returned for type AccountChangePasswordCreated
|
||||
const AccountChangePasswordCreatedCode int = 201
|
||||
// AccountChangePasswordNoContentCode is the HTTP code returned for type AccountChangePasswordNoContent
|
||||
const AccountChangePasswordNoContentCode int = 204
|
||||
|
||||
/*AccountChangePasswordCreated A successful login.
|
||||
/*AccountChangePasswordNoContent A successful login.
|
||||
|
||||
swagger:response accountChangePasswordCreated
|
||||
swagger:response accountChangePasswordNoContent
|
||||
*/
|
||||
type AccountChangePasswordCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.LoginResponse `json:"body,omitempty"`
|
||||
type AccountChangePasswordNoContent struct {
|
||||
}
|
||||
|
||||
// NewAccountChangePasswordCreated creates AccountChangePasswordCreated with default headers values
|
||||
func NewAccountChangePasswordCreated() *AccountChangePasswordCreated {
|
||||
// NewAccountChangePasswordNoContent creates AccountChangePasswordNoContent with default headers values
|
||||
func NewAccountChangePasswordNoContent() *AccountChangePasswordNoContent {
|
||||
|
||||
return &AccountChangePasswordCreated{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the account change password created response
|
||||
func (o *AccountChangePasswordCreated) WithPayload(payload *models.LoginResponse) *AccountChangePasswordCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the account change password created response
|
||||
func (o *AccountChangePasswordCreated) SetPayload(payload *models.LoginResponse) {
|
||||
o.Payload = payload
|
||||
return &AccountChangePasswordNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AccountChangePasswordCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *AccountChangePasswordNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*AccountChangePasswordDefault Generic error response.
|
||||
|
||||
@@ -30,48 +30,28 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// LoginOauth2AuthCreatedCode is the HTTP code returned for type LoginOauth2AuthCreated
|
||||
const LoginOauth2AuthCreatedCode int = 201
|
||||
// LoginOauth2AuthNoContentCode is the HTTP code returned for type LoginOauth2AuthNoContent
|
||||
const LoginOauth2AuthNoContentCode int = 204
|
||||
|
||||
/*LoginOauth2AuthCreated A successful login.
|
||||
/*LoginOauth2AuthNoContent A successful login.
|
||||
|
||||
swagger:response loginOauth2AuthCreated
|
||||
swagger:response loginOauth2AuthNoContent
|
||||
*/
|
||||
type LoginOauth2AuthCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.LoginResponse `json:"body,omitempty"`
|
||||
type LoginOauth2AuthNoContent struct {
|
||||
}
|
||||
|
||||
// NewLoginOauth2AuthCreated creates LoginOauth2AuthCreated with default headers values
|
||||
func NewLoginOauth2AuthCreated() *LoginOauth2AuthCreated {
|
||||
// NewLoginOauth2AuthNoContent creates LoginOauth2AuthNoContent with default headers values
|
||||
func NewLoginOauth2AuthNoContent() *LoginOauth2AuthNoContent {
|
||||
|
||||
return &LoginOauth2AuthCreated{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the login oauth2 auth created response
|
||||
func (o *LoginOauth2AuthCreated) WithPayload(payload *models.LoginResponse) *LoginOauth2AuthCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the login oauth2 auth created response
|
||||
func (o *LoginOauth2AuthCreated) SetPayload(payload *models.LoginResponse) {
|
||||
o.Payload = payload
|
||||
return &LoginOauth2AuthNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginOauth2AuthCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *LoginOauth2AuthNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*LoginOauth2AuthDefault Generic error response.
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package user_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// 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 LoginOperatorHandlerFunc) Handle(params LoginOperatorParams) middleware.Responder {
|
||||
return fn(params)
|
||||
}
|
||||
|
||||
// LoginOperatorHandler interface for that can handle valid login operator params
|
||||
type LoginOperatorHandler interface {
|
||||
Handle(LoginOperatorParams) middleware.Responder
|
||||
}
|
||||
|
||||
// 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}
|
||||
}
|
||||
|
||||
/* LoginOperator swagger:route POST /login/operator UserAPI loginOperator
|
||||
|
||||
Login to Operator Console.
|
||||
|
||||
*/
|
||||
type LoginOperator struct {
|
||||
Context *middleware.Context
|
||||
Handler LoginOperatorHandler
|
||||
}
|
||||
|
||||
func (o *LoginOperator) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewLoginOperatorParams()
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package user_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewLoginOperatorParams creates a new LoginOperatorParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewLoginOperatorParams() LoginOperatorParams {
|
||||
|
||||
return LoginOperatorParams{}
|
||||
}
|
||||
|
||||
// LoginOperatorParams contains all the bound params for the login operator operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters LoginOperator
|
||||
type LoginOperatorParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
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 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.LoginOperatorRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(context.Background())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package user_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// LoginOperatorCreatedCode is the HTTP code returned for type LoginOperatorCreated
|
||||
const LoginOperatorCreatedCode int = 201
|
||||
|
||||
/*LoginOperatorCreated A successful login.
|
||||
|
||||
swagger:response loginOperatorCreated
|
||||
*/
|
||||
type LoginOperatorCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.LoginResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewLoginOperatorCreated creates LoginOperatorCreated with default headers values
|
||||
func NewLoginOperatorCreated() *LoginOperatorCreated {
|
||||
|
||||
return &LoginOperatorCreated{}
|
||||
}
|
||||
|
||||
// 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 operator created response
|
||||
func (o *LoginOperatorCreated) SetPayload(payload *models.LoginResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginOperatorCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*LoginOperatorDefault Generic error response.
|
||||
|
||||
swagger:response loginOperatorDefault
|
||||
*/
|
||||
type LoginOperatorDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewLoginOperatorDefault creates LoginOperatorDefault with default headers values
|
||||
func NewLoginOperatorDefault(code int) *LoginOperatorDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &LoginOperatorDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 operator default response
|
||||
func (o *LoginOperatorDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// 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 operator default response
|
||||
func (o *LoginOperatorDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginOperatorDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package user_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// 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 *LoginOperatorURL) WithBasePath(bp string) *LoginOperatorURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// 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 *LoginOperatorURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *LoginOperatorURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/login/operator"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *LoginOperatorURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query 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 *LoginOperatorURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
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 LoginOperatorURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *LoginOperatorURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -30,48 +30,28 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// LoginCreatedCode is the HTTP code returned for type LoginCreated
|
||||
const LoginCreatedCode int = 201
|
||||
// LoginNoContentCode is the HTTP code returned for type LoginNoContent
|
||||
const LoginNoContentCode int = 204
|
||||
|
||||
/*LoginCreated A successful login.
|
||||
/*LoginNoContent A successful login.
|
||||
|
||||
swagger:response loginCreated
|
||||
swagger:response loginNoContent
|
||||
*/
|
||||
type LoginCreated struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.LoginResponse `json:"body,omitempty"`
|
||||
type LoginNoContent struct {
|
||||
}
|
||||
|
||||
// NewLoginCreated creates LoginCreated with default headers values
|
||||
func NewLoginCreated() *LoginCreated {
|
||||
// NewLoginNoContent creates LoginNoContent with default headers values
|
||||
func NewLoginNoContent() *LoginNoContent {
|
||||
|
||||
return &LoginCreated{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the login created response
|
||||
func (o *LoginCreated) WithPayload(payload *models.LoginResponse) *LoginCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the login created response
|
||||
func (o *LoginCreated) SetPayload(payload *models.LoginResponse) {
|
||||
o.Payload = payload
|
||||
return &LoginNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *LoginCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *LoginNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(201)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*LoginDefault Generic error response.
|
||||
|
||||
@@ -50,7 +50,7 @@ func NewLogout(ctx *middleware.Context, handler LogoutHandler) *Logout {
|
||||
|
||||
/* Logout swagger:route POST /logout UserAPI logout
|
||||
|
||||
Logout from Operator.
|
||||
Logout from Console.
|
||||
|
||||
*/
|
||||
type Logout struct {
|
||||
|
||||
Reference in New Issue
Block a user