Support for special characters and remove buggy functions (#1977)
- remove the use of encodeURI and encodeURIComponent functions and instead use encodeFileName and decodeFileName functions - support for users with special characters - support for users with special characters - support for users with special characters - fixed incorrectly group list display for policies Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/pkg/utils"
|
||||
"github.com/minio/console/restapi/operations"
|
||||
"github.com/minio/madmin-go"
|
||||
|
||||
@@ -117,7 +118,12 @@ func getGroupInfoResponse(session *models.Principal, params groupApi.GroupInfoPa
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
groupDesc, err := groupInfo(ctx, adminClient, params.Name)
|
||||
groupName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
groupDesc, err := groupInfo(ctx, adminClient, groupName)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
@@ -202,10 +208,16 @@ func getRemoveGroupResponse(session *models.Principal, params groupApi.RemoveGro
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// createad a MinIO Admin Client interface implementation
|
||||
// Create a MinIO Admin Client interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
if err := removeGroup(ctx, adminClient, params.Name); err != nil {
|
||||
|
||||
groupName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
if err := removeGroup(ctx, adminClient, groupName); err != nil {
|
||||
minioError := madmin.ToErrorResponse(err)
|
||||
err2 := ErrorWithContext(ctx, err)
|
||||
if minioError.Code == "XMinioAdminNoSuchGroup" {
|
||||
@@ -280,7 +292,11 @@ func getUpdateGroupResponse(session *models.Principal, params groupApi.UpdateGro
|
||||
return nil, ErrorWithContext(ctx, ErrGroupBodyNotInRequest)
|
||||
}
|
||||
expectedGroupUpdate := params.Body
|
||||
groupName := params.Name
|
||||
|
||||
groupName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
|
||||
@@ -24,6 +24,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/console/pkg/utils"
|
||||
|
||||
bucketApi "github.com/minio/console/restapi/operations/bucket"
|
||||
policyApi "github.com/minio/console/restapi/operations/policy"
|
||||
|
||||
@@ -293,7 +295,10 @@ func getListPoliciesResponse(session *models.Principal, params policyApi.ListPol
|
||||
func getListUsersForPolicyResponse(session *models.Principal, params policyApi.ListUsersForPolicyParams) ([]string, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
policy := params.Policy
|
||||
policy, err := utils.DecodeBase64(params.Policy)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
@@ -371,7 +376,10 @@ func getListGroupsForPolicyResponse(session *models.Principal, params policyApi.
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
policy := params.Policy
|
||||
policy, err := utils.DecodeBase64(params.Policy)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
policies, err := listPolicies(ctx, adminClient)
|
||||
if err != nil {
|
||||
@@ -398,8 +406,11 @@ func getListGroupsForPolicyResponse(session *models.Principal, params policyApi.
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
if info.Policy == policy {
|
||||
filteredGroups = append(filteredGroups, group)
|
||||
groupPolicies := strings.Split(info.Policy, ",")
|
||||
for _, groupPolicy := range groupPolicies {
|
||||
if groupPolicy == policy {
|
||||
filteredGroups = append(filteredGroups, group)
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Strings(filteredGroups)
|
||||
@@ -422,6 +433,10 @@ func getRemovePolicyResponse(session *models.Principal, params policyApi.RemoveP
|
||||
if params.Name == "" {
|
||||
return ErrorWithContext(ctx, ErrPolicyNameNotInRequest)
|
||||
}
|
||||
policyName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
@@ -430,7 +445,7 @@ func getRemovePolicyResponse(session *models.Principal, params policyApi.RemoveP
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
if err := removePolicy(ctx, adminClient, params.Name); err != nil {
|
||||
if err := removePolicy(ctx, adminClient, policyName); err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
@@ -506,7 +521,11 @@ func getPolicyInfoResponse(session *models.Principal, params policyApi.PolicyInf
|
||||
// create a MinIO Admin Client interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
policy, err := policyInfo(ctx, adminClient, params.Name)
|
||||
policyName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
policy, err := policyInfo(ctx, adminClient, policyName)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/console/pkg/utils"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
@@ -249,13 +251,17 @@ func getRemoveUserResponse(session *models.Principal, params userApi.RemoveUserP
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
if session.AccountAccessKey == params.Name {
|
||||
userName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
if session.AccountAccessKey == userName {
|
||||
return ErrorWithContext(ctx, ErrAvoidSelfAccountDelete)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
if err := removeUser(ctx, adminClient, params.Name); err != nil {
|
||||
if err := removeUser(ctx, adminClient, userName); err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
@@ -283,7 +289,12 @@ func getUserInfoResponse(session *models.Principal, params userApi.GetUserInfoPa
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
user, err := getUserInfo(ctx, adminClient, params.Name)
|
||||
userName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
user, err := getUserInfo(ctx, adminClient, userName)
|
||||
if err != nil {
|
||||
// User doesn't exist, return 404
|
||||
if madmin.ToErrorResponse(err).Code == "XMinioAdminNoSuchUser" {
|
||||
@@ -318,7 +329,7 @@ func getUserInfoResponse(session *models.Principal, params userApi.GetUserInfoPa
|
||||
}
|
||||
|
||||
userInformation := &models.User{
|
||||
AccessKey: params.Name,
|
||||
AccessKey: userName,
|
||||
MemberOf: user.MemberOf,
|
||||
Policy: policies,
|
||||
Status: string(user.Status),
|
||||
@@ -429,7 +440,12 @@ func getUpdateUserGroupsResponse(session *models.Principal, params userApi.Updat
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
user, err := updateUserGroups(ctx, adminClient, params.Name, params.Body.Groups)
|
||||
userName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
user, err := updateUserGroups(ctx, adminClient, userName, params.Body.Groups)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
@@ -464,16 +480,18 @@ func getUpdateUserResponse(session *models.Principal, params userApi.UpdateUserI
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
name := params.Name
|
||||
userName, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
status := *params.Body.Status
|
||||
groups := params.Body.Groups
|
||||
|
||||
if err := setUserStatus(ctx, adminClient, name, status); err != nil {
|
||||
if err := setUserStatus(ctx, adminClient, userName, status); err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
userElem, errUG := updateUserGroups(ctx, adminClient, name, groups)
|
||||
userElem, errUG := updateUserGroups(ctx, adminClient, userName, groups)
|
||||
|
||||
if errUG != nil {
|
||||
return nil, ErrorWithContext(ctx, errUG)
|
||||
|
||||
@@ -2617,7 +2617,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/group": {
|
||||
"/group/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Group"
|
||||
@@ -2628,7 +2628,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -2657,7 +2657,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -2694,7 +2694,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -3139,7 +3139,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/policy": {
|
||||
"/policy/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
@@ -3150,7 +3150,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -3179,7 +3179,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -3843,7 +3843,30 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user": {
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
],
|
||||
"summary": "returns policies for logged in user",
|
||||
"operationId": "GetUserPolicy",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"User"
|
||||
@@ -3854,7 +3877,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -3883,7 +3906,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -3920,7 +3943,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -3937,7 +3960,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/groups": {
|
||||
"/user/{name}/groups": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"User"
|
||||
@@ -3948,7 +3971,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -3976,29 +3999,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
],
|
||||
"summary": "returns policies for logged in user",
|
||||
"operationId": "GetUserPolicy",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{name}/service-account-credentials": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -9565,7 +9565,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/group": {
|
||||
"/group/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Group"
|
||||
@@ -9576,7 +9576,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -9605,7 +9605,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -9642,7 +9642,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -10087,7 +10087,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/policy": {
|
||||
"/policy/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
@@ -10098,7 +10098,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -10127,7 +10127,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -10791,7 +10791,30 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user": {
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
],
|
||||
"summary": "returns policies for logged in user",
|
||||
"operationId": "GetUserPolicy",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{name}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"User"
|
||||
@@ -10802,7 +10825,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -10831,7 +10854,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -10868,7 +10891,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
@@ -10885,7 +10908,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/groups": {
|
||||
"/user/{name}/groups": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"User"
|
||||
@@ -10896,7 +10919,7 @@ func init() {
|
||||
{
|
||||
"type": "string",
|
||||
"name": "name",
|
||||
"in": "query",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
@@ -10924,29 +10947,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Policy"
|
||||
],
|
||||
"summary": "returns policies for logged in user",
|
||||
"operationId": "GetUserPolicy",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/{name}/service-account-credentials": {
|
||||
"post": {
|
||||
"tags": [
|
||||
|
||||
@@ -1531,7 +1531,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/user"] = user.NewGetUserInfo(o.context, o.UserGetUserInfoHandler)
|
||||
o.handlers["GET"]["/user/{name}"] = user.NewGetUserInfo(o.context, o.UserGetUserInfoHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1539,7 +1539,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/group"] = group.NewGroupInfo(o.context, o.GroupGroupInfoHandler)
|
||||
o.handlers["GET"]["/group/{name}"] = group.NewGroupInfo(o.context, o.GroupGroupInfoHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1643,7 +1643,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/policy"] = policy.NewPolicyInfo(o.context, o.PolicyPolicyInfoHandler)
|
||||
o.handlers["GET"]["/policy/{name}"] = policy.NewPolicyInfo(o.context, o.PolicyPolicyInfoHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1683,15 +1683,15 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/group"] = group.NewRemoveGroup(o.context, o.GroupRemoveGroupHandler)
|
||||
o.handlers["DELETE"]["/group/{name}"] = group.NewRemoveGroup(o.context, o.GroupRemoveGroupHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/policy"] = policy.NewRemovePolicy(o.context, o.PolicyRemovePolicyHandler)
|
||||
o.handlers["DELETE"]["/policy/{name}"] = policy.NewRemovePolicy(o.context, o.PolicyRemovePolicyHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/user"] = user.NewRemoveUser(o.context, o.UserRemoveUserHandler)
|
||||
o.handlers["DELETE"]["/user/{name}"] = user.NewRemoveUser(o.context, o.UserRemoveUserHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1787,7 +1787,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/group"] = group.NewUpdateGroup(o.context, o.GroupUpdateGroupHandler)
|
||||
o.handlers["PUT"]["/group/{name}"] = group.NewUpdateGroup(o.context, o.GroupUpdateGroupHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1795,11 +1795,11 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/user/groups"] = user.NewUpdateUserGroups(o.context, o.UserUpdateUserGroupsHandler)
|
||||
o.handlers["PUT"]["/user/{name}/groups"] = user.NewUpdateUserGroups(o.context, o.UserUpdateUserGroupsHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/user"] = user.NewUpdateUserInfo(o.context, o.UserUpdateUserInfoHandler)
|
||||
o.handlers["PUT"]["/user/{name}"] = user.NewUpdateUserInfo(o.context, o.UserUpdateUserInfoHandler)
|
||||
}
|
||||
|
||||
// Serve creates a http handler to serve the API over HTTP
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewGroupInfo(ctx *middleware.Context, handler GroupInfoHandler) *GroupInfo
|
||||
return &GroupInfo{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* GroupInfo swagger:route GET /group Group groupInfo
|
||||
/* GroupInfo swagger:route GET /group/{name} Group groupInfo
|
||||
|
||||
Group info
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewGroupInfoParams creates a new GroupInfoParams object
|
||||
@@ -51,7 +49,7 @@ type GroupInfoParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *GroupInfoParams) BindRequest(r *http.Request, route *middleware.Matched
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *GroupInfoParams) BindRequest(r *http.Request, route *middleware.Matched
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *GroupInfoParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GroupInfoURL generates an URL for the group info operation
|
||||
@@ -56,7 +57,14 @@ func (o *GroupInfoURL) SetBasePath(bp string) {
|
||||
func (o *GroupInfoURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/group"
|
||||
var _path = "/group/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on GroupInfoURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *GroupInfoURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewRemoveGroup(ctx *middleware.Context, handler RemoveGroupHandler) *Remove
|
||||
return &RemoveGroup{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* RemoveGroup swagger:route DELETE /group Group removeGroup
|
||||
/* RemoveGroup swagger:route DELETE /group/{name} Group removeGroup
|
||||
|
||||
Remove group
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewRemoveGroupParams creates a new RemoveGroupParams object
|
||||
@@ -51,7 +49,7 @@ type RemoveGroupParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *RemoveGroupParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *RemoveGroupParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *RemoveGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RemoveGroupURL generates an URL for the remove group operation
|
||||
@@ -56,7 +57,14 @@ func (o *RemoveGroupURL) SetBasePath(bp string) {
|
||||
func (o *RemoveGroupURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/group"
|
||||
var _path = "/group/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on RemoveGroupURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *RemoveGroupURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewUpdateGroup(ctx *middleware.Context, handler UpdateGroupHandler) *Update
|
||||
return &UpdateGroup{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* UpdateGroup swagger:route PUT /group Group updateGroup
|
||||
/* UpdateGroup swagger:route PUT /group/{name} Group updateGroup
|
||||
|
||||
Update Group Members or Status
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ type UpdateGroupParams struct {
|
||||
Body *models.UpdateGroupRequest
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -74,8 +74,6 @@ func (o *UpdateGroupParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.UpdateGroupRequest
|
||||
@@ -104,8 +102,8 @@ func (o *UpdateGroupParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -114,22 +112,15 @@ func (o *UpdateGroupParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *UpdateGroupParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateGroupURL generates an URL for the update group operation
|
||||
@@ -56,7 +57,14 @@ func (o *UpdateGroupURL) SetBasePath(bp string) {
|
||||
func (o *UpdateGroupURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/group"
|
||||
var _path = "/group/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on UpdateGroupURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *UpdateGroupURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewPolicyInfo(ctx *middleware.Context, handler PolicyInfoHandler) *PolicyIn
|
||||
return &PolicyInfo{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* PolicyInfo swagger:route GET /policy Policy policyInfo
|
||||
/* PolicyInfo swagger:route GET /policy/{name} Policy policyInfo
|
||||
|
||||
Policy info
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewPolicyInfoParams creates a new PolicyInfoParams object
|
||||
@@ -51,7 +49,7 @@ type PolicyInfoParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *PolicyInfoParams) BindRequest(r *http.Request, route *middleware.Matche
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *PolicyInfoParams) BindRequest(r *http.Request, route *middleware.Matche
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *PolicyInfoParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PolicyInfoURL generates an URL for the policy info operation
|
||||
@@ -56,7 +57,14 @@ func (o *PolicyInfoURL) SetBasePath(bp string) {
|
||||
func (o *PolicyInfoURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/policy"
|
||||
var _path = "/policy/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on PolicyInfoURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *PolicyInfoURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewRemovePolicy(ctx *middleware.Context, handler RemovePolicyHandler) *Remo
|
||||
return &RemovePolicy{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* RemovePolicy swagger:route DELETE /policy Policy removePolicy
|
||||
/* RemovePolicy swagger:route DELETE /policy/{name} Policy removePolicy
|
||||
|
||||
Remove policy
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewRemovePolicyParams creates a new RemovePolicyParams object
|
||||
@@ -51,7 +49,7 @@ type RemovePolicyParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *RemovePolicyParams) BindRequest(r *http.Request, route *middleware.Matc
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *RemovePolicyParams) BindRequest(r *http.Request, route *middleware.Matc
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *RemovePolicyParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RemovePolicyURL generates an URL for the remove policy operation
|
||||
@@ -56,7 +57,14 @@ func (o *RemovePolicyURL) SetBasePath(bp string) {
|
||||
func (o *RemovePolicyURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/policy"
|
||||
var _path = "/policy/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on RemovePolicyURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *RemovePolicyURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewGetUserInfo(ctx *middleware.Context, handler GetUserInfoHandler) *GetUse
|
||||
return &GetUserInfo{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* GetUserInfo swagger:route GET /user User getUserInfo
|
||||
/* GetUserInfo swagger:route GET /user/{name} User getUserInfo
|
||||
|
||||
Get User Info
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewGetUserInfoParams creates a new GetUserInfoParams object
|
||||
@@ -51,7 +49,7 @@ type GetUserInfoParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *GetUserInfoParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *GetUserInfoParams) BindRequest(r *http.Request, route *middleware.Match
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *GetUserInfoParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetUserInfoURL generates an URL for the get user info operation
|
||||
@@ -56,7 +57,14 @@ func (o *GetUserInfoURL) SetBasePath(bp string) {
|
||||
func (o *GetUserInfoURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/user"
|
||||
var _path = "/user/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on GetUserInfoURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *GetUserInfoURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewRemoveUser(ctx *middleware.Context, handler RemoveUserHandler) *RemoveUs
|
||||
return &RemoveUser{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* RemoveUser swagger:route DELETE /user User removeUser
|
||||
/* RemoveUser swagger:route DELETE /user/{name} User removeUser
|
||||
|
||||
Remove user
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewRemoveUserParams creates a new RemoveUserParams object
|
||||
@@ -51,7 +49,7 @@ type RemoveUserParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -65,10 +63,8 @@ func (o *RemoveUserParams) BindRequest(r *http.Request, route *middleware.Matche
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -77,22 +73,15 @@ func (o *RemoveUserParams) BindRequest(r *http.Request, route *middleware.Matche
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *RemoveUserParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RemoveUserURL generates an URL for the remove user operation
|
||||
@@ -56,7 +57,14 @@ func (o *RemoveUserURL) SetBasePath(bp string) {
|
||||
func (o *RemoveUserURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/user"
|
||||
var _path = "/user/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on RemoveUserURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *RemoveUserURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewUpdateUserGroups(ctx *middleware.Context, handler UpdateUserGroupsHandle
|
||||
return &UpdateUserGroups{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* UpdateUserGroups swagger:route PUT /user/groups User updateUserGroups
|
||||
/* UpdateUserGroups swagger:route PUT /user/{name}/groups User updateUserGroups
|
||||
|
||||
Update Groups for a user
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ type UpdateUserGroupsParams struct {
|
||||
Body *models.UpdateUserGroups
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -74,8 +74,6 @@ func (o *UpdateUserGroupsParams) BindRequest(r *http.Request, route *middleware.
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.UpdateUserGroups
|
||||
@@ -104,8 +102,8 @@ func (o *UpdateUserGroupsParams) BindRequest(r *http.Request, route *middleware.
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -114,22 +112,15 @@ func (o *UpdateUserGroupsParams) BindRequest(r *http.Request, route *middleware.
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *UpdateUserGroupsParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateUserGroupsURL generates an URL for the update user groups operation
|
||||
@@ -56,7 +57,14 @@ func (o *UpdateUserGroupsURL) SetBasePath(bp string) {
|
||||
func (o *UpdateUserGroupsURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/user/groups"
|
||||
var _path = "/user/{name}/groups"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on UpdateUserGroupsURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *UpdateUserGroupsURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewUpdateUserInfo(ctx *middleware.Context, handler UpdateUserInfoHandler) *
|
||||
return &UpdateUserInfo{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* UpdateUserInfo swagger:route PUT /user User updateUserInfo
|
||||
/* UpdateUserInfo swagger:route PUT /user/{name} User updateUserInfo
|
||||
|
||||
Update User Info
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ type UpdateUserInfoParams struct {
|
||||
Body *models.UpdateUser
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
@@ -74,8 +74,6 @@ func (o *UpdateUserInfoParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.UpdateUser
|
||||
@@ -104,8 +102,8 @@ func (o *UpdateUserInfoParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
qName, qhkName, _ := qs.GetOK("name")
|
||||
if err := o.bindName(qName, qhkName, route.Formats); err != nil {
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
@@ -114,22 +112,15 @@ func (o *UpdateUserInfoParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from query.
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *UpdateUserInfoParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("name", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("name", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateUserInfoURL generates an URL for the update user info operation
|
||||
@@ -56,7 +57,14 @@ func (o *UpdateUserInfoURL) SetBasePath(bp string) {
|
||||
func (o *UpdateUserInfoURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/user"
|
||||
var _path = "/user/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on UpdateUserInfoURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -64,15 +72,6 @@ func (o *UpdateUserInfoURL) Build() (*url.URL, error) {
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
nameQ := o.Name
|
||||
if nameQ != "" {
|
||||
qs.Set("name", nameQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/console/pkg/utils"
|
||||
|
||||
userApi "github.com/minio/console/restapi/operations/user"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
@@ -233,8 +235,11 @@ func getCreateAUserServiceAccountResponse(session *models.Principal, params user
|
||||
// create a MinIO user Admin Client interface implementation
|
||||
// defining the client to be used
|
||||
userAdminClient := AdminClient{Client: userAdmin}
|
||||
|
||||
saCreds, err := createAUserServiceAccount(ctx, userAdminClient, params.Body.Policy, params.Name)
|
||||
name, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
saCreds, err := createAUserServiceAccount(ctx, userAdminClient, params.Body.Policy, name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
@@ -254,7 +259,10 @@ func getCreateAUserServiceAccountCredsResponse(session *models.Principal, params
|
||||
// defining the client to be used
|
||||
userAdminClient := AdminClient{Client: userAdmin}
|
||||
serviceAccount := params.Body
|
||||
user := params.Name
|
||||
user, err := utils.DecodeBase64(params.Name)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
if user == serviceAccount.AccessKey {
|
||||
return nil, ErrorWithContext(ctx, errors.New("Access Key already in use"))
|
||||
}
|
||||
@@ -331,7 +339,10 @@ func getUserServiceAccountsResponse(ctx context.Context, session *models.Princip
|
||||
// create a MinIO user Admin Client interface implementation
|
||||
// defining the client to be used
|
||||
userAdminClient := AdminClient{Client: userAdmin}
|
||||
|
||||
user, err = utils.DecodeBase64(user)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
serviceAccounts, err := getUserServiceAccounts(ctx, userAdminClient, user)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
@@ -348,7 +359,10 @@ func deleteServiceAccount(ctx context.Context, userClient MinioAdmin, accessKey
|
||||
func getDeleteServiceAccountResponse(session *models.Principal, params saApi.DeleteServiceAccountParams) *models.Error {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
accessKey := params.AccessKey
|
||||
accessKey, err := utils.DecodeBase64(params.AccessKey)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
userAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
@@ -381,7 +395,10 @@ func getServiceAccountPolicy(ctx context.Context, userClient MinioAdmin, accessK
|
||||
func getServiceAccountPolicyResponse(session *models.Principal, params saApi.GetServiceAccountPolicyParams) (string, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
accessKey := params.AccessKey
|
||||
accessKey, err := utils.DecodeBase64(params.AccessKey)
|
||||
if err != nil {
|
||||
return "", ErrorWithContext(ctx, err)
|
||||
}
|
||||
userAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return "", ErrorWithContext(ctx, err)
|
||||
@@ -408,7 +425,10 @@ func setServiceAccountPolicy(ctx context.Context, userClient MinioAdmin, accessK
|
||||
func getSetServiceAccountPolicyResponse(session *models.Principal, params saApi.SetServiceAccountPolicyParams) *models.Error {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
accessKey := params.AccessKey
|
||||
accessKey, err := utils.DecodeBase64(params.AccessKey)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
policy := *params.Policy.Policy
|
||||
userAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user