BuildRequestURL creates a request suitable for a resource transfer. it will return a constructed url based off the base url and query key/value provided. cli will build a url for cli transfer request.
(baseURL *url.URL, appAUD string, key, value string, cli, useHostOnly bool, autoClose bool)
| 91 | // it will return a constructed url based off the base url and query key/value provided. |
| 92 | // cli will build a url for cli transfer request. |
| 93 | func buildRequestURL(baseURL *url.URL, appAUD string, key, value string, cli, useHostOnly bool, autoClose bool) (string, error) { |
| 94 | q := baseURL.Query() |
| 95 | q.Set(key, value) |
| 96 | q.Set("aud", appAUD) |
| 97 | baseURL.RawQuery = q.Encode() |
| 98 | if useHostOnly { |
| 99 | baseURL.Path = "" |
| 100 | } |
| 101 | // TODO: pass arg for tunnel login |
| 102 | if !cli { |
| 103 | return baseURL.String(), nil |
| 104 | } |
| 105 | q.Set("redirect_url", baseURL.String()) // we add the token as a query param on both the redirect_url and the main url |
| 106 | q.Set("send_org_token", "true") // indicates that the cli endpoint should return both the org and app token |
| 107 | q.Set("edge_token_transfer", "true") // use new LoginHelper service built on workers |
| 108 | if autoClose { |
| 109 | q.Set("close_interstitial", "true") // Automatically close the success window. |
| 110 | } |
| 111 | |
| 112 | baseURL.RawQuery = q.Encode() // and this actual baseURL. |
| 113 | baseURL.Path = "cdn-cgi/access/cli" |
| 114 | return baseURL.String(), nil |
| 115 | } |
| 116 | |
| 117 | // transferRequest downloads the requested resource from the request URL |
| 118 | func transferRequest(requestURL string, log *zerolog.Logger) ([]byte, string, error) { |
no test coverage detected