Sha256: d9e3546a2cf3879f07c6e81001981ce6a29a7df1bc88615055670d60705503f4
Contents?: true
Size: 950 Bytes
Versions: 5
Compression:
Stored size: 950 Bytes
Contents
require 'rack' module SoarAuthenticationToken class RackMiddleware def initialize(app, configuration) @app = app @configuration = configuration end def call(env) request = Rack::Request.new env session, params = request.session, request.params valid, token_meta = validate_and_resolve_token(request.env['HTTP_AUTHORIZATION'],params['flow_identifier']) if valid session['user'] = token_meta['authenticated_identifier'] session['auth_token_meta'] = token_meta @app.call env else [401, {"Content-Type" => "text/html"}, ["401 - Not authenticated"]] end end private def validate_and_resolve_token(authentication_token,flow_identifier) token_validator = SoarAuthenticationToken::TokenValidator.new(@configuration) token_validator.validate(authentication_token: authentication_token,flow_identifier: flow_identifier) end end end
Version data entries
5 entries across 5 versions & 1 rubygems