Skip to content
Snippets Groups Projects
Commit 547bc672 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

Parse params from body in grdf_token grdf

parent 4bf1feed
Branches
No related tags found
No related merge requests found
Pipeline #7982 failed
...@@ -412,36 +412,44 @@ func main() { ...@@ -412,36 +412,44 @@ func main() {
} }
pageContent := string(contents) pageContent := string(contents)
//Check for client_id //Check for client_id
clientIdStartIndex := strings.Index(pageContent, "client_id=") clientIdKey := "client_id="
clientIdLength := 22
clientIdStartIndex := strings.Index(pageContent, clientIdKey)
if clientIdStartIndex == -1 { if clientIdStartIndex == -1 {
log.Error("No client_id found") log.Error("No client_id found")
http.Error(w, http.StatusText(500), 500) http.Error(w, http.StatusText(500), 500)
} }
clientIdStartIndex += 10 clientIdStartIndex += len(clientIdKey)
clientId = pageContent[clientIdStartIndex : clientIdStartIndex+36] clientId = pageContent[clientIdStartIndex : clientIdStartIndex+clientIdLength]
//Check for client_secret //Check for client_secret
clientSecretStartIndex := strings.Index(pageContent, "client_secret=") clientSecretKey := "client_secret="
clientSecretLength := 14
clientSecretStartIndex := strings.Index(pageContent, clientSecretKey)
if clientSecretStartIndex == -1 { if clientSecretStartIndex == -1 {
log.Error("No client_secret found") log.Error("No client_secret found")
http.Error(w, http.StatusText(500), 500) http.Error(w, http.StatusText(500), 500)
} }
clientSecretStartIndex += 14 clientSecretStartIndex += len(clientSecretKey)
clientSecret = pageContent[clientSecretStartIndex : clientSecretStartIndex+36] clientSecret = pageContent[clientSecretStartIndex : clientSecretStartIndex+clientSecretStartIndex]
//Check for code //Check for code
codeStartIndex := strings.Index(pageContent, "code=") codeKey := "code="
codeLength := 27
codeStartIndex := strings.Index(pageContent, codeKey)
if codeStartIndex == -1 { if codeStartIndex == -1 {
log.Info("No code found (optional param)") log.Info("No code found (optional param)")
} else { } else {
codeStartIndex += 5 codeStartIndex += len(codeKey)
code = pageContent[codeStartIndex : codeStartIndex+30] code = pageContent[codeStartIndex : codeStartIndex+codeLength]
} }
//Check for grant_type //Check for grant_type
grandTypeStartIndex := strings.Index(pageContent, "grant_type=") grandTypeKey := "grant_type="
grandTypeLength := 27
grandTypeStartIndex := strings.Index(pageContent, grandTypeKey)
if grandTypeStartIndex == -1 { if grandTypeStartIndex == -1 {
log.Error("No grant_type found") log.Error("No grant_type found")
http.Error(w, http.StatusText(500), 500) http.Error(w, http.StatusText(500), 500)
} }
grandTypeStartIndex += 11 grandTypeStartIndex += len(grandTypeKey)
tempGrandTypeString := pageContent[grandTypeStartIndex:] tempGrandTypeString := pageContent[grandTypeStartIndex:]
grandTypeEndIndex := strings.Index(tempGrandTypeString, "&") grandTypeEndIndex := strings.Index(tempGrandTypeString, "&")
if grandTypeEndIndex == -1 { if grandTypeEndIndex == -1 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment