Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions 15 cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
params.Add(key, value)
}
}
signatureversion := "3"
expiresKey := "expires"
params.Add("response", "json")
params.Add("signatureversion", signatureversion)
params.Add(expiresKey, time.Now().UTC().Add(15 * time.Minute).Format(time.RFC3339))
sureshanaparti marked this conversation as resolved.
Show resolved Hide resolved

var encodedParams string
var err error
Expand All @@ -220,8 +224,13 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
mac := hmac.New(sha1.New, []byte(secretKey))
mac.Write([]byte(strings.ToLower(encodedParams)))
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
params = nil
if r.Config.Core.PostRequest {
params.Add("signature", signature)
} else {
encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
params = nil
}

} else if len(r.Config.ActiveProfile.Username) > 0 && len(r.Config.ActiveProfile.Password) > 0 {
sessionKey, err := Login(r)
if err != nil {
Expand Down Expand Up @@ -287,7 +296,7 @@ func NewAPIRequest(r *Request, api string, args []string, isAsync bool) (map[str
// we can implement further conditions to do POST or GET (or other http commands) here
func executeRequest(r *Request, requestURL string, params url.Values) (*http.Response, error) {
config.SetupContext(r.Config)
if params.Has("password") || params.Has("userdata") {
if params.Has("password") || params.Has("userdata") || r.Config.Core.PostRequest {
requestURL = fmt.Sprintf("%s", r.Config.ActiveProfile.URL)
return r.Client().PostForm(requestURL, params)
} else {
Expand Down
5 changes: 5 additions & 0 deletions 5 config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Core struct {
VerifyCert bool `ini:"verifycert"`
ProfileName string `ini:"profile"`
AutoComplete bool `ini:"autocomplete"`
PostRequest bool `ini:postrequest`
}

// Config describes CLI config file and default options
Expand Down Expand Up @@ -151,6 +152,7 @@ func defaultCoreConfig() Core {
VerifyCert: true,
ProfileName: "localcloud",
AutoComplete: true,
PostRequest: true,
}
}

Expand Down Expand Up @@ -282,6 +284,9 @@ func saveConfig(cfg *Config) *Config {
core.AutoComplete = true
core.Output = JSON
}
if !conf.Section(ini.DEFAULT_SECTION).HasKey("postrequest") {
core.PostRequest = true
sureshanaparti marked this conversation as resolved.
Show resolved Hide resolved
}
sureshanaparti marked this conversation as resolved.
Show resolved Hide resolved
cfg.Core = core
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.