diff --git a/build_request.go b/build_request.go index 41a41a1..4eba224 100644 --- a/build_request.go +++ b/build_request.go @@ -41,9 +41,11 @@ func (sp *SAMLServiceProvider) buildAuthnRequest(includeSig bool) (*etree.Docume authnRequest.CreateElement("saml:Issuer").SetText(sp.IdentityProviderIssuer) } - nameIdPolicy := authnRequest.CreateElement("samlp:NameIDPolicy") - nameIdPolicy.CreateAttr("AllowCreate", "true") - nameIdPolicy.CreateAttr("Format", sp.NameIdFormat) + if sp.NameIdFormat != "" { + nameIdPolicy := authnRequest.CreateElement("samlp:NameIDPolicy") + nameIdPolicy.CreateAttr("AllowCreate", "true") + nameIdPolicy.CreateAttr("Format", sp.NameIdFormat) + } if sp.RequestedAuthnContext != nil { requestedAuthnContext := authnRequest.CreateElement("samlp:RequestedAuthnContext")