options.go 807 B

1234567891011121314151617181920212223242526272829303132
  1. package security
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/config"
  4. "github.com/imgproxy/imgproxy/v3/ierrors"
  5. )
  6. var ErrSecurityOptionsNotAllowed = ierrors.New(403, "Security processing options are not allowed", "Invalid URL")
  7. type Options struct {
  8. MaxSrcResolution int
  9. MaxSrcFileSize int
  10. MaxAnimationFrames int
  11. MaxAnimationFrameResolution int
  12. }
  13. func DefaultOptions() Options {
  14. return Options{
  15. MaxSrcResolution: config.MaxSrcResolution,
  16. MaxSrcFileSize: config.MaxSrcFileSize,
  17. MaxAnimationFrames: config.MaxAnimationFrames,
  18. MaxAnimationFrameResolution: config.MaxAnimationFrameResolution,
  19. }
  20. }
  21. func IsSecurityOptionsAllowed() error {
  22. if config.AllowSecurityOptions {
  23. return nil
  24. }
  25. return ErrSecurityOptionsNotAllowed
  26. }