There are many ways for authentic users, both for web applications and for APIs. There are several standards, or you can write your own authorization / and / or authentication. I would like to point out the difference between authorization and authentication. Firstly, the application must authenticate the user (or api client) from which the request comes. Once the user is authenticated, based on the user identification application, it is necessary to determine which authenticated user has permission to run a specific application (authorization). For most traditional web applications, there is no clear granularity in the security model, therefore, as soon as the user authenticates, he is in most cases also authorized to perform certain actions. However, these two concepts (authentication and authorization) should be like two different logical operations.
In addition, in classic web applications, after authentication and user authorization (mainly by searching for a pair of username and password in the database), authorization and identification information is recorded in the session store. Session storage does not have to be on the server side, since most of the answers above offer it, it can also be stored in a cookie on the client side, encrypted in most cases. For example, the PHP CodeIgniter framework does this by default. There are a number of client-side session security mechanisms, and I don’t see that this way of storing session data is less secure than storing sessionId, which is then viewed in server-side session storage. In addition, storing the client side of the session is quite convenient in a distributed environment, since it eliminates the need to develop a solution (or using an existing one) to manage a central session on the server side.
In addition, authentication with a simple “user password” pair does not have to be performed in any case through a special code that searches for the corresponding user record in the database. For example, a basic authentication protocol or authentication digest . On proprietary software such as the Windows platform, there are also ways to authenticate a user trough, such as ActiveDirectory
Providing a pair of username and password is not only an authentication method, but also the use of the HTTPS protocol, as well as authentication using digital certificates .
In a specific use case when developing a web service that uses the SOAP protocol as a protocol, there is also a WS-Security extension for the SOAP protocol.
With all these words, I would say that the answers to the following question introduce the decision-making procedure for choosing the authorization / authentication mechanism for WebApi:
1) What is the target audience, is it publicly available or only for registered (paid) participants?
2) Whether it is running either * NIX or the MS platform
3) How many users are expected
4) How sensitive is the data API with data (stronger and weaker authentication mechanisms)
5) Is there any single sign-on service that you could use
.. and much more.
Hope this clears the bit, as there are many variables in the equation.