Commit 997fa4b

mo <mo.khan@gmail.com>
2017-11-10 20:47:51
parse -> deserialize.
1 parent bb9cf8a
Changed files (3)
airport
app
saml-kit
lib
saml
spec
airport/app/controllers/sessions_controller.rb
@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
   end
 
   def create
-    @saml_response = Saml::Kit::Response.parse(params[:SAMLResponse])
+    @saml_response = Saml::Kit::Response.deserialize(params[:SAMLResponse])
     return render :error, status: :forbidden if @saml_response.invalid?
 
     session[:user] = { id: @saml_response.name_id }.merge(@saml_response.attributes)
saml-kit/lib/saml/kit/response.rb
@@ -97,8 +97,8 @@ module Saml
         Time.current > started_at && !expired?
       end
 
-      def self.parse(saml_response)
-        new(Base64.decode64(saml_response))
+      def self.deserialize(saml_response)
+        new(Saml::Kit::Content.decode_raw_saml(saml_response))
       end
 
       private
saml-kit/spec/saml/response_spec.rb
@@ -65,12 +65,12 @@ RSpec.describe Saml::Kit::Response do
     end
   end
 
-  describe ".parse" do
+  describe ".deserialize" do
     subject { described_class }
     let(:raw_response) { IO.read('spec/fixtures/encoded_response.txt') }
 
     it 'decodes the response to the raw xml' do
-      result = Hash.from_xml(subject.parse(raw_response).to_xml)
+      result = Hash.from_xml(subject.deserialize(raw_response).to_xml)
       expect(result['Response']['ID']).to eql('_75358cd9-f357-4b2d-999f-f53382ba8263')
       expect(result['Response']['Version']).to eql('2.0')
       expect(result['Response']['IssueInstant']).to eql("2017-10-22T23:36:44Z")