Mike Faber
Mike Faber

Reputation: 481

Setup Identity Server For Some Controllers And Not Others In .NET Core Web API

Suppose I had a new .NET Core 2.2 Web API Project with two controllers:

[ApiController]
public class AController : ControllerBase
{
}

[ApiController]
public class BController : ControllerBase
{
}

How can I setup the identity server so that authenticating with a reference token is necessary to hit endpoints on AController, but not BController?

Upvotes: 0

Views: 125

Answers (1)

Vidmantas Blazevicius
Vidmantas Blazevicius

Reputation: 4802

Only add [Authorize] attribute to the controllers you need the users of your api to be authenticated for. Your other controllers won’t require token authentication that way.

Upvotes: 1

Related Questions