Sha256: 90ed27d86b00b544cb545f6e01112357b3044163b9fa3b4be4503a97724fb862
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Keycard # This class is responsible for extracting the user attributes (i.e. the # complete set of things that determine the user's #identity), given a Rack # request. class RequestAttributes def initialize(request, finder: InstitutionFinder.new, request_factory: default_factory) @request = request @finder = finder @request_factory = request_factory end def [](attr) all[attr] end def all user_attributes.merge(finder.attributes_for(request)) end private def user_attributes { username: request.username } end def request request_factory.for(@request) end def default_factory access = Keycard.config.access.to_sym case access when :direct DirectRequest when :proxy ProxiedRequest else # TODO: Warn about this once to the appropriate log; probably in a config check, not here. # puts "Keycard does not recognize the '#{access}' access mode, using 'direct'." DirectRequest end end attr_reader :finder attr_reader :request_factory end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keycard-0.1.2 | lib/keycard/request_attributes.rb |