Sha256: ed77ed0006782363feda4708e4b9c4c58d757598cbf5f94662fe993b16a754a3
Contents?: true
Size: 853 Bytes
Versions: 3
Compression:
Stored size: 853 Bytes
Contents
require 'sinatra/base' require 'json' require 'net/https' module Persona module Verifier DEFAULT_VERIFIER_URI = URI("https://verifier.login.persona.org/verify") def self.verify_assertion(assertion, audience, verifier_uri: nil) verifier_uri ||= DEFAULT_VERIFIER_URI Net::HTTP.start(verifier_uri.host, verifier_uri.port, use_ssl: true) do |conn| params = {assertion: assertion, audience: audience} verifier_uri.query = URI.encode_www_form(params) request = Net::HTTP::Post.new verifier_uri response = conn.request request if not response.code == '200' or response.body.nil? then return nil end parsed = JSON.parse response.body if parsed['status'] == 'okay' then parsed['email'] else nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sinatra_persona-0.0.3 | lib/sinatra_persona/verifier.rb |
sinatra_persona-0.0.2 | lib/sinatra_persona/verifier.rb |
sinatra_persona-0.0.1 | lib/sinatra_persona/verifier.rb |