diff --git a/handlers/redirect.go b/handlers/redirect.go index 60fe2c8..7d77167 100644 --- a/handlers/redirect.go +++ b/handlers/redirect.go @@ -8,16 +8,26 @@ import ( 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, ",") - for _, allowed := range allowedRedirectURIs { - if uri == strings.TrimSpace(allowed) { + 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) + + log.Print("✗ Redirect URI not allowed: ", uri) return false }