Commit 72c860b

mo <mo.khan@gmail.com>
2018-02-25 23:57:30
use xpath to find nameid.
1 parent 5195eb2
Changed files (2)
lib
spec
lib/saml/kit/assertion.rb
@@ -22,9 +22,9 @@ module Saml
         @configuration = configuration
         @occurred_at = Time.current
         decrypt!(::Xml::Kit::Decryption.new(
-                   private_keys: (
-                     configuration.private_keys(use: :encryption) + private_keys
-                   ).uniq
+          private_keys: (
+            configuration.private_keys(use: :encryption) + private_keys
+          ).uniq
         ))
       end
 
@@ -33,7 +33,7 @@ module Saml
       end
 
       def name_id
-        assertion.fetch('Subject', {}).fetch('NameID', nil)
+        at_xpath('./saml:Subject/saml:NameID').try(:text)
       end
 
       def signed?
spec/saml/kit/assertion_spec.rb
@@ -9,6 +9,7 @@ RSpec.describe Saml::Kit::Assertion do
   let(:entity_id) { FFaker::Internet.uri("https") }
 
   specify { expect(subject.issuer).to eql(entity_id) }
+  specify { expect(subject.name_id).to eql(user.name_id) }
 
   describe '#active?' do
     let(:configuration) do