Comparing changes
v1.0.3
→
v1.0.4
5 commits
7 files changed
Commits
Changed files (7)
exe/saml-kit-create-self-signed-certificate
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
require 'saml/kit'
+Saml::Kit.deprecate("Use the 'saml-kit-cli' gem instead. saml-kit-create-self-signed-certificate")
+
puts "Enter Passphrase:"
passphrase = STDIN.read.strip
certificate, private_key = ::Xml::Kit::SelfSignedCertificate.new.create(passphrase: passphrase)
exe/saml-kit-decode-http-post
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
require 'saml/kit'
+Saml::Kit.deprecate("Use the 'saml-kit-cli' gem instead. saml-kit-decode-http-post")
+
saml = STDIN.read
binding = Saml::Kit::Bindings::HttpPost.new(location: '')
puts binding.deserialize('SAMLRequest' => saml).to_xml(pretty: true)
exe/saml-kit-decode-http-redirect
@@ -1,6 +1,8 @@
#!/usr/bin/env ruby
require 'saml/kit'
+Saml::Kit.deprecate("Use the 'saml-kit-cli' gem instead. saml-kit-decode-http-redirect*")
+
input = STDIN.read
binding = Saml::Kit::Bindings::HttpRedirect.new(location: '')
lib/saml/kit/assertion.rb
@@ -8,7 +8,7 @@ module Saml
validate :must_be_active_session
attr_reader :name
- def initialize(xml_hash, configuration:)
+ def initialize(xml_hash, configuration: Saml::Kit.configuration)
@name = "Assertion"
@xml_hash = xml_hash
@configuration = configuration
@@ -36,7 +36,7 @@ module Saml
end
def active?(now = Time.current)
- now > configuration.clock_drift.before(started_at) && !expired?
+ now > configuration.clock_drift.seconds.before(started_at) && !expired?
end
def attributes
@@ -71,6 +71,10 @@ module Saml
@xml_hash.fetch('Response', {}).fetch('EncryptedAssertion', nil).present?
end
+ def present?
+ assertion.present?
+ end
+
private
attr_reader :configuration
lib/saml/kit/namespaces.rb
@@ -6,6 +6,7 @@ module Saml
BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
BEARER = "urn:oasis:names:tc:SAML:2.0:cm:bearer"
EMAIL_ADDRESS = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
+ INVALID_NAME_ID_POLICY = "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"
METADATA = "urn:oasis:names:tc:SAML:2.0:metadata"
PASSWORD = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
PASSWORD_PROTECTED = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
lib/saml/kit/version.rb
@@ -1,5 +1,5 @@
module Saml
module Kit
- VERSION = "1.0.3"
+ VERSION = "1.0.4"
end
end
spec/saml/assertion_spec.rb
@@ -25,5 +25,39 @@ RSpec.describe Saml::Kit::Assertion do
expect(subject).to be_active
expect(subject).to_not be_expired
end
+
+ it 'interprets integers correctly' do
+ configuration.clock_drift = 30
+ now = Time.current
+ travel_to now
+ xml_hash = {
+ 'Response' => {
+ 'Assertion' => {
+ 'Conditions' => {
+ 'NotBefore' => now.utc.iso8601,
+ 'NotOnOrAfter' => configuration.session_timeout.since(now).iso8601,
+ }
+ }
+ }
+ }
+
+ subject = described_class.new(xml_hash, configuration: configuration)
+ expect(subject).to be_active
+ expect(subject).to_not be_expired
+ end
+ end
+
+ describe "#present?" do
+ it 'returns false when the assertion is empty' do
+ xml_hash = { 'Response' => { } }
+ subject = described_class.new(xml_hash)
+ expect(subject).to_not be_present
+ end
+
+ it 'returns true when the assertion is present' do
+ xml_hash = { 'Response' => { 'Assertion' => { 'Conditions' => { } } } }
+ subject = described_class.new(xml_hash)
+ expect(subject).to be_present
+ end
end
end