Security instance

This commit is contained in:
Viktor Sokolov
2025-09-12 09:43:59 +02:00
parent 91187082f5
commit 0b972b74f4
11 changed files with 238 additions and 53 deletions

View File

@@ -1,15 +1,13 @@
package security
import (
"github.com/imgproxy/imgproxy/v3/config"
)
func VerifySourceURL(imageURL string) error {
if len(config.AllowedSources) == 0 {
// 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 config.AllowedSources {
for _, allowedSource := range s.config.AllowedSources {
if allowedSource.MatchString(imageURL) {
return nil
}