microsoft-authentication-library-for-js | Microsoft Authentication Library for JS | Azure library
kandi X-RAY | microsoft-authentication-library-for-js Summary
kandi X-RAY | microsoft-authentication-library-for-js Summary
Microsoft Authentication Library (MSAL) for JS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of microsoft-authentication-library-for-js
microsoft-authentication-library-for-js Key Features
microsoft-authentication-library-for-js Examples and Code Snippets
Community Discussions
Trending Discussions on microsoft-authentication-library-for-js
QUESTION
Im trying to provide a global configuration, which is dependent on the user's webbrowser, by using an InjectionToken
. However the declared const cannot be found in the source code on compiling the application. I have seen this pattern work before(1), but I am not sure what I am doing differently. Below is an abstract of my code.
ANSWER
Answered 2022-Apr-08 at 03:16To Create injection token you have to instantiate
QUESTION
I'm working on an SPA which depends on an instance of Identity Server for authenticating users. I need a solution that manages my tokens locally, but Duende (the owners of Identity Server) lean towards a Backend For Frontend (BFF) pattern over Javascript libraries. This isn't going to work for us. Since the original oidc-client that was written by the authors of Identity Server is no longer maintained I've been looking at Javascript alternatives. The most likely candidate would seem to be Microsoft's MSAL.js which is built for Azure AD, but supposedly supports OIDC standards.
From what I can tell, MSAL.js forces you down an offline_access path using refresh tokens to renew security tokens. Even if I don't expressly require an offline_access
scope the library appends one anyway! But my use case doesn't require refresh tokens. Instead I want my client to keep the session on the identity provider fresh using OIDC session mamnagement standards (via the check_session_iframe endpoint exposed by the provider's well-known JSON).
I have found that if I ignore the offline_access
scope requested by the MSAL.js library so my identity provider only issues and ID token and an access token then MSAL continues to work just fine. It even has an ssoSilent
option for explicitly renewing the tokens via a connect/authorize request in a hidden iframe. But as far as I can tell I can't have the library keeping that session fresh via an iframe like the old oidc-client used to.
So given that session management is part of the OIDC specification, and MSAL is supposed to be an OIDC-compliant library, am I missing something here?
...ANSWER
Answered 2022-Feb-09 at 23:32Unfortunately, at this time MSAL.js does not have an API that integrates with the checksession
endpoint. If you would like to see this added, you are welcome to open a PR on our Github.
QUESTION
I am trying to get the perfect structure of config and the authority url for my B2C auth application that will be integrated with Azure and React. I did get this structure for my config file and the auth link is specified as in the comments. but I am not able to get the popup screen and the error says that the authority link is invalid.
...ANSWER
Answered 2022-Jan-13 at 18:14Here is an example authority URL, as per the guide here:
authority: "https://contoso.b2clogin.com/contoso.onmicrosoft.com/Your-B2C-SignInOrSignUp-Policy-Id"
Your code has:
const tenantName = "TenantName";
const signInPolicy = "Plicy_For_SignIn";
const AuthorityUrl = https://${tenantName}/tfp/${tenantName}/${signInPolicy}
Which results into:
https://TenantName/tfp/TenantName/Plicy_For_SignIn
-> that does not conform to the sample.
You need to make it follow this format:
authority: "https://contoso.b2clogin.com/contoso.onmicrosoft.com/Your-B2C-SignInOrSignUp-Policy-Id"
As follows:
const AuthorityUrl = https://${tenantName}.b2clogin.com/tfp/${tenantName}.onmicrosoft.com/${signInPolicy}
QUESTION
We are currently successfully running a Node.js Azure Function App deployed in an App Service in Azure with AAD B2C authentication as backend for a React-based Single-Page Application. User authentication in the SPA is done with Azure AAD B2C, where users obtain a JWT Token which is used as Bearer token for all requests against the backend API. This works great.
Due to different reasons, we now need to dockerize our Function App and move it inside a Kubernetes cluster. This prevents us from using the AAD B2C integration of the Function App in the App Service for protecting the API, hence we need a different approach to validate the Bearer tokens of the requests.
From what we understand, there are two possible options to do this:
- passport.js
- MSAL
passport.js seems to work great for all Express-based apps and is therefore not suitable for us as our Function App is not Express-based. We also had a look at msal-node and various examples using it, but struggle to understand exactly where and how our token validation fits and which (if any) of the examples fits our use case.
Are we looking in the right direction with msal-node and if so, how can we accomplish the task of protecting a containerized Node.js Azure Function App by validating the Bearer token with the AAD B2C?
...ANSWER
Answered 2022-Jan-13 at 12:01We found a working solution. Turns out we were thinking way too complicated and "normal" JWT verification is exactly what we needed to do.
This StackOverflow post describes exactly what we were trying to achieve.
QUESTION
I am using MSALjs to logout a user on my application. When the msalService.logoutRedirect()
is triggered, the page redirects and is logged out. However, my application does not have an "un-guarded" route, thus the redirect after logout (postLogoutRedirectUri
) is set to return to the application's last active page. And when it returns to the application, the MSAL guard automatically finds a valid MS session and logs back in again automatically (after redirects).
If I change the postLogoutRedirectUri
to https://login.microsoftonline.com/common/oauth2/logout
, the logout does work and I am signed out correctly. However, I would like to immediately be prompted to sign back in, which is why I intend on returning to the application so the MsalGuard can prompt sign in.
Per a recent GitHub issue , one of the MSAL contributors said the following:
This is a nuance of how B2C works. By default B2C might not log you out of your federated identity provider when you call the logout endpoint, this is explained in more detail here. I unfortunately don't know enough about B2C configuration to give you a definitive answer but you may need to create a custom policy which redirects to the AAD logout endpoint you mentioned: 'https://login.microsoftonline.com/common/oauth2/logout' as this endpoint is the one that ultimately closes your session with AAD. You can also have B2C pass through your postLogoutRedirectUri to this endpoint so that AAD redirects you back to your application after the logout instead of ending on the "Close this window" screen, if desired.
How can I set this up so the logout is triggered correctly and all sessions are signed out?
Furthermore, if I manually change the metadata of the openid-config to have the "end_session_endpoint"
equal to the microsoftonline logout link from above, the behavior seems to be more in line with what I would expect.
ANSWER
Answered 2022-Jan-07 at 20:31You could send the apps post logout redirect uri to the federated IdPs logout url. You can set the postLogoutRedirectURI in MSAL config object.
And at the federated IdP, set the logout url to the application.
Approach only works if you are using 1 federated IdP, and is the only IdP available.
QUESTION
I believe we have everything mentioned in https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/ie-support.md
We have included a promise polyfill at the top of our index.html:
...ANSWER
Answered 2021-Oct-26 at 07:25For anyone having similar issues:
We were using MSAL-angular v2.0.4 with Angular 6. Having downgraded to MSAL-angular v1.4.0, IE11 works fine.
QUESTION
I have a React SPA which uses msal
. I have configured Azure AD as Identity Provider for my AADB2C. I can signIn/signOut and other operations.
If my user signs out off my application, I want to also sign out of my Identity Provider. I looked a bit into this matter 1, 2, 3, 4, 5.
At this moment, I use msal
's logoutRedirect
method.
ANSWER
Answered 2021-Sep-17 at 19:51You are doing an RP Initiated Logout in OpenID Connect terms, meaning you need to also send the id_token_hint
query parameter.
I can also confirm that sending both query string parameters logs out successfully for my Azure developer account:
QUESTION
I'm implementing security for the applications at the company I'm working at right now. I'm using @azure/msal-angular@2.0.2
, @azure/msal-browser@2.16.1
. I followed the example found here
and got it working for the first application. I went on to implement it for the next application, which is basically the same one, just talks to a different api, but the complexity is the same. After possibly doing something wrong I keep getting the error:
ANSWER
Answered 2021-Aug-19 at 09:34"Workaround" fix
Make your login type Popup. Dumb of me not to think about that
QUESTION
I use https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/configuration.md to setup a single sign-on in angular. So if I click the sign in button then I can login.
My question is that if in other place I already login with my company's credentials so I don't need to login again in the angular application. How my angular application knows I already signed? Therefore I don't need navigation to login component and click sign in button again?
...ANSWER
Answered 2021-Aug-11 at 14:49The msal-browser library provides the following APIs to access cached accounts:
getAllAccounts()
: returns all the accounts currently in the cache. An application must choose an account to acquire tokens silently.getAccountByHomeId()
: receives ahomeAccountId
string and returns the matching account from the cache.getAccountByLocalId()
: receives alocalAccountId
string and returns the matching account from the cache.getAccountByUsername()
: receives a username string and returns the matching account from the cache.[ ... snip ... ]
The current
msal-browser
default sample has a working single account scenario.
Source: Accounts in MSAL Browser.
Part of that example code:
QUESTION
I have implemented SPA in the same way as mentioned here - https://docs.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-javascript-spa#configure-your-javascript-spa
I have changed the code as per - https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp/issues/61#issuecomment-630953375
Still my code is not working IE 11. Only thing which is different from the above code is I am using MSAL 2.13.1.js.
Does 2.*.js works with IE11 ?
Code which I have used is below. It doesnt redirect to the Microsoft login page in IE 11. It works fine in chrome and edge.
...ANSWER
Answered 2021-Jul-12 at 10:54In short: yes. MSAL 2.0 supports IE. It does, however, need a Promise polyfill to do so, which it doesn't include.
What browsers are supported by MSAL.js?
MSAL.js has been tested and supports the last 2 stable and supported versions of the following browsers:
- Chrome
- Edge (Chromium)
- Firefox
- Safari
- Opera
MSAL.js has also been tested and supports the following browsers with Promise polyfills (not included):
- IE 11
- Edge (Legacy)
Information taken from the FAQ: What browsers are supported by MSAL.js?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install microsoft-authentication-library-for-js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page