concept/server
OAuth - Client Credentials Grant Type
오연 : Oana
2020. 11. 3. 00:19
educative 를 번역, 요약한 자료입니다.
이 grant type은 기계 대 기계 authorization에 사용된다. 여기서는 유저가 관여하지 않는다.
마이크로 서비스 아키텍처를 따르는 애플리케이션이 있다고 가정해보자. 애플리케이션은 작은 부분으로 나뉘고 각 부분은 별도의 서버에 배포된다.
한 내부 서버가 다른 서버의 일부 데이터에 액세스해야 하는 경우, client credentials grant type을 사용할 수 있다.
Client Credentials grant type working
1단계 : Token request
여기서는 직접 토큰 요청이 있다. 유저가 관여하지 않기 때문에 클라이언트가 직접 HTTP POST 요청을 Authorization 서버로 전송한다.
request query 파라미터는 다음과 같다
1. grant_type
클라이언트 자격 증명을 사용하여 액세스 토큰을 요청하므로 이 매개 변수에는 client_credentials가 포함될 것이다.
2. client_id
client id
3. client_secret
client secret
4. scope
요청되는 리소스를 정의하는 optional 한 파라미터
request의 모습은 다음과 같다
POST /token/endpoint HTTP/1.1
Host: authserver.dummy.com
grant_type=client_credentials
&client_id=12345
&client_secret=gh5Gdkj743HFG45udbfGfs
&scope=images_read
2단계 : Token response
클라이언트 자격 증명이 유효한 경우 인증 서버에서 토큰을 반환한다.
response의 모습은 다음과 같다.
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token":"YT3774ghsghdj6t4GJT5hd",
"token_type":"bearer",
"expires_in":3600,
"refresh_token":"YT768475hjsdbhdgby6434hdh",
"scope":"images_read"
}