Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure login not working - Unable to open the Login popup #86

Open
ambal1330 opened this issue Dec 16, 2021 · 21 comments
Open

Azure login not working - Unable to open the Login popup #86

ambal1330 opened this issue Dec 16, 2021 · 21 comments

Comments

@ambal1330
Copy link

HI,

We have created a Cordova app with Framework 7 version 2. Working on enabling Azure MFA authentication, Installed the Codova-plugin-msal. Given below configuration. Gave the tenent_id, cliend_id & Signature has value during the plugin installation. Still it is not working MSALInit is not working, Please help me on this .

var defaultOptions1 = {
authorities: [
{
type: 'AAD',
audience: 'AzureADMyOrg',
authorityUrl: '',
cloudInstance: 'MSALAzurePublicCloudInstance',
default: true
}
],
authorizationUserAgent: 'DEFAULT',
multipleCloudsSupported: false,
brokerRedirectUri: true,
accountMode: 'SINGLE',
scopes: ['User.Read']
};

window.cordova.plugins.msalPlugin.msalInit(function() {
alert('msalInit');
},
function (err) {
alert('msalInit' + err);

}, defaultOptions1);

window.cordova.plugins.msalPlugin.signInInteractive(
function(resp) {
alert(resp);
},
function(err) {
}
);

@ambal1330
Copy link
Author

@wrobins could you please help on this query

@wrobins
Copy link
Owner

wrobins commented Dec 20, 2021

Hi @ambal1330,

Sorry this is giving you trouble! Would you mind sharing what platform you're running (Android or iOS) and any error that MsalInit() is giving you?

Thanks for your patience and hopefully we can figure out what's going on!

@ambal1330
Copy link
Author

ambal1330 commented Dec 22, 2021

@wrobins
We have android & IOS . But currently trying in Android.
I am not getting any error in msinit()

But in signInInteractive function getting be low error.

it is giving that "No configuration has been set yet"

image

@ambal1330
Copy link
Author

@wrobins can you help me on this?

@a619sachin
Copy link

@wrobins can you help me on this?

Same issue, msalinit just getting skipped and not getting any errors.

@a619sachin
Copy link

a619sachin commented Jan 4, 2022

@ambal1330 can you show the list of plugins used in your cordova project? I think some other plugin is causing the issue.

Edit: @wrobins I tested using a sample app installing plugins one by one, I found issue with deeplink plugin if I add the deeplink <universal-links> host url </universal-links>, msal won't work. Plugin : https://github.com/e-imaxina/cordova-plugin-deeplinks

@ambal1330
Copy link
Author

@wrobins I am using plain instance having only below Plugins

image

@ambal1330
Copy link
Author

@wrobins please help on this

@a619sachin
Copy link

@ambal1330 can you show the list of plugins used in your cordova project? I think some other plugin is causing the issue.

Edit: @wrobins I tested using a sample app installing plugins one by one, I found issue with deeplink plugin if I add the deeplink <universal-links> host url </universal-links>, msal won't work. Plugin : https://github.com/e-imaxina/cordova-plugin-deeplinks

Hello, does anyone know the workaround for this issue?
@wrobins @@peitschie @kratz00 @ambal1330

@peitschie
Copy link
Contributor

@a619sachin are you using the current master, or the (quite old) package released on NPM?

@a619sachin
Copy link

@peitschie I installed using CLI.

@peitschie
Copy link
Contributor

@a619sachin try using master instead: cordova plugin add https://github.com/wrobins/cordova-plugin-msal.git

@a619sachin
Copy link

a619sachin commented Mar 1, 2022

@peitschie Okay, will try it.

@a619sachin
Copy link

@peitschie Okay, will try it.

@peitschie tried it, still same issue.

@ambal1330
Copy link
Author

HI All, Any update on this issue.

@a619sachin
Copy link

HI All, Any update on this issue.

No, I used other plugin. That's the only workaround I found.

@ambal1330
Copy link
Author

@a619sachin What is the another plugin?

@peitschie
Copy link
Contributor

@ambal1330 do you have any allowed intents annotated in your config.xml? The SSO pattern that MSAL uses launches an external http request I believe, so you probably need to allow the intent through so cordova enables the external browser to launch.

See https://cordova.apache.org/docs/en/11.x/guide/appdev/allowlist/index.html#intent-allow-list

To test this (do NOT use this in production, as it allows any url to be launched, which is a security risk!!!!) would be to add something like this in your config.xml under the root widget section:

<widget ...>
  ... existing config ...
  <allow-intent href="http://*/*" />
  <allow-intent href="https://*/*" />
</widget>

If this allows the window to open, you're on the right path, and just need to figure out the right URLs to allow to keep your app secure but still allow login via SSO.

@zailleh
Copy link
Contributor

zailleh commented Mar 13, 2023

I modified the java to output the error since it wasn't visible to me anywhere prior, the error I am getting is:

com.microsoft.identity.client.exception.MsalClientException: Intent filter for: BrowserTabActivity is missing.  Please make sure you have the following activity in your AndroidManifest.xml


<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
	<intent-filter>
		<action android:name="android.intent.action.VIEW" />
		<category android:name="android.intent.category.DEFAULT" />
		<category android:name="android.intent.category.BROWSABLE" />
		<data
			android:host="app.name"
			android:path="/HASH_KEY"
			android:scheme="msauth" />
	</intent-filter>
</activity>

I can confirm the intent is not there in the generated manifest file and I have the generated config in package.json with the hash key, so something is causing the intent to not be added to the manifest file.

@peitschie
Copy link
Contributor

@zailleh are you using cordova or capacitor?

@zailleh
Copy link
Contributor

zailleh commented Mar 14, 2023

@zailleh are you using cordova or capacitor?

@peitschie I'm using cordova.

I confirmed what @a619sachin said about https://github.com/e-imaxina/cordova-plugin-deeplinks.

That plug-in's afterPrepareHook wipes out all <intent> tags (see source here).

Due to another bug in that plugin I discovered recently with a dependancy issue, I've forked it and I'm putting in a fix for it in our version that only removes intents from the mainActivity which solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants