oidc-client-js icon indicating copy to clipboard operation
oidc-client-js copied to clipboard

Usage with Azure AD

Open wijnsema opened this issue 9 years ago • 8 comments

Hello,

Currently I'm on a project with an existing Azure AD infrastructure. I need to make a Single Page Application which should authenticate with Azure AD and use access tokens to call API's. I have some experience with this oidc-client-js library connecting to a IdentityServer 4 so it is tempting to use it also with Azure AD.

My question is the following:

  • Would the oidc-client-js library work well with Azure AD?
  • How does oidc-client-js compare to adal.js, the (Microsoft) recommended javascript lib for Azure AD?

Thanks in advance,

Ronald Wijnsema

wijnsema avatar Jan 25 '17 09:01 wijnsema

AAD doesn't 100% support the intent of the OIDC spec, so this library might not work 100% easily with it. I have heard of others using it and making it work, though.

brockallen avatar Jan 25 '17 13:01 brockallen

Thanks Brock, I'll go for adal.js then for a start, maybe things get more standardized in the future.

To anyone who was able to make it work already, please share!

Ronald Wijnsema

wijnsema avatar Jan 25 '17 14:01 wijnsema

Could you write what exactly is not supported by AAD?

hmha avatar Jan 30 '17 21:01 hmha

IIRC they don't support CORS on the metadata and userinfo endpoints. also they don't allow certain flows, but i don't recall which combo they don't allow. IIRC i think for implicit they don't allow access tokens and expect you to (incorrectly) use id_tokens to call APIs.

brockallen avatar Jan 30 '17 21:01 brockallen

In the current version of adal.js if the resource is the app it uses the Id token (maybe incorrectly) but otherwise access_token is supported.

dcarr42 avatar May 15 '18 19:05 dcarr42

They seem to have enabled CORS for their jwks endpoint now. Best to switch over or get caught out like we did with a cached copy of the old keys.

Matt-J-Hosking avatar Jul 10 '19 23:07 Matt-J-Hosking

They seem to have enabled CORS for their jwks endpoint now. Best to switch over or get caught out like we did with a cached copy of the old keys.

Can you provide proof if they already enabled CORS? Thnx

hokaido62 avatar Jul 11 '19 08:07 hokaido62

It's really not hard to check - just open: https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration which will give you the JWKS url as: https://login.microsoftonline.com/common/discovery/v2.0/keys which gives the following headers on response now. Access-Control-Allow-Methods: GET, OPTIONS Access-Control-Allow-Origin: *

Not really sure why I should need to provide proof though? Just letting those affected know they should try again...

Matt-J-Hosking avatar Jul 11 '19 09:07 Matt-J-Hosking