I am currently launching several issues related to porting my MVC application from beta 3 to 4 - one of them is related to OpenIdConnect for Windows Azure for authentication. When I go to the page with the Authorize attribute, the page stops processing and sits on a blank white page without raising the Azure login page. I do not get YSOD - just a blank screen. As for the sample code, I could only find them:
https://github.com/aspnet/Security/blob/5cf0564484cf5bb2a7a16e6485816d19287538e6/samples/OpenIdConnectSample/Startup.cs
https://github.com/aspnet-contrib/AspNet.Sconte/AspNet.Scont OpenIdConnect.Server / blob / vNext / samples / Mvc / Mvc.Client / Startup.cs
If I use the second example and actually use the ChallengeResult in another controller, it calls the Azure login page, but returns Bad Request (400) from Azure.
This is my current code:
public void ConfigureServices(IServiceCollection services)
{
services.AddWebEncoders();
services.AddDataProtection();
services.Configure<ExternalAuthenticationOptions>(options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationType;
});
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
app.UseCookieAuthentication(options => {
options.AutomaticAuthentication = true;
});
app.UseOpenIdConnectAuthentication(options =>
{
options.ClientId = Constants.ClientId;
options.Authority = Constants.Authority;
options.PostLogoutRedirectUri = Constants.PostLogoutRedirectUri;
options.TokenValidationParameters.RoleClaimType = "roles";
options.Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthorizationCodeReceived = async (context) =>
{
var code = context.Code;
ClientCredential credential = new ClientCredential(Constants.ClientId, Constants.AppKey);
AuthenticationContext authContext = new AuthenticationContext(Constants.Authority, false);
var result = await authContext.AcquireTokenByAuthorizationCodeAsync(
code, new Uri(Constants.PostLogoutRedirectUri), credential, Constants.GraphUri);
ActiveDirectoryHelper.token = result.AccessToken;
}
};
});
}
PS Does anyone have useful resources for MVC 6? I tried GitHub for most of my Beta 4 code.
source
share