samlify icon indicating copy to clipboard operation
samlify copied to clipboard

Saml - IDP

Open tzahush opened this issue 7 years ago • 11 comments

Hello, I am trying to understand how could I create an IDP on my NodeJS server which will integrate with multiple SP's? So for example if i go to '/saml/sp1' it will connect to sp1 on my created IDP, could anyone please help me out with the code?

tzahush avatar Feb 25 '19 18:02 tzahush

@tzahush Hi, there is an example in https://samlify.js.org/#/multi-entities.

tngan avatar Feb 26 '19 03:02 tngan

@tngan Hey, so maybe i didn't fully understand.

How is it possible to make my own IDP, beacuase what i see there is a 'default-idp' and onelogin idp. Is it even possible declaring my server as an IDP?

tzahush avatar Feb 26 '19 03:02 tzahush

Yes, you can create your own IdP, for example:

const myIdP = saml.IdentityProvider({
  metadata: fs.readFileSync('./my_idp_metadata.xml')
});

tngan avatar Feb 26 '19 04:02 tngan

@tngan I see, thanks,

One more question, is there a way to generate my IDP certificate somehow? also to have it outputted from my express, example: /api/getmetadata will return the XML?

tzahush avatar Feb 26 '19 04:02 tzahush

@tzahush For metadata distribution, you can set up a route and call an instance method getMetadata. For example,

const idp = saml.IdentityProvider({
  metadata: fs.readFileSync('./metadata_idp.xml')
});

router.get('/metadata', (req, res) => {
  res.header('Content-Type', 'text/xml').send(idp.getMetadata());
});

Certificate generation is out of this project, you can simply create a self-signed certificate via openssl.

tngan avatar Feb 26 '19 10:02 tngan

@tzahush Did you resolve this ?

tngan avatar Mar 11 '19 14:03 tngan

Yea got an operating IDP, thanks for the help :)

tzahush avatar Mar 11 '19 15:03 tzahush

Hi @tngan - I am looking for some direction in setting up our own IDP, I see that @tzahush have successfully implemented and this issue has been closed. Would really help if you could give some documentation on the same or some sample own IDP.

I do not want to use existing IDP such as onelogin, otka , oath etc. rather want to setup my own.

thank you for your assistance in advance

LogeswaranA avatar Aug 26 '19 09:08 LogeswaranA

@LogeswaranAudhikesavan you're not alone :D, i'm also looking for some resources to implement my own IDP

Cerbis avatar Aug 26 '19 12:08 Cerbis

@LogeswaranAudhikesavan @Cerbis You can find an example under https://github.com/tngan/samlify/blob/master/test/flow.ts.

Minimal work for SP-init SSO:

  1. Create a web server and expose an endpoint
  2. If user is not logged into your IdP, redirect to idp login page
  3. If user is logged in, use the function to parse the request parseLoginRequest
  4. Check if the email or name id matches the persistence record stored in user table
  5. Send back the response through createLoginResponse.

tngan avatar Sep 04 '19 07:09 tngan

We only provide functions to do request parsing and response generation, the rest is your business/application level logic.

tngan avatar Sep 04 '19 07:09 tngan