From bc7052dd64a5541233af27a1e2553c22f9fdd3c1 Mon Sep 17 00:00:00 2001 From: Phu Kieu Date: Fri, 2 Dec 2016 15:52:09 -0800 Subject: [PATCH] Remove signature related fields when SPSignRequest=false --- authnrequest.go | 7 ++++++- types.go | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/authnrequest.go b/authnrequest.go index 3c826a6..0c41083 100644 --- a/authnrequest.go +++ b/authnrequest.go @@ -87,6 +87,11 @@ func (s *ServiceProviderSettings) GetAuthnRequest() *AuthnRequest { r.Issuer.Url = s.IDPSSODescriptorURL r.Signature.KeyInfo.X509Data.X509Certificate.Cert = s.PublicCert() + if !s.SPSignRequest { + r.SAMLSIG = "" + r.Signature = nil + } + return r } @@ -146,7 +151,7 @@ func NewAuthnRequest() *AuthnRequest { Transport: "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", }, }, - Signature: Signature{ + Signature: &Signature{ XMLName: xml.Name{ Local: "samlsig:Signature", }, diff --git a/types.go b/types.go index 217340f..e691c02 100644 --- a/types.go +++ b/types.go @@ -6,7 +6,7 @@ type AuthnRequest struct { XMLName xml.Name SAMLP string `xml:"xmlns:samlp,attr"` SAML string `xml:"xmlns:saml,attr"` - SAMLSIG string `xml:"xmlns:samlsig,attr"` + SAMLSIG string `xml:"xmlns:samlsig,attr,omitempty"` ID string `xml:"ID,attr"` Version string `xml:"Version,attr"` ProtocolBinding string `xml:"ProtocolBinding,attr"` @@ -17,7 +17,7 @@ type AuthnRequest struct { Issuer Issuer `xml:"Issuer"` NameIDPolicy NameIDPolicy `xml:"NameIDPolicy"` RequestedAuthnContext RequestedAuthnContext `xml:"RequestedAuthnContext"` - Signature Signature `xml:"Signature,omitempty"` + Signature *Signature `xml:"Signature,omitempty"` originalString string }