class Rack::Middleware::AngusAuthentication
Constants
- TIMEOUT_MESSAGE
- UNAUTHORIZED_MESSAGE
Public Class Methods
new(app, settings = {})
click to toggle source
# File lib/rack/middleware/angus_authentication.rb, line 11 def initialize(app, settings = {}) @app = app @authentication_settings = settings end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/middleware/angus_authentication.rb, line 17 def call(env) dup.call!(env) end
call!(env)
click to toggle source
# File lib/rack/middleware/angus_authentication.rb, line 21 def call!(env) authentication_provider = Angus::Authentication::Provider.new(@authentication_settings, env) authentication_provider.authenticate! response = @app.call(env) authentication_provider.update_response_header(response) response rescue Angus::Authentication::MissingAuthorizationData, Angus::Authentication::InvalidAuthorizationData [401, {}, [UNAUTHORIZED_MESSAGE]] rescue Angus::Authentication::AuthorizationTimeout [419, {}, [TIMEOUT_MESSAGE]] end