0

I have ASP.NET Core 2.0 project where I am using my custom Authroization logic by Implementing AuthorizeAttribute so when I am adding in startup.cs as below

services.AddMvc(options =>
{
    options.Filters.Add(new AuthorizeFilter(Configuration, IBussinessAuthLogic));
});

But I want to enable specific endpoint for authorization but how can I pass an instance of the interface in using [Authorize]?

poke
  • 307,619
  • 61
  • 472
  • 533
user1480180
  • 79
  • 1
  • 6
  • 6
    You should read a basic ASP.NET Core Authorization tutorial (the ones on Microsoft Docs are pretty good). You are not supposed, at all, to create a custom Authorize attribute. Create and apply policies instead. – Camilo Terevinto Dec 20 '17 at 19:31
  • Here is the documentation that shows you how to implement policy-based authorization: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies – Gabriel Luci Dec 20 '17 at 20:39
  • You need to register *policies* which you can then refer to with the authorize attribute. – poke Dec 20 '17 at 21:14

0 Answers0