Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- services
- .AddAuthentication(options =>
- {
- options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
- options.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
- })
- .AddCookie(options => options.Cookie.Name = "aspnetcorewsfed")
- .AddWsFederation(options =>
- {
- var settings = WebAppSettings.WsFederation;
- if (settings == null)
- {
- throw new InvalidOperationException("WsFederationSettings not set");
- }
- options.MetadataAddress = settings.StsUrl + settings.MetadataPath;
- options.Wtrealm = settings.Realm;
- options.Events.OnRedirectToIdentityProvider += context =>
- {
- if (context.Request.IsAjaxRequest())
- {
- context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
- context.HandleResponse();
- }
- return Task.CompletedTask;
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment