Authorizing users
Authentication and authorization are two of the main concepts of information security. If authentication is a way to prove that an entity is who they say they are, then authorization is a way to give rights to the entity. One entity might be able to modify some resources, one entity might be able to modify all resources, one entity might only be able to see limited resources, and so on.
In the previous section, we implemented authentication concepts such as login and CurrentUser
; now it's time to implement authorization. The idea is that we make sure logged-in users can only modify their own information and posts.
Please keep in mind that this example is very simple. In more advanced information security, there are more advanced concepts, such as role-based access control. For example, we can create a role called admin
, we can set a certain user as admin
, and admin
can do everything without restrictions.
Let's try implementing simple authorization...