在web应用程序中有什么不同?我经常看到缩写“auth”。它是代表认证还是授权?或者两者都有?


当前回答

假设你注册了一个技术会议。你到了,走到外面的登记桌前领取你的会议徽章。你必须先出示某种形式的身份证明,比如驾照。你的驾照可以识别你的身份(比如你的照片),并由一个受信任的实体(车管所)分发。这就是身份验证。

工作人员将你的徽章交给你,徽章是红色、蓝色或绿色的。在会场内走一圈,你会发现一些展品都是用颜色标注的。有了绿色徽章,您可以进入绿色的展品,但不能进入蓝色或红色的展品。徽章不是由DMV分发的,而是由会议本身分发的,用于访问会议厅内的会议资源。

徽章上不一定有任何可以识别你的东西(徽章上可能印着你的名字,但你可以很容易地借用你朋友的蓝色徽章去参观蓝色展览——没有人会检查你的名字,只有蓝色)。你徽章的颜色允许你进入展品。这就是授权。

其他回答

我发现这篇文章中的类比对我很有帮助。

Consider a person walking up to a locked door to provide care to a pet while the family is away on vacation. That person needs: Authentication is in the form of a key. The lock on the door only grants access to someone with the correct key in much the same way that a system only grants access to users who have the correct credentials. Authorization is in the form of permissions. Once inside, the person has the authorization to access the kitchen and open the cupboard that holds the pet food. The person may not have permission to go into the bedroom for a quick nap.

因此,简而言之,认证是关于用户身份的,而授权是关于用户权限的。

身份验证是验证所宣布的身份的过程。

例如,用户名/密码

通常接下来是授权,也就是批准你可以这样做或那样做。

如权限

身份验证是确定某人确实是他们所声称的那个人的过程。 授权是指决定谁可以做什么的规则。例如,亚当可能被授权创建和删除数据库, 而Usama只被授权阅读。

这两个概念是完全正交和独立的,但它们都是安全设计的核心,如果其中任何一个概念都不正确,就会导致妥协。

就web应用程序而言,简单地说,身份验证是指你检查登录凭证,看看你是否识别出用户已登录,而授权是指你在访问控制中查看是否允许用户查看、编辑、删除或创建内容。

认证是验证实体身份的过程。例如

Webserver每次都要求用户输入登录名/密码,以验证创建该帐户的用户是否是现在正在访问该帐户的用户。

授权是允许每个实体获得所需数量的服务/资源的过程。例如

On blogging site (eg. medium.com) users can create an account and write a post and publish. And users can read all posts published by others as well. Here the blogging server first authenticates the user with the user login credentials (login/password) and then it authorizes to read all others post and write/modify the post only created by the user. Here authorization is used by the server to limit which all post each user can modify. Users can create a free google account by which google server provides free services like mail, calendar, chat, drives etc. But the storage provided for all these services to free users are 15GB (as of now). User can pay a monthly or annual fee to google server to increase the storage space. Here google server authorizes every authenticated user to limit the amount of resource usage.

在当今的互联网中,授权被广泛用于对客户端施加访问限制。

混淆是可以理解的,因为这两个词听起来很相似,而且概念经常密切相关并一起使用。此外,如前所述,常用的缩写Auth也没有帮助。

其他人已经很好地描述了身份验证和授权的含义。这里有一个简单的规则来帮助区分这两者:

身份验证验证您的身份(或真实性,如果您喜欢) 授权验证您的权限,即您访问和可能更改某些内容的权利。