mvertopoulos / vue-msal

Vue plugin for using Microsoft Authentication Library (MSAL)
MIT License
123 stars 66 forks source link

Can't get it to work with Azure AD B2C #15

Closed yasinkavakliat closed 4 years ago

yasinkavakliat commented 4 years ago

Can someone provide me some help in order to get it to work with Azure AD B2C Login? The tutorial in the Readme.md doesn't help to get this to work.

I've changed the mode to spa instead of universal and set the clientId in the Msal.js file that I created.

And then I get this in the console: VM1305:1 GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.0&authorization_endpoint=https://{TENANTNAME}.b2clogin.com/{TENANTNAME}.onmicrosoft.com/{LOGINREGISTERFLOWNAME}/oauth2/v2.0/authorize 400 (Bad Request)

I would also like to have this package to open the login window so I can use NuxtJS still in universal mode if that's possible.

baSSiLL commented 4 years ago

@Coupz I couldn't get it working as well without tweaking the libarary's code. Despite being mentioned in the docs, auth.validateAuthority configuration option is not passed to the constructor of underlying MSAL.UserAgentApplication object. So validateAuthority is always true actually and this leads to bad request response from AAD endpoints.

yasinkavakliat commented 4 years ago

@baSSiLL Did you get it to work with our PR change? I made the changes locally and still get redirected to login.microsoftonline.com when I want to bring my users to b2clogin.com and receive the access token from there.

Why isn't there an easy plug and play for Azure B2C 😠

Evert1976 commented 4 years ago

Hi, I also have the same problem. Is there still no solution for this?

baSSiLL commented 4 years ago

@Coupz I get authentication working. But my app also gets redirected to login.microsoftonline.com eventually which shows a login form. I believe that's how they meant it to work, with b2clogin.com being only a mediator.

ddlaat commented 4 years ago

It took me also a while to find out you have to put your settings like this:

auth = {
  clientId: 'd2e486b0-4e06-43e0-9aaf-620d4c032cf7',
  tenantId: '<your-tenant>.onmicrosoft.com/B2C_1_signup_signin', // <-- policy id
  tenantName: '<your-tenant>.b2clogin.com/tfp', // <-- TFP
  validateAuthority: false
}

Add the /tfp behind the tenantName and add a policy behind the tenantId.

baSSiLL commented 4 years ago

@ddlaat FYI I use tenantName: '<your-tenant>.b2clogin.com'

yasinkavakliat commented 4 years ago

I'm closing this right now, because I've got it to work with the Nuxt-Auth module from Nuxt itself: https://github.com/nuxt-community/auth-module/pull/468

mvertopoulos commented 4 years ago

Duplicate of #11