Class: SAML2::AuthnRequest
- Inherits:
-
Object
- Object
- SAML2::AuthnRequest
- Defined in:
- lib/saml2/authn_request.rb
Instance Attribute Summary collapse
-
#assertion_consumer_service ⇒ Object
readonly
Returns the value of attribute assertion_consumer_service.
-
#attribute_consuming_service ⇒ Object
readonly
Returns the value of attribute attribute_consuming_service.
Class Method Summary collapse
Instance Method Summary collapse
- #assertion_consumer_service_index ⇒ Object
- #assertion_consumer_service_url ⇒ Object
- #attribute_consuming_service_index ⇒ Object
- #force_authn? ⇒ Boolean
- #id ⇒ Object
-
#initialize(document) ⇒ AuthnRequest
constructor
A new instance of AuthnRequest.
- #issuer ⇒ Object
- #name_id_policy ⇒ Object
- #passive? ⇒ Boolean
- #protocol_binding ⇒ Object
- #resolve(service_provider) ⇒ Object
- #subject ⇒ Object
- #valid_interoperable_profile? ⇒ Boolean
- #valid_schema? ⇒ Boolean
- #valid_web_browser_sso_profile? ⇒ Boolean
Constructor Details
#initialize(document) ⇒ AuthnRequest
Returns a new instance of AuthnRequest.
28 29 30 |
# File 'lib/saml2/authn_request.rb', line 28 def initialize(document) @document = document end |
Instance Attribute Details
#assertion_consumer_service ⇒ Object (readonly)
Returns the value of attribute assertion_consumer_service.
86 87 88 |
# File 'lib/saml2/authn_request.rb', line 86 def assertion_consumer_service @assertion_consumer_service end |
#attribute_consuming_service ⇒ Object (readonly)
Returns the value of attribute attribute_consuming_service.
86 87 88 |
# File 'lib/saml2/authn_request.rb', line 86 def attribute_consuming_service @attribute_consuming_service end |
Class Method Details
.decode(authnrequest) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/saml2/authn_request.rb', line 13 def self.decode(authnrequest) begin zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS) authnrequest = zstream.inflate(Base64.decode64(authnrequest)) zstream.finish zstream.close rescue Zlib::BufError end parse(authnrequest) end |
.parse(authnrequest) ⇒ Object
24 25 26 |
# File 'lib/saml2/authn_request.rb', line 24 def self.parse(authnrequest) new(Nokogiri::XML(authnrequest)) end |
Instance Method Details
#assertion_consumer_service_index ⇒ Object
92 93 94 |
# File 'lib/saml2/authn_request.rb', line 92 def assertion_consumer_service_index @document.root['AssertionConsumerServiceIndex'] && @document.root['AssertionConsumerServiceIndex'].to_i end |
#assertion_consumer_service_url ⇒ Object
88 89 90 |
# File 'lib/saml2/authn_request.rb', line 88 def assertion_consumer_service_url @document.root['AssertionConsumerServiceURL'] end |
#attribute_consuming_service_index ⇒ Object
96 97 98 |
# File 'lib/saml2/authn_request.rb', line 96 def attribute_consuming_service_index @document.root['AttributeConsumerServiceIndex'] && @document.root['AttributeConsumerServiceIndex'].to_i end |
#force_authn? ⇒ Boolean
100 101 102 |
# File 'lib/saml2/authn_request.rb', line 100 def force_authn? @document.root['ForceAuthn'] end |
#id ⇒ Object
82 83 84 |
# File 'lib/saml2/authn_request.rb', line 82 def id @document.root['ID'] end |
#issuer ⇒ Object
74 75 76 |
# File 'lib/saml2/authn_request.rb', line 74 def issuer @issuer ||= NameID.from_xml(@document.root.at_xpath('saml:Issuer', Namespaces::ALL)) end |
#name_id_policy ⇒ Object
78 79 80 |
# File 'lib/saml2/authn_request.rb', line 78 def name_id_policy @name_id_policy ||= NameID::Policy.from_xml(@document.root.at_xpath('samlp:NameIDPolicy', Namespaces::ALL)) end |
#passive? ⇒ Boolean
104 105 106 |
# File 'lib/saml2/authn_request.rb', line 104 def passive? @document.root['IsPassive'] end |
#protocol_binding ⇒ Object
108 109 110 |
# File 'lib/saml2/authn_request.rb', line 108 def protocol_binding @document.root['ProtocolBinding'] end |
#resolve(service_provider) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/saml2/authn_request.rb', line 58 def resolve(service_provider) # TODO: check signature if present if assertion_consumer_service_url @assertion_consumer_service = service_provider.assertion_consumer_services.find { |acs| acs.location == assertion_consumer_service_url } else @assertion_consumer_service = service_provider.assertion_consumer_services.resolve(assertion_consumer_service_index) end @attribute_consuming_service = service_provider.attribute_consuming_services.resolve(attribute_consuming_service_index) return false unless @assertion_consumer_service return false if attribute_consuming_service_index && !@attribute_consuming_service true end |
#subject ⇒ Object
112 113 114 |
# File 'lib/saml2/authn_request.rb', line 112 def subject @subject ||= Subject.from_xml(@document.at_xpath('saml:Subject', Namespaces::ALL)) end |
#valid_interoperable_profile? ⇒ Boolean
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/saml2/authn_request.rb', line 47 def valid_interoperable_profile? # It's a subset of Web Browser SSO profile return false unless valid_web_browser_sso_profile? return false unless assertion_consumer_service_url return false if protocol_binding && protocol_binding != Endpoint::Bindings::HTTP_POST return false if subject true end |
#valid_schema? ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/saml2/authn_request.rb', line 32 def valid_schema? return false unless Schemas.protocol.valid?(@document) # Check for the correct root element return false unless @document.at_xpath('/samlp:AuthnRequest', Namespaces::ALL) true end |