Comments (7)
I have been able to update this project to .NET Core 2.1 so it is possible. If I compare my update with the 2.0 version I see one difference in StartUp.ConfigureServices. The 2.0 code looks like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddAzureAd(options => Configuration.Bind("AzureAd", options))
.AddCookie();
services.AddMvc();
// This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.
services.AddMemoryCache();
services.AddSession();
// Add application services.
//services.AddSingleton<IConfiguration>(Configuration);
services.AddSingleton<IGraphAuthProvider, GraphAuthProvider>();
services.AddTransient<IGraphSdkHelper, GraphSdkHelper>();
}
And my updated version to 2.1 looks like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddAzureAd(options => Configuration.Bind("AzureAd", options))
.AddCookie();
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
//services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
// .AddAzureAD(options => Configuration.Bind("AzureAd", options));
services.AddMvc(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.
services.AddMemoryCache();
services.AddSession();
// Add application services.
//services.AddSingleton<IConfiguration>(Configuration);
services.AddSingleton<IGraphAuthProvider, GraphAuthProvider>();
services.AddTransient<IGraphSdkHelper, GraphSdkHelper>();
}
Maybe that helps a bit. Otherwise I see no significant changes to the code.
from aspnetcore-connect-sample.
Worked for me, thanks @pekspro !
from aspnetcore-connect-sample.
Also guidance on how to trap and log the errors is ideal. (how would I handle tracing this in production?)
from aspnetcore-connect-sample.
Hi @ZeroPKI
It would be great to have the logs from the app. On localhost you can check the logs in VisualStudio. In a published app on Azure you can use the Diagnostic logs feature of Web Apps. To check what the tokens are doing between login.microsoftonline.com and your app, you can use fiddler for example.
from aspnetcore-connect-sample.
@pekspro pull requests are welcomed! 😉
from aspnetcore-connect-sample.
@mark-szabo, OK :-) I created PR #22
from aspnetcore-connect-sample.
Merged #22
from aspnetcore-connect-sample.
Related Issues (20)
- Configuring for single tenant HOT 2
- Access denied when trying to get mail messages HOT 2
- ConfidentialClientApplication.AcquireTokenForClientAsync(IEnumerable<string>)' is obsolete HOT 2
- Authentication success, but after redirect to site Getting the error page - Azure app service HOT 2
- The profile picture is not loading and getting access denied error. HOT 1
- User not found in token cache HOT 6
- Supported account types issue HOT 1
- Needs updating to MSAL v4.0
- Application using http vs https HOT 3
- Unable to get access token HOT 12
- Transient creation of GraphServiceClient HOT 2
- build failed HOT 1
- Restart IIS in production returns error if user is logged in HOT 3
- After signin in to AAD - Exception: Correlation failed. HOT 2
- Code is not usable in a deployed web app. HOT 6
- Release version for production env HOT 3
- Single tenant - Guest Account login error - Null Token HOT 2
- Retrieve user groups in Startup.cs HOT 1
- Error when running application (single-tenant vs multi-tenant) HOT 3
- This repo is missing important files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetcore-connect-sample.