samlify icon indicating copy to clipboard operation
samlify copied to clipboard

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

Open crk4 opened this issue 6 years ago • 10 comments

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)

crk4 avatar Sep 14 '19 11:09 crk4

@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.

tngan avatar Sep 16 '19 08:09 tngan

@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

bttf avatar Apr 08 '20 04:04 bttf

@bttf Would you like to post your metadata here?

tngan avatar Apr 08 '20 06:04 tngan

<?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>

bttf avatar Apr 08 '20 15:04 bttf

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

tngan avatar Apr 09 '20 13:04 tngan

@tngan Using [email protected]

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

bttf avatar Apr 09 '20 18:04 bttf

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

tngan avatar Apr 09 '20 21:04 tngan

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

bttf avatar Apr 10 '20 23:04 bttf

@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.

rkkatariya avatar Apr 19 '20 08:04 rkkatariya