I am using CustomUserService sample of Identity server v3. I added home controller as below - `public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); }
[Authorize]
public ActionResult About()
{
//ViewBag.Message = "Your application description page.";
//return View();
return View((User as ClaimsPrincipal).Claims);
}`
And added 2 views About.cshtml and Index.cshtml. As you see About action has Authorize attribute. So when I navigate to About, I should get redirected to login page of Identity Server V3 however it is not happening so. My complete startup.cs is as follows -
public void Configuration(IAppBuilder app)
{
LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
app.Map("/core", coreApp =>
{
var factory = InMemoryFactory.Create(
clients: Clients.Get(),
scopes: Scopes.Get());
// different examples of custom user services
var userService = new RegisterFirstExternalRegistrationUserService();
//var userService = new ExternalRegistrationUserService();
//var userService = new EulaAtLoginUserService();
//var userService = new LocalRegistrationUserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
var options = new IdentityServerOptions
{
//IssuerUri = "https://idsrv3.com",
IssuerUri = "https://localhost:44333/",
SiteName = "Thinktecture IdentityServer3 - CustomUserService",
//SigningCertificate = LoadCertificate(),
SigningCertificate = Certificate.Get(),
Factory = factory,
CorsPolicy = CorsPolicy.AllowAll,
AuthenticationOptions = new Thinktecture.IdentityServer.Core.Configuration.AuthenticationOptions
{
IdentityProviders = ConfigureAdditionalIdentityProviders,
LoginPageLinks = new LoginPageLink[] {
new LoginPageLink{
Text = "Register",
//Href = "~/localregistration"
Href = "localregistration"
}
}
},
EventsOptions = new EventsOptions
{
RaiseSuccessEvents = true,
RaiseErrorEvents = true,
RaiseFailureEvents = true,
RaiseInformationEvents = true
}
};
coreApp.UseIdentityServer(options);
});
I am using CustomerUserService sample because, I want to use WSfederation. So ADFS wil provide claims to identity server and in turn Identity server should return those claims to About view. Can anyone help me here.
I ran into a similar situation, when there were errors during Identity Server initialization. I turned on logging in Web.config:
http://identityserver.github.io/Documentation/docs/configuration/logging.html
Logs showed me that my certificate's key length was less than 2048 bits. You might have run into a different error which is logged as well.