tngan / samlify

Node.js library for SAML SSO
https://samlify.js.org
MIT License
610 stars 216 forks source link

The "url" argument must be of type string. Received type object #308

Open crk4 opened 5 years ago

crk4 commented 5 years ago

The "url" argument must be of type string. Received type object TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type object at Url.parse (url.js:154:11) at Object.urlParse [as parse] (url.js:148:13) at buildRedirectURL (d:\Ranjith Office\Sample\sample-app1\node_modules\samlify\build\src\binding-redirect.js:37:25) at Object.loginRequestRedirectURL (d:\Ranjith Office\Sample\sample-app1\node_modules\samlify\build\src\binding-redirect.js:86:22) at ServiceProvider.createLoginRequest (d:\Ranjith Office\Sample\sample-app1\node_modules\samlify\build\src\entity-sp.js:79:47) at router.get (d:\Ranjith Office\Sample\sample-app1\routes\sso.js:25:32) at Layer.handle [as handle_request] (d:\Ranjith Office\Sample\sample-app1\node_modules\express\lib\router\layer.js:95:5) at next (d:\Ranjith Office\Sample\sample-app1\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (d:\Ranjith Office\Sample\sample-app1\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (d:\Ranjith Office\Sample\sample-app1\node_modules\express\lib\router\layer.js:95:5)

tngan commented 5 years ago

@crk4 How many single sign on services did you specify in the metadata? Can you give more information like how do you construct the iDP and the metadata without sensitive information? Otherwise, it's hard for me to check and give you precise feedback just based on the callstack.

bttf commented 4 years ago

@tngan I'm also experiencing this issue. The SAML metadata I have has only one md:SingleSignOnService specified, and the binding for it is urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST.

Stepping through the code, it seems that the library is looking for the HTTP-Redirect binding, and cannot find it, so it defaults to the entire object

tngan commented 4 years ago

@bttf Would you like to post your metadata here?

bttf commented 4 years ago
<?xml version="1.0" ?>
<md:EntityDescriptor entityID="redacted" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata">
    <md:IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
        <md:KeyDescriptor use="signing">
            <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:X509Data>
                    <ds:X509Certificate>redacted</ds:X509Certificate>
                </ds:X509Data>
            </ds:KeyInfo>
        </md:KeyDescriptor>
        <md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</md:NameIDFormat>
        <md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</md:NameIDFormat>
        <md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat>
        <md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
        <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="redacted"/>
    </md:IDPSSODescriptor>
</md:EntityDescriptor>
tngan commented 4 years ago

@bttf In fact, you can only use the post binding when only POST binding is specified. Can you also send me the callstack ?

bttf commented 4 years ago

@tngan Using samlify@2.7.1

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type object
    at Url.parse (url.js:154:11)
    at Object.urlParse [as parse] (url.js:148:13)
    at buildRedirectURL (/Users/bttf/dev/my_app/node_modules/samlify/src/binding-redirect.ts:55:25)
    at Object.loginRequestRedirectURL (/Users/bttf/dev/my_app/node_modules/samlify/src/binding-redirect.ts:105:16)
    at ServiceProvider.createLoginRequest (/Users/bttf/dev/my_app/node_modules/samlify/src/entity-sp.ts:67:30)

Hope this helps

tngan commented 4 years ago

@bttf Are you trying to construct a request with HTTP-Redirect binding when only HTTP-POST binding is specified in the metadata?

bttf commented 4 years ago

@tngan I believe so. I think this was a mistake on my part

rkkatariya commented 4 years ago

@tngan I have run into a similar issue. TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

I am new to SAML. I am trying to setup the idp and sp using the examples you provided. https://github.com/tngan/samlify/tree/f2b6a2f8c36dc0ff887d0442c48cd0f2c0a4a778/examples

Stepping through the code, it seems that the library is looking for octetString to verifyMessageSignature in the redirectFlow, but this is undefined. Can you suggest what I could be doing wrong here.