You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2024/05/07 15:06:04 UTC
(cloudstack-go) 01/01: Use POST for user sensitive calls
This is an automated email from the ASF dual-hosted git repository.
mlsorensen pushed a commit to branch post
in repository https://gitbox.apache.org/repos/asf/cloudstack-go.git
commit 0b2d6ba879cad605e86ba71f73e1a992bba9f4ee
Author: Marcus Sorensen <ml...@apple.com>
AuthorDate: Tue May 7 09:05:44 2024 -0600
Use POST for user sensitive calls
---
cloudstack/UserService.go | 4 ++--
cloudstack/VPNService.go | 2 +-
generate/generate.go | 16 +++++++++++++++-
generate/listApis.json | 6 +++---
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/cloudstack/UserService.go b/cloudstack/UserService.go
index d622f39..8aad5de 100644
--- a/cloudstack/UserService.go
+++ b/cloudstack/UserService.go
@@ -243,7 +243,7 @@ func (s *UserService) NewCreateUserParams(account string, email string, firstnam
// Creates a user for an account that already exists
func (s *UserService) CreateUser(p *CreateUserParams) (*CreateUserResponse, error) {
- resp, err := s.cs.newRequest("createUser", p.toURLValues())
+ resp, err := s.cs.newPostRequest("createUser", p.toURLValues())
if err != nil {
return nil, err
}
@@ -1478,7 +1478,7 @@ func (s *UserService) NewUpdateUserParams(id string) *UpdateUserParams {
// Updates a user account
func (s *UserService) UpdateUser(p *UpdateUserParams) (*UpdateUserResponse, error) {
- resp, err := s.cs.newRequest("updateUser", p.toURLValues())
+ resp, err := s.cs.newPostRequest("updateUser", p.toURLValues())
if err != nil {
return nil, err
}
diff --git a/cloudstack/VPNService.go b/cloudstack/VPNService.go
index 741b935..4cc1050 100644
--- a/cloudstack/VPNService.go
+++ b/cloudstack/VPNService.go
@@ -191,7 +191,7 @@ func (s *VPNService) NewAddVpnUserParams(password string, username string) *AddV
// Adds vpn users
func (s *VPNService) AddVpnUser(p *AddVpnUserParams) (*AddVpnUserResponse, error) {
- resp, err := s.cs.newRequest("addVpnUser", p.toURLValues())
+ resp, err := s.cs.newPostRequest("addVpnUser", p.toURLValues())
if err != nil {
return nil, err
}
diff --git a/generate/generate.go b/generate/generate.go
index a671908..2dbb9c6 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -58,6 +58,20 @@ var detailsRequireZeroIndex = map[string]bool{
"updateAccount": true,
}
+// requiresPost is a prefilled set of API names that require POST
+// for security or size purposes
+var requiresPostMethod = map[string]bool{
+ "login": true,
+ "deployVirtualMachine": true,
+ "updateVirtualMachine": true,
+ "createUser": true,
+ "updateUser": true,
+ "addVpnUser": true,
+ "registerUserData": true,
+ "setupUserTwoFactorAuthentication": true,
+ "validateUserTwoFactorAuthenticationCode": true,
+}
+
var mapRequireList = map[string]map[string]bool{
"deployVirtualMachine": map[string]bool{
"dhcpoptionsnetworklist": true,
@@ -1698,7 +1712,7 @@ func (s *service) generateNewAPICallFunc(a *API) {
pn(" time.Sleep(500 * time.Millisecond)")
pn(" }")
} else {
- if a.Name == "deployVirtualMachine" || a.Name == "login" || a.Name == "updateVirtualMachine" {
+ if requiresPostMethod[a.Name] {
pn(" resp, err := s.cs.newPostRequest(\"%s\", p.toURLValues())", a.Name)
} else {
pn(" resp, err := s.cs.newRequest(\"%s\", p.toURLValues())", a.Name)
diff --git a/generate/listApis.json b/generate/listApis.json
index df050bd..bbc5c76 100644
--- a/generate/listApis.json
+++ b/generate/listApis.json
@@ -44786,7 +44786,7 @@
]
},
{
- "description": "Lists OpenDyalight controllers",
+ "description": "Lists OpenDaylight controllers",
"isasync": false,
"name": "listOpenDaylightControllers",
"params": [
@@ -55892,7 +55892,7 @@
"since": "4.15.0"
},
{
- "description": "Removes an OpenDyalight controler",
+ "description": "Removes an OpenDaylight controller",
"isasync": true,
"name": "deleteOpenDaylightController",
"params": [
@@ -117752,7 +117752,7 @@
]
},
{
- "description": "Adds an OpenDyalight controler",
+ "description": "Adds an OpenDaylight controller",
"isasync": true,
"name": "addOpenDaylightController",
"params": [