class RapidRack::Authenticator
Constants
- DISPATCH
Attributes
audience[R]
error_handler[R]
issuer[R]
secret[R]
Public Class Methods
new(opts)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 11 def initialize(opts) @url = opts[:url] @receiver = opts[:receiver].try(:constantize) fail('A receiver must be configured for rapid_rack') if @receiver.nil? @secret = opts[:secret] @issuer = opts[:issuer] @audience = opts[:audience] @error_handler = opts[:error_handler].try(:constantize).try(:new) || self end
Public Instance Methods
call(env)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 21 def call(env) sym = DISPATCH[env['PATH_INFO']] return send(sym, env) if sym [404, {}, ["Not found: #{env['PATH_INFO']}"]] end
handle(_env, _exception)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 28 def handle(_env, _exception) [ 400, { 'Content-Type' => 'text/plain' }, [ 'Sorry, your attempt to log in to this service was not successful. ', 'Please contact the service owner for assistance, and include the ', 'link you used to access this service.' ] ] end
Private Instance Methods
callback(env)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 53 def callback(env) return method_not_allowed unless method?(env, 'POST') params = Rack::Utils.parse_query(env['rack.input'].read) with_claims(env, params['assertion']) do |claims| receiver.receive(env, claims) end end
initiate(env)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 47 def initiate(env) return method_not_allowed unless method?(env, 'GET') [302, { 'Location' => @url }, []] end
method?(env, method)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 68 def method?(env, method) env['REQUEST_METHOD'] == method end
method_not_allowed()
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 72 def method_not_allowed [405, {}, ['Method not allowed']] end
receiver()
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 76 def receiver @receiver.new end
terminate(env)
click to toggle source
# File lib/rapid_rack/authenticator.rb, line 62 def terminate(env) return method_not_allowed unless method?(env, 'GET') receiver.logout(env) end