Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:09:09+00:00 2026-06-13T13:09:09+00:00

I want to protect all forms from CSRF with Dancer . I tried using

  • 0

I want to protect all forms from CSRF with Dancer.

I tried using Plack::Middleware::CSRFBlock, but the error said “CSRFBlock needs Session.”. Even if I use Plack::Session, forms didn’t have a hidden input field that contains one time token.

Are there any good practice to do this? Any advice much appreciated.

my environment/development.yml is:

# 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

and the route is:

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
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:09:10+00:00Added an answer on June 13, 2026 at 1:09 pm

    Well, I noticed the Debug panel isn’t shown, meaning Plack::Middlewares::Debug isn’t loaded.
    With help from How to use Dancer with Plack middlewares | PerlDancer Advent Calendar and Plack::Middleware::Debug::Dancer::Version I managed to turn it on

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having login forms in all static pages. I have enabled csrf middleware
I want to get a list of all the forms in the project i
I want to protect a directory and the php files in it, from direct
I have a server application which I want to protect from being stopped by
i search online but can't get satisfactory result i want to protect images on
For some reason one of our forms reads all UI element data from its
I want to add a custom base class for all of my web forms.
I want to password protect my page which I am doing using LDAP bind
my Project model has 2 datetime atttributes: start_date and end_date. Now I want all
I am trying to find all ruby files in the project. However I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.