module CSRF
Public Instance Methods
form_authenticity_token()
click to toggle source
# File lib/laris/controller/csrf.rb, line 2 def form_authenticity_token @token ||= SecureRandom.urlsafe_base64 end
verify_authenticity()
click to toggle source
# File lib/laris/controller/csrf.rb, line 6 def verify_authenticity unless session_auth_token == form_auth_token raise "Invalid Authenticity Token" end end
Private Instance Methods
form_auth_token()
click to toggle source
# File lib/laris/controller/csrf.rb, line 13 def form_auth_token params['authenticity_token'] end
session_auth_token()
click to toggle source
# File lib/laris/controller/csrf.rb, line 21 def session_auth_token session['authenticity_token'] end
set_session_auth_token()
click to toggle source
# File lib/laris/controller/csrf.rb, line 17 def set_session_auth_token session['authenticity_token'] = form_authenticity_token end