Class: Saml::Kit::AuthenticationRequest
- Includes:
- Requestable
- Defined in:
- lib/saml/kit/authentication_request.rb
Overview
This class can be used to parse a SAML AuthnRequest or generate one.
To generate an AuthnRequest use the builder API.
request = AuthenticationRequest.build do |builder|
builder.name_id_format = [Saml::Kit::Namespaces::EMAIL_ADDRESS]
end
<?xml version="1.0" encoding="UTF-8"?>
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_ca3a0e72-9530-41f1-9518-c53716de88b2" Version="2.0" IssueInstant="2017-12-19T16:27:44Z" Destination="http://hartmann.info" AssertionConsumerServiceURL="https://carroll.com/acs">
<saml:Issuer>Day of the Dangerous Cousins</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"/>
</samlp:AuthnRequest>
Example:
Constant Summary
Constants inherited from Document
Document::NAMESPACES, Document::PROTOCOL_XSD, Document::XPATH
Instance Method Summary collapse
-
#assertion_consumer_service_url ⇒ Object
Extract the AssertionConsumerServiceURL from the AuthnRequest <samlp:AuthnRequest AssertionConsumerServiceURL=“carroll.com/acs”></samlp:AuthnRequest>.
-
#initialize(xml, configuration: Saml::Kit.configuration) ⇒ AuthenticationRequest
constructor
Create an instance of an AuthnRequest document.
-
#name_id_format ⇒ Object
Extract the NameIDPolicy from the AuthnRequest <samlp:AuthnRequest> <samlp:NameIDPolicy Format=“urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress”/> </samlp:AuthnRequest>.
-
#response_for(user, binding:, relay_state: nil, configuration: Saml::Kit.configuration) ⇒ Object
Generate a Response for a specific user.
Methods inherited from Document
#destination, #id, #issue_instant, #issuer, #to_h, #to_s, to_saml_document, #to_xhtml, #to_xml, #version
Methods included from Trustable
Constructor Details
#initialize(xml, configuration: Saml::Kit.configuration) ⇒ AuthenticationRequest
Create an instance of an AuthnRequest document.
27 28 29 |
# File 'lib/saml/kit/authentication_request.rb', line 27 def initialize(xml, configuration: Saml::Kit.configuration) super(xml, name: "AuthnRequest", configuration: configuration) end |
Instance Method Details
#assertion_consumer_service_url ⇒ Object
Extract the AssertionConsumerServiceURL from the AuthnRequest
<samlp:AuthnRequest AssertionConsumerServiceURL="https://carroll.com/acs"></samlp:AuthnRequest>
33 34 35 |
# File 'lib/saml/kit/authentication_request.rb', line 33 def assertion_consumer_service_url to_h[name]['AssertionConsumerServiceURL'] end |
#name_id_format ⇒ Object
Extract the NameIDPolicy from the AuthnRequest
<samlp:AuthnRequest>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"/>
</samlp:AuthnRequest>
41 42 43 |
# File 'lib/saml/kit/authentication_request.rb', line 41 def name_id_format to_h[name]['NameIDPolicy']['Format'] end |
#response_for(user, binding:, relay_state: nil, configuration: Saml::Kit.configuration) ⇒ Object
Generate a Response for a specific user.
49 50 51 52 53 54 55 56 |
# File 'lib/saml/kit/authentication_request.rb', line 49 def response_for(user, binding:, relay_state: nil, configuration: Saml::Kit.configuration) response_binding = provider.assertion_consumer_service_for(binding: binding) builder = Saml::Kit::Response.builder(user, self, configuration: configuration) do |x| x. = provider.want_assertions_signed yield x if block_given? end response_binding.serialize(builder, relay_state: relay_state) end |