0
votes

I am trying to authenticate users through Azure Active Directory in a node.js application. I am using azure-activedirectory-library-for-nodejs. Here is the sample code I have replicated https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/username-password-sample.js . I have created a self signed certificate and uploaded to Azure AD using Azure AD power shell. I am still getting certificate un-trsuted error. Can anyone suggest a solution for the issue?

1
Could you paste your nodejs code or error information? - Peter Pan
Code is exactly the same as here github.com/AzureAD/azure-activedirectory-library-for-nodejs/… . I am getting 'Cert_Untrusted' error @ context.acquireTokenWithUsernamePassword() method - Maverik
I think you should refer to the "certificate-credentials-sample" code github.com/AzureAD/azure-activedirectory-library-for-nodejs/… when using self signed certificate. - Peter Pan
I need to use 'UserName-Passowrd' to authenticate. - Maverik
OK. It seems to be not related to self signed certificate. The easy way to authenticate users for sign-in nodejs app is using "passport-azure-ad" package, you can refer to azure.microsoft.com/en-us/documentation/articles/…. And there is a sample github.com/Azure-Samples/… for this scene. - Peter Pan

1 Answers

1
votes

The sample code (https://github.com/AzureAD/azure-activedirectory-library-for-nodejs/blob/master/sample/username-password-sample.js) don't need to use any self signed certificate to authenticate user.

Generally, Using management certificate to authentificate for Service Management on Azure, please refer to https://msdn.microsoft.com/en-us/library/azure/ee460782.aspx.

The easy way to authenticate users for sign-in nodejs app is using "passport-azure-ad" package, you can refer to https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-devquickstarts-node-web/. And there is a sample https://github.com/Azure-Samples/active-directory-node-webapp-openidconnect for this scenario.

The passport-azure-ad is a strategy of passportjs for Azure AD OpenID connect.

If you just want to authenticate users for using AAD to sign-in apps, you can also try to use passport-azure-ad-oauth2 https://github.com/auth0/passport-azure-ad-oauth2.

About the usage of PassportJS, please refer to http://passportjs.org/docs.