mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-11 04:32:29 +02:00
18 lines
397 B
Go
18 lines
397 B
Go
package security
|
|
|
|
// VerifySourceURL checks if the given imageURL is allowed based on
|
|
// the configured AllowedSources.
|
|
func (s *Security) VerifySourceURL(imageURL string) error {
|
|
if len(s.config.AllowedSources) == 0 {
|
|
return nil
|
|
}
|
|
|
|
for _, allowedSource := range s.config.AllowedSources {
|
|
if allowedSource.MatchString(imageURL) {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
return newSourceURLError(imageURL)
|
|
}
|