Class: Rack::U2f::AuthenticationMiddleware
- Inherits:
-
Object
- Object
- Rack::U2f::AuthenticationMiddleware
- Includes:
- Helpers
- Defined in:
- lib/rack/u2f/authentication_middleware.rb
Overview
Middleware to authenticate against registered u2f keys
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config = nil) ⇒ AuthenticationMiddleware
constructor
A new instance of AuthenticationMiddleware.
Methods included from Helpers
Constructor Details
#initialize(app, config = nil) ⇒ AuthenticationMiddleware
Returns a new instance of AuthenticationMiddleware.
7 8 9 10 11 |
# File 'lib/rack/u2f/authentication_middleware.rb', line 7 def initialize(app, config = nil) @app = app @store = config[:store] || raise('Please specify a U2F store such as Rack::U2f::RegistrationStore::RedisStore.new') @exclude_urls = config[:exclude_urls] || [/\A\/u2f/] end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rack/u2f/authentication_middleware.rb', line 13 def call(env) request = Rack::Request.new(env) return @app.call(env) if excluded?(request) return @app.call(env) if authenticated?(request) return resp_auth_from_u2f(request) if request.params['u2f_auth'] challenge_page(request) end |