Coder Social home page Coder Social logo

azure-samples / active-directory-javascript-singlepageapp-dotnet-webapi-v2 Goto Github PK

View Code? Open in Web Editor NEW
67.0 49.0 42.0 1.75 MB

A JavaScript based single page app with a .NET backend that authenticates users for AzureAD, Microsoft personal and work accounts, and more, and calls the backend web api using access tokens, without using any Single Page Application framework

CSS 1.28% JavaScript 17.51% HTML 8.83% C# 72.32% ASP 0.05%
msal azure-active-directory javascript azuread identity js

active-directory-javascript-singlepageapp-dotnet-webapi-v2's Introduction

active-directory-javascript-singlepageapp-dotnet-webapi-v2's People

Contributors

derisen avatar ellvtr avatar jmprieur avatar microsoftopensource avatar msftgits avatar navyasric avatar plamber avatar rwike77 avatar shivbijlani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active-directory-javascript-singlepageapp-dotnet-webapi-v2's Issues

Bluebird Unhandled rejection s@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:29059

How to reproduce:

  1. clone the repository

  2. replace the client id with your own client id

  3. run it and open the website in FireFox 75.0 (64-bit), Windows 10

  4. Try to log in with a personal account.

image

Unhandled rejection s@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:29059
c@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:28565
r</c.createClientInfoDecodingError@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:27489
s@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:82499
r</l.prototype.saveTokenFromHash@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:60262
r</l.prototype.processCallBack@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:49026
r</l.prototype.handleAuthenticationResponse@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:50705
l@https://secure.aadcdn.microsoftonline-p.com/lib/1.1.2/js/msal.min.js:17:68696
@https://localhost:44302/App/Scripts/app.js:15:29
@https://localhost:44302/App/Scripts/app.js:123:2

If I ran it in Edge, I can sign in with my personal account.

OAuthBearerAuthenticationOptions in .NET 4.6 with Azure AD v2

Do you guys have a sample in .NET 4.6 or can give a pointer?

IIssuerSecurityTokenProvider is not longer available in Microsoft.Owin.Security.Jwt. There is now IIssuerSecurityKeyProvider and OpenIdConnectCachingSecurityTokenProvider is no longer compiling.

Therefore I cannot get OAuthBearerAuthenticationOptions working with an Azure AD v2 endpoint on my Web API.

ida::tenant and ida::audience

Hi, I was following the step-by-step but I can't figure out how to get the ida::tenant and ida::audience for the application. It's not described in the "Register the application" section. What am I missing?

_configManager.GetConfigurationAsync().Result causing deadlock situation in OpenIdConnectCachingSecurityTokenProvider.cs file

Below code is like calling an async method in sync context which is a bad practice and causing deadlock with infinite loops.

        _synclock.EnterWriteLock();  --> synchronous lock

            OpenIdConnectConfiguration config = _configManager.GetConfigurationAsync().Result;  --> async method

Could you please update the above code as below to avoid a deadlock situation.

            OpenIdConnectConfiguration config =Task.Run( _configManager.GetConfigurationAsync).Result;

Ida::Tenant not required: No longer the case. Solution.

You will get following exception on trying to authenticate with (in my case) an organization account.

AADSTS50194: Application 'cab0646e-fd4e-4ea9-8eae-68e057d6bf2e'(Azure-Samples_active-directory-javascript-singlepageapp-dotnet-webapi-v2) is not configured as a multi-tenant application. Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.

If you have the same problem you can do the following:

Find the TenantId on the overview of your registered app:

image

Then do the following in code:

image

image

image

Unhandled rejection AADSTS700054: response_type 'id_token' is not enabled for the application.

Hello,
trying to run the sample code against Azure AD B2C returns the error:

Unhandled rejection AADSTS700054: response_type 'id_token' is not enabled for the application.

The reasons seems to be that Azure AD B2C applications , while they do have a configuration setting to "Enable Implicit Flow" Yes/No (I configured "yes"), do not have a setting to enable the "ID Token" like Azure AD apps do.

Couple of questions:

  • Is this an error of this sample code, or is this sample code not supporting Azure AD B2C?
  • I noticed that the MSAL.js library linked here is older than the current available 1.1.1. I tried updating, but other issues show up in the code, so I believe this may be a breaking change. Would updating the sample to support a more recent MSAL.js library resolve the issue?

Thank you

Validate issuer signing key?

In this repo, the only token validation is based on Audience:

            var tvps = new TokenValidationParameters
            {
                // In this app, the TodoListClient and TodoListService
                // are represented using the same Application Id - we use
                // the Application Id to represent the audience, or the
                // intended recipient of tokens.

                ValidAudience = ConfigurationManager.AppSettings["ida:Audience"],

                // In a real application, you might use issuer validation to
                // verify that the user's organization (if applicable) has
                // signed up for the app.  Here, we'll just turn it off.

                ValidateIssuer = false,
            };

Is this actually secure? For a production app should we also be validating IssuerSigningKey as well? Or is that not necessary because the key is signed with a public/private key pair?

Thank you

AADSTS50194: Application not configured as a multi-tenant application.

Hi,

I am getting this error:
AADSTS50194: Application is not configured as a multi-tenant application. Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.

I changed this to
AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider("https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration")),

to
AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider("https://login.microsoftonline.com/MYTENANTID/v2.0/.well-known/openid-configuration")),

But still get an error, does this work with the latest app registration feature in AD?

Please offer guidance for ADFS + OpenID Connect

I have been searching for hours and am unable to find clear guidance on how to use ADAL.js with ADFS (v4+ with openid connect) with a SPA. Please provide some kind of translation matrix for parameters and configuration values to allow use to use ADFS in the place of AAD.

You make it a point to claim ADFS compatibility but make it very hard for the rest of us to verify this statement.

DB Could Not be Created

System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Directory lookup for the file "D:\Projects\Sample Apps\active-directory-javascript-singlepageapp-dotnet-webapi-v2-master\TodoSPA\App_Data\TodoListServiceContext.mdf" failed with the operating system error 2(The system cannot find the file specified.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Source=.Net SqlClient Data Provider

.net core 2.0 support

The server side is based on .net framework 4.5. Many of these extension methods are not anymore avialable in .net core 2.0. Would be nice to have a sample web api running on .net core 2.0 backend. Is samples somewhere I can find (if not any plan to provide such) ?

Nice clean sample to understand and follow, BTW. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.