리소스 서버에 대한 OAuth 2.0 액세스 토큰의 유효성을 검사하는 방법은 무엇입니까?
클라이언트가 리소스 서버에 OAuth 2.0 액세스 토큰으로 보호 된 리소스를 요청하면이 서버는 어떻게 토큰의 유효성을 검사합니까? OAuth 2.0 새로 고침 토큰 프로토콜?
2015 년 11 월 업데이트 : 아래 Hans Z.에 따르면, 이것은 실제로 RFC 7662의 일부로 정의됩니다 .
원래 답변 : OAuth 2.0 사양 ( RFC 6749 )은 액세스 토큰 (AT) 유효성 검사를 위해 RS (Resource Server)와 AS (Authorization Server) 간의 상호 작용을 명확하게 정의하지 않습니다. 그것은 실제로 AS의 토큰 형식 / 전략에 달려 있습니다. 일부 토큰은 자체적으로 포함되어 있으며 ( JSON Web Tokens 과 같은 ) 다른 토큰 은 AS에서 서버 측에 보유한 정보를 참조한다는 점에서 세션 쿠키와 유사 할 수 있습니다.
이 있었다 논의 는 RS는 AT의 검증을 위해 AS와 통신하기위한 표준적인 방법을 만드는에 대한 OAuth는 워킹 그룹이다. : 우리 회사 (핑 신원은) 우리의 상업 OAuth를 AS (PingFederate)에 대한 하나의 접근 방식에 도달했습니다 https://support.pingidentity.com/s/document-item?bundleId=pingfederate-93&topicId=lzn1564003025072.html#lzn1564003025072__section_N10578_N1002A_N10001 . OAuth 2.0을 보완하는 REST 기반 상호 작용을 사용합니다.
구글 웨이
의뢰:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=1/fFBGRNJru1FQd44AzqT3Zg
응창 성가:
{
"audience":"8819981768.apps.googleusercontent.com",
"user_id":"123456789",
"scope":"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
"expires_in":436
}
Microsoft 방식
Github 방식
의뢰:
GET /applications/:client_id/tokens/:access_token
응창 성가:
{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "abc123",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "somehexcode",
"url": "https://api.github.com/users/octocat"
}
}
아마존 방식
Amazon으로 로그인-개발자 안내서 (2015 년 12 월, 21 페이지)
요청 :
https://api.amazon.com/auth/O2/tokeninfo?access_token=Atza|IQEBLjAsAhRmHjNgHpi0U-Dme37rR6CuUpSR...
응답 :
HTTP/l.l 200 OK
Date: Fri, 3l May 20l3 23:22:l0 GMT
x-amzn-RequestId: eb5be423-ca48-lle2-84ad-5775f45l4b09
Content-Type: application/json
Content-Length: 247
{
"iss":"https://www.amazon.com",
"user_id": "amznl.account.K2LI23KL2LK2",
"aud": "amznl.oa2-client.ASFWDFBRN",
"app_id": "amznl.application.436457DFHDH",
"exp": 3597,
"iat": l3ll280970
}
An update on @Scott T.'s answer: the interface between Resource Server and Authorization Server for token validation was standardized in IETF RFC 7662 in October 2015, see: https://tools.ietf.org/html/rfc7662. A sample validation call would look like:
POST /introspect HTTP/1.1
Host: server.example.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer 23410913-abewfq.123483
token=2YotnFZFEjr1zCsicMWpAA
and a sample response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"active": true,
"client_id": "l238j323ds-23ij4",
"username": "jdoe",
"scope": "read write dolphin",
"sub": "Z5O3upPC88QrAjx00dis",
"aud": "https://protected.example.net/resource",
"iss": "https://server.example.com/",
"exp": 1419356238,
"iat": 1419350238,
"extension_field": "twenty-seven"
}
Of course adoption by vendors and products will have to happen over time.
OAuth 2.0 spec doesn't define the part. But there could be couple of options:
When resource server gets the token in the Authz Header then it calls the validate/introspect API on Authz server to validate the token. Here Authz server might validate it either from using DB Store or verifying the signature and certain attributes. As part of response, it decodes the token and sends the actual data of token along with remaining expiry time.
Authz Server can encrpt/sign the token using private key and then publickey/cert can be given to Resource Server. When resource server gets the token, it either decrypts/verifies signature to verify the token. Takes the content out and processes the token. It then can either provide access or reject.
OAuth v2 specs indicates:
Access token attributes and the methods used to access protected resources are beyond the scope of this specification and are defined by companion specifications.
My Authorisation Server has a webservice (SOAP) endpoint that allows the Resource Server to know whether the access_token is valid.
'development' 카테고리의 다른 글
Django 컨텐츠 유형은 정확히 어떻게 작동합니까? (0) | 2020.07.05 |
---|---|
Android에서 logcat 버퍼를 비우는 방법 (복제) (0) | 2020.07.05 |
Twiny를 사용할 때 Python Matplotlib 그림 제목이 축 레이블과 겹칩니다. (0) | 2020.07.05 |
ConfigureServices에서 개발 / 스테이징 / 생산 호스팅 환경을 얻는 방법 (0) | 2020.07.05 |
sizeof (my_arr) [0]이 컴파일되고 sizeof (my_arr [0])과 같은 이유는 무엇입니까? (0) | 2020.07.05 |