Евгений
Евгений

Reputation: 73

how to add Authentication to web api

I already have a ready server on Asp.net WebApi. How can I add authorization to it? I looked through many articles, but everywhere a new project is created and the authorization method is selected there, but I did not find how to add to the existing one.

during creation was selected enter image description here

And I need to add like this but to an existing project. enter image description here

Upvotes: 0

Views: 223

Answers (1)

Raju Dasupally
Raju Dasupally

Reputation: 174

You may want to implement Authorize attribute and decorate each of your API with the same. The authorize attribute gets hit before proceeding to your API logic and you can have your custom logic to check if the caller has the Authorization to access the API.

Authorize attribute example

Upvotes: 1

Related Questions