My Question: How do I Secure my Node JS API with JWT Token having Shibboleth SSO as the Authentication mechanism?
[MY APPLICATION FLOW]
[NORMAL JWT SCENARIO TO SECURE API]
[MY JWT SCENARIO AND PROBLEM]
[AN APPROACH WITH A FLAW]
So again My Question is: How do I Secure my Node JS API with JWT Token having Shibboleth SSO as the Authentication mechanism?
I hope, I might have explained my scenario properly. Any help, guidance, or a right direction will be appreciated.
Thanks :)
The [NORMAL JWT SCENARIO TO SECURE API] strategy is explained in this article: https://medium.com/front-end-weekly/learn-using-jwt-with-passport-authentication-9761539c4314.
Assuming you use a library like Node Express to implement your API resource endpoints, you can make use of an application middleware like Passport that handles authentication and restricts access to resources only for clients in possession of a valid JWT token:
/login
endpoint on the back-end and is provided with a JWT token. At this moment we introduce [MY JWT SCENARIO AND PROBLEM]: when the user reaches the AngularJS app, he is already authenticated by Shibboleth SSO. And you want to ensure that he cannot go out of the SSO context by allowing the AngularJS app to provide its own username / password to the NodeJS back-end.
That requires a trusted way to validate the SAML2 assertion provided to the AngularJS app by the IdP in the NodeJS back-end. Per the SAML description available at https://community.apigee.com/articles/33625/saml-20-vs-jwt-understanding-federated-identity-an.html, that requires trust to be established between the NodeJS back-end and the IDP such that the back-end can validate the SAML assertion provided by the AngularJS app.
For that I inspired my theoretical answer from this article: https://wiki.library.ucsf.edu/spaces/flyingpdf/pdfpageexport.action?pageId=361762610. It basically extends the JWT-token implementation already discussed above as follows:
passport-saml
strategy in order to communicate with Shibboleth SSO for SAML2 assertion validation and register the NodeJS back-end as a SP to the IdP (see the Provide SP metadata to IDP section in the above link)./login
endpoint protected by the local strategy, as we do not wish to allow unverified username / password logins. /ssologin
endpoint in the NodeJS back-end and protect access to the route with Passport authentication using the SAML strategy. The AngularJS app will call this endpoint and pass the SAML2 assertion as part of the attempt to access it. /ssologin
route. This will only be called if the SAML2 assertion has been validated by the NodeJS app against the Shibboleth SSO (IdP). You can now use information from the SAML assertion to generate the JWT token in the back-end and return it to the AngularJS app.Hope it helps in devising a definitive solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With