(req *http.Request)
| 59 | } |
| 60 | |
| 61 | func getApiKey(req *http.Request) (string, error) { |
| 62 | list := []string{ |
| 63 | req.Header.Get("x-api-key"), |
| 64 | req.Header.Get("api-key"), |
| 65 | } |
| 66 | |
| 67 | split := strings.Split(req.Header.Get("Authorization"), " ") |
| 68 | |
| 69 | if len(split) >= 2 { |
| 70 | list = append(list, split[1]) |
| 71 | } |
| 72 | |
| 73 | for _, key := range list { |
| 74 | if len(key) != 0 { |
| 75 | return key, nil |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return "", internal_errors.NewAuthError("api key not found in header") |
| 80 | } |
| 81 | |
| 82 | func rewriteHttpAuthHeader(req *http.Request, setting *provider.Setting) error { |
| 83 | uri := req.URL.RequestURI() |
no test coverage detected