oauth2授权框架中定义的4种角色和4种权限授予类型

本文的内容均来源于 RFC6749,它描述了 OAuth 2.0 授权框架。
参考链接:https://datatracker.ietf.org/doc/html/rfc6749

1 oauth2授权框架中定义的4种角色

1.1 参考链接

请参考RFC6749的该章节:https://datatracker.ietf.org/doc/html/rfc6749#section-1.1

1.2 原文

OAuth defines four roles:

resource owner
An entity capable of granting access to a protected resource.
When the resource owner is a person, it is referred to as an
end-user.

resource server
The server hosting the protected resources, capable of accepting
and responding to protected resource requests using access tokens.

client
An application making protected resource requests on behalf of the
resource owner and with its authorization. The term "client" does
not imply any particular implementation characteristics (e.g.,
whether the application executes on a server, a desktop, or other
devices).

authorization server
The server issuing access tokens to the client after successfully
authenticating the resource owner and obtaining authorization.

The interaction between the authorization server and resource server
is beyond the scope of this specification. The authorization server
may be the same server as the resource server or a separate entity.
A single authorization server may issue access tokens accepted by
multiple resource servers.

1.3 译文

OAuth 定义了四个角色:

资源所有者
能够授予对受保护资源的访问权限的实体。当资源所有者是一个人时,它被称为终端用户。

资源服务器
托管受保护资源的服务器,能够接受并使用访问令牌响应受保护的资源请求。

客户
是一个应用程序,该应用程序代表资源所有者,根据其持有的授权,发起对受保护资源的请求。“客户”一词并不暗示任何特定的实现特征(例如,应用程序是否在服务器、桌面或其他设备上执行)。

授权服务器
该服务器在验证资源所有者并获得授权成功后,向客户端颁发访问令牌。

授权服务器和资源服务器的交互超出了本规范的范围。授权服务器可以是与资源服务器相同的服务器或单独的实体。一个单一的授权服务器可以发布被接受的访问令牌多个资源服务器。

2 oauth2授权框架中定义的4种权限授予类型

2.1 参考链接

请参考RFC6749的该章节:https://datatracker.ietf.org/doc/html/rfc6749#section-1.3

2.2 原文

Authorization Grant

An authorization grant is a credential representing the resource
owner's authorization (to access its protected resources) used by the
client to obtain an access token. This specification defines four
grant types -- authorization code, implicit, resource owner password
credentials, and client credentials -- as well as an extensibility
mechanism for defining additional types.

spring security 的官方文档的 oauth2 部分(https://docs.spring.io/spring-security/reference/servlet/oauth2/client/core.html#oauth2Client-client-registration),
也有一段类似的描述:
The OAuth 2.0 Authorization Framework defines four Authorization Grant types. The supported values are authorization_code, client_credentials, password, as well as, extension grant type "urn:ietf:params:oauth:grant-type:jwt-bearer".

2.3 译文

权限授予

权限授予是一项代表资源拥有者的权限(用以访问其受保护的资源)的凭据,该凭据用来被客户获取一个访问令牌。
该规范定义了四个授权类型——授权码、隐式、资源所有者密码凭据和客户端凭据 -- 以及定义附加类型的可扩展性机制。

spring security 的官方文档的 oauth2 部分的描述:
OAuth 2.0授权框架定义了4种权限授予类型。分别是:授权码、客户端凭据、密码,以及扩展授予类型:"urn:ietf:params:oauth:grant-type:jwt-bearer" 。

2.4 拓展

其实这4种类型,最终获取的都是 access token,用来作为发起请求时的认证token。
另外,还有一个 refresh token,作用是刷新 access token。该token 在 4种类型中,都是可选的,即可有可无,由具体的业务场景决定。

posted @ 2022-05-17 10:49  mediocrep  阅读(497)  评论(0编辑  收藏  举报
既然选择了远方,便只顾风雨兼程!