2012-10-28 4 views
2

모든 양식을 CSRF에서 Dancer으로 보호하고 싶습니다.Plack :: Middleware :: CSRFBlock with Dancer를 사용하는 방법?

Plack::Middleware::CSRFBlock을 사용해 보았지만 "CSRFBlock Session이 필요합니다." Plack::Session을 사용하는 경우에도 양식에 한 번의 시간 토큰이 포함 된 숨겨진 입력 필드가 없습니다.

이렇게하는 것이 좋습니다. 어떤 조언을 많이 주셨습니다.

environment/development.yml은 다음과 같습니다

# configuration file for development environment 

# the logger engine to use 
# console: log messages to STDOUT (your console where you started the 
#   application server) 
# file: log message to a file in log/ 
logger: "console" 

# the log level for this environment 
# core is the lowest, it shows Dancer's core log messages as well as yours 
# (debug, info, warning and error) 
log: "core" 

# should Dancer consider warnings as critical errors? 
warnings: 1 

# should Dancer show a stacktrace when an error is caught? 
show_errors: 1 

# auto_reload is a development and experimental feature 
# you should enable it by yourself if you want it 
# Module::Refresh is needed 
# 
# Be aware it's unstable and may cause a memory leak. 
# DO NOT EVER USE THIS FEATURE IN PRODUCTION 
# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING 
auto_reload: 0 

session: Simple 
#session: YAML 

plack_middlewares: 
    - 
     #- Session 
     - CSRFBlock 
     - Debug 
     - panels 
     - 
      - Parameters 
      - Dancer::Version 
      - Dancer::Settings 
      - Memory 

및 경로는 다음과 같습니다

get '/test' => sub { 
    return <<EOM 
     <!DOCTYPE html> 
     <html> 
     <head><title>test route</title></head> 
     <body> 
      <form action="./foobar" method="post"> 
      <input type="text"/> 
      <input type="submit"/> 
      </form> 
     </body> 
     </html> 
EOM 
}; 

답변

4

글쎄, 난 디버그 패널 Plack을 의미하는 표시되지 않습니다주의 : 미들웨어 :: 디버그하지 않습니다 짐을 실은. How to use Dancer with Plack middlewares | PerlDancer Advent CalendarPlack::Middleware::Debug::Dancer::Version의 도움으로 나는

session: PSGI 
## Dancer::Session::PSGI 

plack_middlewares: 
    - 
     - Session 
    - 
     - CSRFBlock 
    - 
     - Debug 
## panels is an argument for Debug, as in 
## enable 'Debug', panels => [ qw(Parameters Response Environment Session Timer Dancer::Logger Dancer::Settings Dancer::Version) ]; 
     - panels 
     - 
      - Parameters 
      - Response 
      - Environment 
      - Session 
      - Timer 
      - Dancer::Logger 
      - Dancer::Settings 
      - Dancer::Version 
#Plack::Middleware::Debug::Dancer::Version 
+0

그것이 매력처럼 작동에 그것을 설정하는 관리! 고마워요. 제 시간을 많이 구 했어요! 그리고 Dancer와 PSGI 간의 세션 제어에 대한 대답을 마침내 발견했습니다. 댄서 :: 세션 :: PSGI – ernix

관련 문제