Module: Rack::SimpleCsrf::Helpers
Instance Method Summary collapse
- #csrf_form_tag(opts = {}, session = self.session) ⇒ Object
- #csrf_meta_tag(opts = {}, session = self.session) ⇒ Object
Instance Method Details
#csrf_form_tag(opts = {}, session = self.session) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rack/simple_csrf.rb', line 103 def csrf_form_tag(opts = {}, session = self.session) session_key = session[opts[:key] || "csrf"] tag = opts[:tag] || "div" <<-HTML.strip_heredoc(opts[:offset]) <#{tag} class="hidden"> <input type="hidden" name="#{ \ opts[:field] || "auth"}" value="#{session_key}"> </#{tag}> HTML end |
#csrf_meta_tag(opts = {}, session = self.session) ⇒ Object
98 99 100 101 |
# File 'lib/rack/simple_csrf.rb', line 98 def (opts = {}, session = self.session) %Q{<meta name="#{opts[:field] || "auth"}" content="#{ \ session[opts[:key] || "csrf"]}">} end |