AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 374 forks source link

Programatically sign in user w/o the prompt #759

Closed rogeralsing closed 6 years ago

rogeralsing commented 6 years ago

We use ADAL JS in our app, we are also evaluating Cypress for automated frontend tests. The issue here is that Cypress does not allow redirects off site, e.g. for the login process.

This is problematic as both our back and frontend relies on having a logged in user. we validate things by looking at AD groups etc.

Is there any way to programatically sign in a user using e.g. username/pwd w/o redirecting away from the site? Any clever options we could use here?

The Cypress devs state that most other OAuth providers allow this, but not Azure AD.

richardspence commented 6 years ago

All the functionality of this library relies on redirects either via the main tab or via the iframes. If you can't support that - that's a deal breaker. You should look to use an alternative authentication method for your front end tests.

If you want to fake it you could fake the library entirely, or alternatively neuter it by preload the tokens into localstorage, etc.

nehaagrawal commented 6 years ago

@rogeralsing You mentioned that redirects are blocked but is popup allowed? If yes, you can try the login with a popup config. Please check this wiki https://github.com/AzureAD/azure-activedirectory-library-for-js/wiki/Login-methods

If both redirect and popup are not allowed then we don't provide any other option to login. I am closing this issue for now.