Saml - IDP
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 Hi, there is an example in https://samlify.js.org/#/multi-entities.
@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?
Yes, you can create your own IdP, for example:
const myIdP = saml.IdentityProvider({
metadata: fs.readFileSync('./my_idp_metadata.xml')
});
@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 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.
@tzahush Did you resolve this ?
Yea got an operating IDP, thanks for the help :)
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
@LogeswaranAudhikesavan you're not alone :D, i'm also looking for some resources to implement my own IDP
@LogeswaranAudhikesavan @Cerbis You can find an example under https://github.com/tngan/samlify/blob/master/test/flow.ts.
Minimal work for SP-init SSO:
- Create a web server and expose an endpoint
- If user is not logged into your IdP, redirect to idp login page
- If user is logged in, use the function to parse the request
parseLoginRequest - Check if the email or name id matches the persistence record stored in user table
- Send back the response through
createLoginResponse.
We only provide functions to do request parsing and response generation, the rest is your business/application level logic.