SameDomainRedirectPolicy allows redirect only if the redirected domain is the same as original domain, e.g. redirect to "www.imroc.cc" from "imroc.cc" is allowed, but redirect to "google.com" is not allowed.
()
| 37 | // is the same as original domain, e.g. redirect to "www.imroc.cc" from |
| 38 | // "imroc.cc" is allowed, but redirect to "google.com" is not allowed. |
| 39 | func SameDomainRedirectPolicy() RedirectPolicy { |
| 40 | return func(req *http.Request, via []*http.Request) error { |
| 41 | if getDomain(req.URL.Host) != getDomain(via[0].URL.Host) { |
| 42 | return errors.New("different domain name is not allowed") |
| 43 | } |
| 44 | return nil |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // SameHostRedirectPolicy allows redirect only if the redirected host |
| 49 | // is the same as original host, e.g. redirect to "www.imroc.cc" from |
searching dependent graphs…