34 lines
848 B
Go
34 lines
848 B
Go
package handlers
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func IsAllowedRedirectURI(uri string) bool {
|
|
allowedRedirectURIsEnv := os.Getenv("ALLOWED_REDIRECT_URIS")
|
|
log.Print("Checking redirect URI: ", uri)
|
|
log.Print("Allowed Redirect URIs (raw): ", allowedRedirectURIsEnv)
|
|
|
|
if allowedRedirectURIsEnv == "" {
|
|
log.Print("ERROR: ALLOWED_REDIRECT_URIS environment variable is empty")
|
|
return false
|
|
}
|
|
|
|
allowedRedirectURIs := strings.Split(allowedRedirectURIsEnv, ",")
|
|
log.Print("Parsed allowed URIs count: ", len(allowedRedirectURIs))
|
|
|
|
for i, allowed := range allowedRedirectURIs {
|
|
trimmed := strings.TrimSpace(allowed)
|
|
log.Printf(" [%d] Comparing '%s' with '%s'", i, uri, trimmed)
|
|
if uri == trimmed {
|
|
log.Print("✓ Redirect URI allowed: ", uri)
|
|
return true
|
|
}
|
|
}
|
|
|
|
log.Print("✗ Redirect URI not allowed: ", uri)
|
|
return false
|
|
}
|