returns true if this request is coming from a loopback address
(req *http.Request)
| 115 | |
| 116 | // returns true if this request is coming from a loopback address |
| 117 | func (a *API) localhostAuthn(req *http.Request) bool { |
| 118 | h, _, err := net.SplitHostPort(req.RemoteAddr) |
| 119 | if err != nil { |
| 120 | return false |
| 121 | } |
| 122 | if !net.ParseIP(h).IsLoopback() { |
| 123 | return false |
| 124 | } |
| 125 | return true |
| 126 | } |
| 127 | |
| 128 | func (a *API) tokenAuthn(req *http.Request) (string, error) { |
| 129 | user, pw, ok := req.BasicAuth() |