PlugImageProcessing.Middlewares.AllowedOrigins (plug_image_processing v0.9.1)
View SourceMiddleware for validating that image URLs come from allowed origins.
This middleware provides security by restricting which domains can be used as image sources. It validates the host of the provided URL against a configured allowlist of origins.
Configuration
Set allowed_origins in your config to enable this middleware:
plug PlugImageProcessing.Web, allowed_origins: ["example.com", "cdn.example.com"]Security
- Uses exact host matching to prevent subdomain bypass attacks
- Safely handles malformed URLs without crashing
- Returns 403 Forbidden for unauthorized origins