I'm trying to use the IdentityServer3 therefore I'm going over the official examples. I have created an authorization server which is very simple:
namespace SimpleIdentityServer
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var options = new IdentityServerOptions
{
Factory = new IdentityServerServiceFactory()
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
.UseInMemoryUsers(Users.Get()),
RequireSsl = false
};
app.UseIdentityServer(options);
}
}
}
This is my in memory user:
new Client
{
ClientName = "MVC application",
ClientId = "mvc",
Enabled = true,
AccessTokenType = AccessTokenType.Jwt,
Flow = Flows.Implicit,
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
AllowedScopes = new List<string>
{
"openId",
"profile"
},
RedirectUris = new List<string>
{
"http://localhost:12261/"
}
}
Now, I want to use the aforementioned server to authenticate the users of an MVC application, so I have done this:
public void Configuration(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "http://localhost:47945/",
ClientId = "mvc",
RedirectUri = "http://localhost:12261/",
ResponseType = "id_token",
SignInAsAuthenticationType = "Cookies"
});
}
And this is a sample controller action annotated with the Authorize
attribute:
[Authorize]
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
But when I go to home/about in my mvc application it shows me 401 error and it seems (from the serilog) that it doesn't even call the authorization server.