Let's answer the following questions to practice what we have learned in this chapter:
- In the Configure method in the Startup class, what is wrong with the following:
public void Configure(...)
{
...
app.UseEndpoints(...);
app.UseAuthentication();
}
- What attribute can be added to a protected action method to allow unauthenticated users to access it?
- We are building an app with an ASP.NET Core backend and using an identity provider to authenticate users. The default audience has been set to http://my-app in the identity provider, and we have configured the authentication service in our ASP.NET Core backend as follows:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme =
JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme =
JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
...