Returned multi user list in tenant created modal (#718)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -23,6 +23,8 @@ package models
|
|||||||
// Editing this file might prove futile when you re-run the swagger generate command
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
@@ -34,7 +36,7 @@ import (
|
|||||||
type CreateTenantResponse struct {
|
type CreateTenantResponse struct {
|
||||||
|
|
||||||
// console
|
// console
|
||||||
Console *CreateTenantResponseConsole `json:"console,omitempty"`
|
Console []*TenantResponseItem `json:"console"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this create tenant response
|
// Validate validates this create tenant response
|
||||||
@@ -57,13 +59,20 @@ func (m *CreateTenantResponse) validateConsole(formats strfmt.Registry) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Console != nil {
|
for i := 0; i < len(m.Console); i++ {
|
||||||
if err := m.Console.Validate(formats); err != nil {
|
if swag.IsZero(m.Console[i]) { // not required
|
||||||
if ve, ok := err.(*errors.Validation); ok {
|
continue
|
||||||
return ve.ValidateName("console")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.Console[i] != nil {
|
||||||
|
if err := m.Console[i].Validate(formats); err != nil {
|
||||||
|
if ve, ok := err.(*errors.Validation); ok {
|
||||||
|
return ve.ValidateName("console" + "." + strconv.Itoa(i))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -86,38 +95,3 @@ func (m *CreateTenantResponse) UnmarshalBinary(b []byte) error {
|
|||||||
*m = res
|
*m = res
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTenantResponseConsole create tenant response console
|
|
||||||
//
|
|
||||||
// swagger:model CreateTenantResponseConsole
|
|
||||||
type CreateTenantResponseConsole struct {
|
|
||||||
|
|
||||||
// access key
|
|
||||||
AccessKey string `json:"access_key,omitempty"`
|
|
||||||
|
|
||||||
// secret key
|
|
||||||
SecretKey string `json:"secret_key,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate validates this create tenant response console
|
|
||||||
func (m *CreateTenantResponseConsole) Validate(formats strfmt.Registry) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalBinary interface implementation
|
|
||||||
func (m *CreateTenantResponseConsole) MarshalBinary() ([]byte, error) {
|
|
||||||
if m == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return swag.WriteJSON(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalBinary interface implementation
|
|
||||||
func (m *CreateTenantResponseConsole) UnmarshalBinary(b []byte) error {
|
|
||||||
var res CreateTenantResponseConsole
|
|
||||||
if err := swag.ReadJSON(b, &res); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*m = res
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
63
models/tenant_response_item.go
Normal file
63
models/tenant_response_item.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
// 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 models
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TenantResponseItem tenant response item
|
||||||
|
//
|
||||||
|
// swagger:model tenantResponseItem
|
||||||
|
type TenantResponseItem struct {
|
||||||
|
|
||||||
|
// access key
|
||||||
|
AccessKey string `json:"access_key,omitempty"`
|
||||||
|
|
||||||
|
// secret key
|
||||||
|
SecretKey string `json:"secret_key,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this tenant response item
|
||||||
|
func (m *TenantResponseItem) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *TenantResponseItem) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *TenantResponseItem) UnmarshalBinary(b []byte) error {
|
||||||
|
var res TenantResponseItem
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -31,6 +31,10 @@ const styles = (theme: Theme) =>
|
|||||||
buttonContainer: {
|
buttonContainer: {
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
},
|
},
|
||||||
|
credentialsPanel: {
|
||||||
|
overflowY: "auto",
|
||||||
|
maxHeight: 350,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ICredentialsPromptProps {
|
interface ICredentialsPromptProps {
|
||||||
@@ -84,16 +88,31 @@ const CredentialsPrompt = ({
|
|||||||
A new {entity} has been created with the following details:
|
A new {entity} has been created with the following details:
|
||||||
{consoleCreds && (
|
{consoleCreds && (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12} className={classes.credentialsPanel}>
|
||||||
<strong>Console Credentials</strong>
|
<strong>Console Credentials</strong>
|
||||||
<ul>
|
{Array.isArray(consoleCreds) &&
|
||||||
<li>
|
consoleCreds.map((credentialsPair, index) => {
|
||||||
<b>Access Key:</b> {consoleCreds.accessKey}
|
return (
|
||||||
</li>
|
<ul key={`creds-item-${index.toString()}`}>
|
||||||
<li>
|
<li>
|
||||||
<b>Secret Key:</b> {consoleCreds.secretKey}
|
<b>Access Key:</b> {credentialsPair.accessKey}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
<li>
|
||||||
|
<b>Secret Key:</b> {credentialsPair.secretKey}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{!Array.isArray(consoleCreds) && (
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>Access Key:</b> {consoleCreds.accessKey}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Secret Key:</b> {consoleCreds.secretKey}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
@@ -112,12 +131,27 @@ const CredentialsPrompt = ({
|
|||||||
let consoleExtras = {};
|
let consoleExtras = {};
|
||||||
|
|
||||||
if (consoleCreds) {
|
if (consoleCreds) {
|
||||||
consoleExtras = {
|
if (!Array.isArray(consoleCreds)) {
|
||||||
console: {
|
consoleExtras = {
|
||||||
access_key: consoleCreds.accessKey,
|
console: [
|
||||||
secret_key: consoleCreds.secretKey,
|
{
|
||||||
},
|
access_key: consoleCreds.accessKey,
|
||||||
};
|
secret_key: consoleCreds.secretKey,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const cCreds = consoleCreds.map((itemMap) => {
|
||||||
|
return {
|
||||||
|
access_key: itemMap.accessKey,
|
||||||
|
secret_key: itemMap.secretKey,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
consoleExtras = {
|
||||||
|
console: [...cCreds],
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
download(
|
download(
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export interface NewServiceAccount {
|
export interface NewServiceAccount {
|
||||||
console?: ConsoleSA;
|
console?: ConsoleSA | ConsoleSA[];
|
||||||
accessKey?: string;
|
accessKey?: string;
|
||||||
secretKey?: string;
|
secretKey?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Fragment, useEffect, useState } from "react";
|
import React, { Fragment, useEffect, useState } from "react";
|
||||||
|
import get from "lodash/get";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from "@material-ui/core/Grid";
|
||||||
import { LinearProgress } from "@material-ui/core";
|
import { LinearProgress } from "@material-ui/core";
|
||||||
@@ -512,13 +513,30 @@ const AddTenant = ({
|
|||||||
api
|
api
|
||||||
.invoke("POST", `/api/v1/tenants`, dataSend)
|
.invoke("POST", `/api/v1/tenants`, dataSend)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const newSrvAcc: NewServiceAccount = {
|
const consoleSAList = get(res, "console", []);
|
||||||
console: {
|
|
||||||
accessKey: res.console.access_key,
|
let newSrvAcc: NewServiceAccount = {
|
||||||
secretKey: res.console.secret_key,
|
console: [],
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (consoleSAList && Array.isArray(consoleSAList)) {
|
||||||
|
const consoleItem = consoleSAList.map((consoleKey) => {
|
||||||
|
return {
|
||||||
|
accessKey: consoleKey.access_key,
|
||||||
|
secretKey: consoleKey.secret_key,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
newSrvAcc.console = consoleItem;
|
||||||
|
} else {
|
||||||
|
newSrvAcc = {
|
||||||
|
console: {
|
||||||
|
accessKey: res.console.access_key,
|
||||||
|
secretKey: res.console.secret_key,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
setAddSending(false);
|
setAddSending(false);
|
||||||
|
|
||||||
setShowNewCredentials(true);
|
setShowNewCredentials(true);
|
||||||
|
|||||||
@@ -767,6 +767,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
|
|||||||
// optionals are set below
|
// optionals are set below
|
||||||
var tenantUserAccessKey string
|
var tenantUserAccessKey string
|
||||||
var tenantUserSecretKey string
|
var tenantUserSecretKey string
|
||||||
|
keyElementEmpty := len(tenantReq.Idp.Keys) == 1 && (*tenantReq.Idp.Keys[0].AccessKey == "" && *tenantReq.Idp.Keys[0].SecretKey == "")
|
||||||
|
|
||||||
enableConsole := true
|
enableConsole := true
|
||||||
if tenantReq.EnableConsole != nil && *tenantReq.EnableConsole {
|
if tenantReq.EnableConsole != nil && *tenantReq.EnableConsole {
|
||||||
@@ -775,7 +776,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
|
|||||||
|
|
||||||
if enableConsole {
|
if enableConsole {
|
||||||
// provision initial user for tenant
|
// provision initial user for tenant
|
||||||
if !(len(tenantReq.Idp.Keys) > 0) {
|
if len(tenantReq.Idp.Keys) == 0 || keyElementEmpty {
|
||||||
tenantUserAccessKey = RandomCharString(16)
|
tenantUserAccessKey = RandomCharString(16)
|
||||||
tenantUserSecretKey = RandomCharString(32)
|
tenantUserSecretKey = RandomCharString(32)
|
||||||
consoleUserSecretName := fmt.Sprintf("%s-user-secret", tenantName)
|
consoleUserSecretName := fmt.Sprintf("%s-user-secret", tenantName)
|
||||||
@@ -1055,10 +1056,17 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
|
|||||||
response = &models.CreateTenantResponse{}
|
response = &models.CreateTenantResponse{}
|
||||||
// Attach Console Credentials
|
// Attach Console Credentials
|
||||||
if enableConsole {
|
if enableConsole {
|
||||||
response.Console = &models.CreateTenantResponseConsole{
|
var itemsToReturn []*models.TenantResponseItem
|
||||||
AccessKey: tenantUserAccessKey,
|
|
||||||
SecretKey: tenantUserSecretKey,
|
if len(tenantReq.Idp.Keys) == 0 || keyElementEmpty {
|
||||||
|
itemsToReturn = append(itemsToReturn, &models.TenantResponseItem{AccessKey: tenantUserAccessKey, SecretKey: tenantUserSecretKey})
|
||||||
|
} else { // IDP Keys
|
||||||
|
for _, item := range tenantReq.Idp.Keys {
|
||||||
|
itemsToReturn = append(itemsToReturn, &models.TenantResponseItem{AccessKey: *item.AccessKey, SecretKey: *item.SecretKey})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Console = itemsToReturn
|
||||||
}
|
}
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4330,14 +4330,9 @@ func init() {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"console": {
|
"console": {
|
||||||
"type": "object",
|
"type": "array",
|
||||||
"properties": {
|
"items": {
|
||||||
"access_key": {
|
"$ref": "#/definitions/tenantResponseItem"
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"secret_key": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6337,6 +6332,17 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tenantResponseItem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"access_key": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"secret_key": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"tenantUsage": {
|
"tenantUsage": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -10463,17 +10469,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CreateTenantResponseConsole": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"access_key": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"secret_key": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GcpConfigurationSecretmanager": {
|
"GcpConfigurationSecretmanager": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@@ -11668,14 +11663,9 @@ func init() {
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"console": {
|
"console": {
|
||||||
"type": "object",
|
"type": "array",
|
||||||
"properties": {
|
"items": {
|
||||||
"access_key": {
|
"$ref": "#/definitions/tenantResponseItem"
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"secret_key": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13528,6 +13518,17 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tenantResponseItem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"access_key": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"secret_key": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"tenantUsage": {
|
"tenantUsage": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
18
swagger.yml
18
swagger.yml
@@ -3851,12 +3851,18 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
console:
|
console:
|
||||||
type: object
|
type: array
|
||||||
properties:
|
items:
|
||||||
access_key:
|
$ref: "#/definitions/tenantResponseItem"
|
||||||
type: string
|
|
||||||
secret_key:
|
tenantResponseItem:
|
||||||
type: string
|
type: object
|
||||||
|
properties:
|
||||||
|
access_key:
|
||||||
|
type: string
|
||||||
|
secret_key:
|
||||||
|
type: string
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
|
|||||||
Reference in New Issue
Block a user