Фильтры все еще фильтруют POST после отключения его в игре - PullRequest
0 голосов
/ 28 мая 2018

Возникли проблемы с воспроизведением и фильтрами Http, я использовал несколько методов, чтобы отключить его, но он продолжает утверждать, что фильтры включены.есть ли другие способы набрать номер, которые я не пробовал ....

это мой файл application.conf

    play.filters {

  # Enabled filters are run automatically against Play.
  # CSRFFilter, AllowedHostFilters, and SecurityHeadersFilters are enabled by default.
  #enabled += filters.ExampleFilter

  # Disabled filters remove elements from the enabled list.
  disabled += filters.ExampleFilter

  ## CORS filter configuration
  # https://www.playframework.com/documentation/latest/CorsFilter
  # ~~~~~
  # CORS is a protocol that allows web applications to make requests from the browser
  # across different domains.
  # NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has
  # dependencies on CORS settings.
  cors {
    # Filter paths by a whitelist of path prefixes
    #pathPrefixes = ["/some/path", ...]

    # The allowed origins. If null, all origins are allowed.
    allowedOrigins = null
    #  ["http://www.example.com"]

    # The allowed HTTP methods. If null, all methods are allowed
    #allowedHttpMethods = ["GET", "POST"]
    play.filters.disabled += "play.filters.cors.CORSFilter"
  }

  ## CSRF Filter
  # https://www.playframework.com/documentation/latest/ScalaCsrf#Applying-a-global-CSRF-filter
  # https://www.playframework.com/documentation/latest/JavaCsrf#Applying-a-global-CSRF-filter
  # ~~~~~
  # Play supports multiple methods for verifying that a request is not a CSRF request.
  # The primary mechanism is a CSRF token. This token gets placed either in the query string
  # or body of every form submitted, and also gets placed in the users session.
  # Play then verifies that both tokens are present and match.
  csrf {
    # Sets the cookie to be sent only over HTTPS
    #cookie.secure = true

    # Defaults to CSRFErrorHandler in the root package.
    #errorHandler = MyCSRFErrorHandler
    play.filters.disabled += "play.filters.csrf.CSRFFilter"
  }


  play.filters.disabled += "play.filters.hosts.AllowedHostsFilter"




  play.filters.enabled=[]



  ## Security headers filter configuration
  # https://www.playframework.com/documentation/latest/SecurityHeaders
  # ~~~~~
  # Defines security headers that prevent XSS attacks.
  # If enabled, then all options are set to the below configuration by default:
  headers {
    # The X-Frame-Options header. If null, the header is not set.
    #frameOptions = "DENY"

    # The X-XSS-Protection header. If null, the header is not set.
    #xssProtection = "1; mode=block"

    # The X-Content-Type-Options header. If null, the header is not set.
    #contentTypeOptions = "nosniff"

    # The X-Permitted-Cross-Domain-Policies header. If null, the header is not set.
    #permittedCrossDomainPolicies = "master-only"

    # The Content-Security-Policy header. If null, the header is not set.
    #contentSecurityPolicy = "default-src 'self'"
  }

я даже отключил его в начале маршрутов: этоэто файл маршрута:

GET     /                           controllers.ShopController.index

+ nocsrf
GET    /products                           controllers.ShopController.listOfProducts()
+ nocsrf
GET    /products/new                       controllers.ShopController.createNewProduct()

+ nocsrf
POST   /products/new                       controllers.ShopController.saveProduct()
# An example controller showing how to use dependency injection
GET     /count                      controllers.CountController.count
# An example controller showing how to write asynchronous code
GET     /message                    controllers.AsyncController.message

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)

это трассировка стека ::

info] application - ApplicationTimer demo: Stopping application at 2018-05-28T00:46:22.634Z after 245s.
[info] application - Shutting down connection pool.
[info] application - Creating Pool for datasource 'default'
[info] p.a.d.DefaultDBApi - Database [default] connected at jdbc:h2:mem:play
[info] application - ApplicationTimer demo: Starting application at 2018-05-28T00:46:23.076Z
[warn] o.h.v.m.ParameterMessageInterpolator - HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported
[info] p.a.h.EnabledFilters - Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):

    play.filters.csrf.CSRFFilter
    play.filters.headers.SecurityHeadersFilter
    play.filters.hosts.AllowedHostsFilter

[info] play.api.Play - Application started (Dev)

Я не могу понять, почему он не отключает, перекомпилирует и даже перезапускает sbt .... любая помощь приветствуется..thanks.

1 Ответ

0 голосов
/ 28 мая 2018

Кажется, вы использовали шаблон play seed для разработки своего приложения Play.Вы можете удалить все из application.conf и затем использовать его;как это касается различных аспектов игры.Вы могли бы даже иметь в своем фильтре application.conf следующее:

play.filters.disabled += "play.filters.csrf.CSRFFilter" 
play.filters.disabled += "play.filters.headers.SecurityHeadersFilter"
play.filters.disabled += "play.filters.hosts.AllowedHostsFilter"
play.filters.disabled += "filters.ExampleFilter" 

Кроме того, чтобы иметь более понятный код, избавьтесь от всех Filter связанных классов, поскольку вы не хотите / не используетеих.Затем выполните команду clean / compile / run, чтобы увидеть результаты:

sbt clean compile run
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...