class Rack::Contrib::Nonce
Constants
- VERSION
Public Class Methods
new(app, opts)
click to toggle source
# File lib/rack/contrib/nonce.rb, line 6 def initialize app, opts @app = app @logger = opts[:logger] || Logger.new('/dev/null') @seen = opts[:seen] || [] @header = opts[:header] || 'Nonce' end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/contrib/nonce.rb, line 17 def call env unless env[header_name] @logger.error "Denied: #{@header} not present." return [401, {}, []] end if @seen.include? env[header_name] @logger.error "Denied: #{@header} not unique." return [401, {}, []] end @seen << env[header_name] @app.call(env) end
header_name()
click to toggle source
# File lib/rack/contrib/nonce.rb, line 13 def header_name 'HTTP_' + @header.upcase.gsub(/-/, '_') end