Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saml20-clj.sp.request Coerce/->Element throws [samlp:AuthnRequest: null] #64

Open
MMaicki opened this issue Mar 16, 2023 · 3 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MMaicki
Copy link

MMaicki commented Mar 16, 2023

This part is working just fine and returning XML just as it should:

(coerce/->xml-string
                                   [:samlp:AuthnRequest
                                    {:xmlns:samlp                 "urn:oasis:names:tc:SAML:2.0:protocol"
                                     :ID                          request-id
                                     :Version                     "2.0"
                                     :IssueInstant                (format-instant instant)
                                     :ProtocolBinding             "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                                     :ProviderName                sp-name
                                     :IsPassive                   false
                                     :Destination                 idp-url
                                     :AssertionConsumerServiceURL acs-url}
                                    [:saml:Issuer
                                     {:xmlns:saml "urn:oasis:names:tc:SAML:2.0:assertion"}
                                     issuer]
                                    ;;[:samlp:NameIDPolicy {:AllowCreate false :Format saml-format}]
                                    ])

XML that it produces looks like this, which looks fine:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
 <samlp:AuthnRequest 
 AssertionConsumerServiceURL=\"https://www.mydomain.com/saml\" 
 Destination=\"https://login.microsoftonline.com/rand0m-saml2-ap1-id/saml2\" 
 ID=\"999888\" IssueInstant=\"111222\" 
 ProtocolBinding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" 
 ProviderName=\"MyFancyApp\" 
 Version=\"2.0\" 
 xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">
 <saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">
 https://login.microsoftonline.com/rand0m-saml2-ap1-id/federationmetadata/2007-06/federationmetadata.xml
 </saml:Issuer>
 </samlp:AuthnRequest>

But coerce/->Element returns #object[com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl 0x6db903b4 "[samlp:AuthnRequest: null]"] which is bad as it should have values from the XML instead of NULL.

(coerce/->Element (coerce/->xml-string
                                   [:samlp:AuthnRequest
                                    {:xmlns:samlp                 "urn:oasis:names:tc:SAML:2.0:protocol"
                                     :ID                          request-id
                                     :Version                     "2.0"
                                     :IssueInstant                (format-instant instant)
                                     :ProtocolBinding             "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                                     :ProviderName                sp-name
                                     :IsPassive                   false
                                     :Destination                 idp-url
                                     :AssertionConsumerServiceURL acs-url}
                                    [:saml:Issuer
                                     {:xmlns:saml "urn:oasis:names:tc:SAML:2.0:assertion"}
                                     issuer]
                                    ;;[:samlp:NameIDPolicy {:AllowCreate false :Format saml-format}]
                                    ]))

I was following README guide and this error breaks everything.

@camsaul
Copy link
Member

camsaul commented Mar 29, 2023

Hmmm, that's weird. Did you dig in to this at all? PRs welcome

@camsaul camsaul added bug Something isn't working help wanted Extra attention is needed labels Mar 29, 2023
@camsaul
Copy link
Member

camsaul commented Mar 29, 2023

What version of the lib are you using? We fixed support for non-saml namespaces in 2.1.0, so this wouldn't have worked in prior versions because the namespace above is samlp

@MMaicki
Copy link
Author

MMaicki commented Apr 4, 2023

I'm using [metabase/saml20-clj "2.1.0"]

I don't have PR.
I was trying to migrate from kirasystems/saml20-clj lib and I was creating a POC.

I hoped for this lib to work out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants