From 92927db76d2d50233e64566f0dd3f5a773a6b1a9 Mon Sep 17 00:00:00 2001 From: taro1025 Date: Fri, 30 Aug 2024 15:20:15 +0900 Subject: [PATCH] feat: Idp initiated-logging-out --- .idea/workspace.xml | 53 ++++++++++++++++++++++++++ lib/saml_idp/logout_request_builder.rb | 27 +++++++------ 2 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..7de85a72 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + 1724996887307 + + + + + + \ No newline at end of file diff --git a/lib/saml_idp/logout_request_builder.rb b/lib/saml_idp/logout_request_builder.rb index b75f9315..63c962b5 100644 --- a/lib/saml_idp/logout_request_builder.rb +++ b/lib/saml_idp/logout_request_builder.rb @@ -1,7 +1,10 @@ require 'saml_idp/logout_builder' module SamlIdp class LogoutRequestBuilder < LogoutBuilder + include SamlIdp::Signable + attr_accessor :name_id + attr_accessor :reference_id def initialize(response_id, issuer_uri, saml_slo_url, name_id, algorithm) super(response_id, issuer_uri, saml_slo_url, algorithm) @@ -9,18 +12,20 @@ def initialize(response_id, issuer_uri, saml_slo_url, name_id, algorithm) end def build + req_options = {} + req_options[:ID] = "_#{reference_id}" + req_options[:Version] = "2.0" + req_options[:IssueInstant] = now_iso + req_options[:Destination] = saml_slo_url + req_options["xmlns:samlp"] = Saml::XML::Namespaces::PROTOCOL + req_options["xmlns:saml"] = Saml::XML::Namespaces::ASSERTION + req_options[:NotOnOrAfter] = (Time.now + 180).utc.iso8601 builder = Builder::XmlMarkup.new - builder.LogoutRequest ID: response_id_string, - Version: "2.0", - IssueInstant: now_iso, - Destination: saml_slo_url, - "xmlns" => Saml::XML::Namespaces::PROTOCOL do |request| - request.Issuer issuer_uri, xmlns: Saml::XML::Namespaces::ASSERTION - sign request - request.NameID name_id, xmlns: Saml::XML::Namespaces::ASSERTION, - Format: Saml::XML::Namespaces::Formats::NameId::PERSISTENT - request.SessionIndex response_id_string - end + builder.tag! "samlp:LogoutRequest", req_options do |request| + request.tag! "saml:Issuer", issuer_uri + sign request + request.tag! "saml:NameID", name_id, Format: Saml::XML::Namespaces::Formats::NameId::PERSISTENT + end end private :build end