9 "github.com/bitly/oauth2_proxy/api"
12// stripToken is a helper function to obfuscate "access_token"
14func stripToken(endpoint string) string {
15 return stripParam("access_token", endpoint)
18// stripParam generalizes the obfuscation of a particular
19// query parameter - typically 'access_token' or 'client_secret'
20// The parameter's second half is replaced by '...' and returned
21// as part of the encoded query parameters.
22// If the target parameter isn't found, the endpoint is returned
24func stripParam(param, endpoint string) string {
25 u, err := url.Parse(endpoint)
27 log.Printf("error attempting to strip %s: %s", param, err)
32 values, err := url.ParseQuery(u.RawQuery)
34 log.Printf("error attempting to strip %s: %s", param, err)
38 if val := values.Get(param); val != "" {
39 values.Set(param, val[:(len(val)/2)]+"...")
40 u.RawQuery = values.Encode()
48// validateToken returns true if token is valid
49func validateToken(p Provider, access_token string, header http.Header) bool {
50 if access_token == "" || p.Data().ValidateURL == nil {
53 endpoint := p.Data().ValidateURL.String()
55 params := url.Values{"access_token": {access_token}}
56 endpoint = endpoint + "?" + params.Encode()
58 resp, err := api.RequestUnparsedResponse(endpoint, header)
60 log.Printf("GET %s", endpoint)
61 log.Printf("token validation request failed: %s", err)
65 body, _ := ioutil.ReadAll(resp.Body)
67 log.Printf("%d GET %s %s", resp.StatusCode, stripToken(endpoint), body)
69 if resp.StatusCode == 200 {
72 log.Printf("token validation request failed: status %d - %s", resp.StatusCode, body)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list