class OmniAuth::Strategies::Blockstack
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/blockstack.rb, line 74 def callback_phase auth_response = request.params['authResponse'] ::Blockstack.api = options.blockstack_api ::Blockstack.leeway = options.leeway ::Blockstack.valid_within = options.valid_within @decoded_token = ::Blockstack.verify_auth_response auth_response super rescue ::Blockstack::InvalidAuthResponse => error fail! :invalid_auth_response, error end
decoded_token()
click to toggle source
# File lib/omniauth/strategies/blockstack.rb, line 23 def decoded_token @decoded_token end
request_phase()
click to toggle source
# File lib/omniauth/strategies/blockstack.rb, line 27 def request_phase app_manifest = { :name => options.app_name, :short_name => (options.app_short_name ? options.app_short_name : options.app_name), :start_url => callback_url, :display => "standalone", :background_color => "#fff", :description => options.app_description, :icons => options.app_icons } if request.params["manifest"] return Rack::Response.new(app_manifest.to_json, 200, 'content-type' => 'text/json', 'Access-Control-Allow-Origin' => '*').finish end blockstack_js = File.open(File.join(File.dirname(__FILE__), "blockstack.js"), "rb").read auth_request_js = File.open(File.join(File.dirname(__FILE__), "auth-request.js"), "rb").read header_info = "<script>#{blockstack_js}</script>" app_data_js = <<~JAVASCRIPT var manifestURI = "#{callback_url.chomp("/callback") + "?manifest=true"}" var redirectURI = "#{callback_url}" JAVASCRIPT header_info << "<script>#{app_data_js}</script>" header_info << "<script>#{auth_request_js}</script>" title = "Redirecting to Blockstack" html = %{ <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>#{title}</title> #{header_info} </head> <body>Redirecting to blockstack</body> </html> } Rack::Response.new(html, 200, 'content-type' => 'text/html').finish end