33 lines
959 B
Go
33 lines
959 B
Go
package foundry
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
func createAuthRequest(host, sessionID, password string) (*http.Request, error) {
|
|
authData := url.Values{}
|
|
authData.Add("adminPassword", password)
|
|
authData.Add("action", "adminAuth")
|
|
|
|
req, err := http.NewRequest("POST", fmt.Sprintf("http://%s%s", host, authPath), bytes.NewBuffer([]byte(authData.Encode())))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
header := http.Header{}
|
|
header.Set("Cookie", fmt.Sprintf("session=%s", sessionID))
|
|
header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
|
header.Set("Connection", "keep-alive")
|
|
header.Set("Content-Length", fmt.Sprintf("%d", len(authData.Encode())))
|
|
header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
header.Set("Host", host)
|
|
header.Set("Origin", fmt.Sprintf("http://%s", host))
|
|
header.Set("Referer", fmt.Sprintf("http://%s%s", host, authPath))
|
|
|
|
req.Header = header
|
|
return req, nil
|
|
}
|