2020-02-01 12:54:50 +00:00
|
|
|
package utils
|
2019-04-24 21:52:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// IsRedirectionSafe determines if a redirection URL is secured.
|
2020-02-01 12:54:50 +00:00
|
|
|
func IsRedirectionSafe(url url.URL, protectedDomain string) bool {
|
2019-04-24 21:52:08 +00:00
|
|
|
if url.Scheme != "https" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasSuffix(url.Hostname(), protectedDomain) {
|
|
|
|
return false
|
|
|
|
}
|
2020-05-05 19:35:32 +00:00
|
|
|
|
2019-04-24 21:52:08 +00:00
|
|
|
return true
|
|
|
|
}
|