본문 바로가기

코딩

OAuth 2.0

728x90
반응형

OAuth2.0 은 Open Authorization 2.0 의 약자로, 애플리케이션이 사용자의 자원(예: 계정 정보, 파일 등)에 접근할 수 있도록 허용하는 인증 및 권한 부여 프레임워크이다.


흐름

1. **클라이언트 요청**: 사용자가 애플리케이션(클라이언트)을 통해 특정 서비스에 접근하려고 할 때, 클라이언트는 인증 서버에 접근 권한을 요청한다.
2. **사용자 인증**: 인증 서버는 사용자를 인증하기 위해 사용자에게 자격 증명(예: 아이디, 비밀번호)을 요구한다. 사용자가 인증되면, 인증 서버는 권한 코드를 생성해 클라이언트에 전달한다.
3. **권한 코드 교환**: 클라이언트는 이 권한 코드를 인증 서버에 다시 보내고, 이에 대한 응답으로 액세스 토큰을 받는다.
4. **리소스 서버 접근**: 클라이언트는 받은 액세스 토큰을 리소스 서버에 제시해 사용자의 데이터를 안전하게 요청하고 접근한다.
5. **토큰 갱신 (선택 사항)**: 액세스 토큰이 만료되면, 클라이언트는 새로 고침 토큰을 사용해 인증 서버에서 새로운 액세스 토큰을 발급받을 수 있다.

이 과정은 사용자가 직접 자격 증명을 공유하지 않아도 되며, 토큰을 통해 안전하게 권한을 관리한다. 그림에서 각 화살표는 데이터 흐름(요청과 응답)을 나타내며, 다양한 서버 간의 상호작용을 보여준다.

 

OAuth 2.0

 

Resource Server

The Resource Server is a fundamental component of the OAuth 2.0 authorization framework. Resource Server is the server that hosts the user’s protected resources. These resources could be anything from user profiles, photos, to other personal data. The Resource Server receives and responds to requests for these resources from client applications. However, it only serves these resources when they are accompanied by a valid, unexpired access token that grants the necessary permissions (or “scopes”). The Resource Server often needs to interact with the Authorization Server to validate these access tokens and ensure they have the appropriate scope for the requested resources.

Here are the primary components and functionalities of the Resource Server:

Resource Server

 

Authorization Server

The Authorization Server is the component that authenticates the user, obtains user consent, issues access tokens to client applications, and optionally refresh tokens. Essentially, it’s the entity that the user interacts with when granting permission to the client application. The Authorization Server also validates the client’s identity before issuing tokens. Depending on the architecture, it can additionally validate the access tokens presented by the client to the Resource Server. Its crucial role makes it the main orchestrator of the OAuth 2.0 flow, ensuring secure and controlled access to the user’s protected resources.

Here are the key components and responsibilities of the Authorization Server:

Authorization Server

 

Client

In OAuth 2.0, the Client is the application that wants to access the user’s account or data, which is hosted on the Resource Server. The client could be a web application, a mobile app, a desktop application, or even a backend server. It initiates the process by directing the user to the Authorization Server for authentication and authorization. Upon successful authorization, the client receives an access token from the Authorization Server, which it then uses to request the user’s data from the Resource Server. Throughout this process, the client does not gain access to the user’s credentials, ensuring a secure interaction.

Here are the key components and responsibilities of a client:

 

Client

 

728x90
반응형

'코딩' 카테고리의 다른 글

SOA and Micro Service  (0) 2025.09.04
SSO; Single Sign On  (0) 2025.09.04
django HTTP Security; Headers, SSL, Session, Cookie  (0) 2025.08.26
Gunicorn 설치 및 설정  (0) 2025.08.26
nginx 설치 및 설정  (0) 2025.08.24