class OmniAuth::Strategies::Irma

Constants

LOOKUP

Public Instance Methods

raw_info(sessiontoken) click to toggle source
# File lib/omniauth/strategies/irma.rb, line 48
def raw_info(sessiontoken)
  if @raw_info.nil?
    sessionresult = JSON.load(Faraday.get("#{options[:irma_server]}/session/#{sessiontoken}/result").body)

    @raw_info = {}
    lookup = LOOKUP.merge(options[:attrs_lookup])
    puts lookup.to_json
    sessionresult["disclosed"].each do |concon|
      concon.each do |con|
        attribute_id = con["id"]
        opts = lookup[attribute_id]
        raw_info_key = opts[:key]
        raise RuntimeError if raw_info_key.nil?
        val = con["rawvalue"]
        if !opts[:replace].nil? && opts[:replace].key?(val)
          val = opts[:replace][val]
        end
        @raw_info[raw_info_key] = val
      end
    end
  end
  @raw_info
end
request_phase() click to toggle source
# File lib/omniauth/strategies/irma.rb, line 22
def request_phase
  registering = !Rack::Utils.parse_nested_query(request.query_string)["register"].nil?
  disclose = registering ? options[:attrs_register].to_json : options[:attrs_login].to_json
  body = "{\"@context\":\"https://irma.app/ld/request/disclosure/v2\",\"disclose\":#{disclose}}"
  headers = {"Content-Type" => "application/json"}
  headers["Authorization"] = options[:requestor_token] if options[:requestor_token].present?
  res = Faraday.post("#{options[:irma_server]}/session", body, headers).body
  Rack::Response.new(res, 200, "content-type" => "application/json").finish
end
token(request) click to toggle source
# File lib/omniauth/strategies/irma.rb, line 44
def token(request)
  Rack::Utils.parse_nested_query(request.query_string)["sessiontoken"]
end