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


当前回答

身份验证是通过获取某种凭据(例如用户名密码组合)来验证用户身份的过程,并使用这些凭据来验证用户的身份。

授权是通过检查用户是否具有系统访问权限,从而允许经过认证的用户访问其资源的过程。您可以通过向已验证的用户授予或拒绝特定的权限来控制访问权限。因此,如果身份验证成功,则启动授权过程。认证过程始终进行到授权过程。

用于授权的JWT: JWT是一种基于JSON的安全令牌格式,它基本上是一个base64 url编码的字符串,用于传输 保护两个应用程序之间的内容。它们用于保护Web api中的请求数据。这些都包含在授权HTTP报头中,作为承载身份验证方案的一部分。

OAuth代表授权:OAuth不是API或服务:它是授权的开放标准,任何人都可以实现它。有了OAuth,你可以用你的谷歌、Facebook、Twitter或微软账户登录第三方网站,而不需要提供密码。这样你就可以避免在互联网上使用的每个web应用程序上创建帐户和记住密码。

其他回答

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

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.

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

身份验证是验证您的登录用户名和密码的过程。

授权是验证您是否可以访问某些内容的过程。

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

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

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

正如身份验证vs授权所言:

Authentication is the mechanism whereby systems may securely identify their users. Authentication systems provide an answers to the questions: Who is the user? Is the user really who he/she represents himself to be? Authorization, by contrast, is the mechanism by which a system determines what level of access a particular authenticated user should have to secured resources controlled by the system. For example, a database management system might be designed so as to provide certain specified individuals with the ability to retrieve information from a database but not the ability to change data stored in the datbase, while giving other individuals the ability to change data. Authorization systems provide answers to the questions: Is user X authorized to access resource R? Is user X authorized to perform operation P? Is user X authorized to perform operation P on resource R?

参见:

Wikipedia上的身份验证与授权

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

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

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