> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OAuth Authorization Codes 컬렉션

`oauthAuthorizationCodes`는 OAuth 인가 코드 흐름의 코드를 담기 위한 컬렉션입니다. 코드 하나당 문서 하나이며, 클라이언트는 이 코드를 액세스 토큰으로 교환합니다. 스키마는 `services/web/app/src/models/OauthAuthorizationCode.mjs`이고, 여기에 쓸 코드는 web 모듈 `oauth2-server`에 있습니다. Ayakaleaf Pro에서는 그 코드에 도달하는 경로가 없으므로 컬렉션은 비어 있습니다(참고 참조).

#### 필드

| 필드 | 타입 | 의미 | 출처 |
| - | - | - | - |
| `_id` | ObjectId | 문서 id. | `OauthAuthorizationCode.mjs:6` |
| `authorizationCode` | String | 코드 자체로, 그대로 저장됩니다(해시하지 않음). | `OauthAuthorizationCode.mjs:8`, `services/web/modules/oauth2-server/app/src/OAuth2Model.mjs:280` |
| `expiresAt` | Date | 유효 기간의 끝. 이후 `getAuthorizationCode`가 코드를 거부하고 TTL 인덱스가 삭제합니다. | `OauthAuthorizationCode.mjs:9`, `OAuth2Model.mjs:150-153,281` |
| `oauthApplication_id` | ObjectId | 코드를 요청한 [OAuth Applications](https://ayakaleaf-pro.mintlify.site/ko/dev/data-model/oauth-applications-collection.md)의 클라이언트. | `OauthAuthorizationCode.mjs:10`, `OAuth2Model.mjs:275-284` |
| `redirectUri` | String | 요청의 리디렉션 URI. | `OauthAuthorizationCode.mjs:11`, `OAuth2Model.mjs:282` |
| `scope` | String | 요청된 스코프. | `OauthAuthorizationCode.mjs:12`, `OAuth2Model.mjs:283` |
| `user_id` | ObjectId | 코드를 허가한 사용자. | `OauthAuthorizationCode.mjs:13`, `OAuth2Model.mjs:285` |
| `codeChallenge`, `codeChallengeMethod` | String | PKCE 챌린지와 그 방식. | `OauthAuthorizationCode.mjs:14-15`, `OAuth2Model.mjs:286-287` |

#### 쓰는 코드

| 코드 | 역할 |
| - | - |
| `OAuth2Model.mjs:274-300` (`saveAuthorizationCode`) | 코드를 삽입합니다. 실행되지 않습니다. 참고를 확인하세요. |
| `OAuth2Model.mjs:307-312` (`revokeAuthorizationCode`) | 사용된 코드를 삭제합니다. 실행되지 않습니다. |

#### 읽는 코드

| 코드 | 역할 |
| - | - |
| `OAuth2Model.mjs:137-177` (`getAuthorizationCode`) | 코드를 사용자 및 클라이언트와 함께 불러옵니다. 실행되지 않습니다. |

#### 인덱스

| 이름 | 키 | 옵션 | 마이그레이션 |
| - | - | - | - |
| `expiresAt_1` | `{ expiresAt: 1 }` | TTL, `expireAfterSeconds: 0`, 부분 인덱스: `expiresAt` 존재 | `20230406125632_oauth_tokens_ttl.mjs` |

마이그레이션은 `tools/migrations/`에 있습니다. 고유 인덱스 `authorizationCode_1`은 `saas`와 `server-pro` 태그가 붙은 마이그레이션에서만 만들어지며, Community Edition은 이를 실행하지 않습니다.

#### 참고

* 위 모델 메서드는 `@node-oauth/oauth2-server`의 authorize 및 token 핸들러만 호출합니다. web은 이 라이브러리를 bearer 토큰 검사에만 사용하고(`services/web/app/src/Features/Authentication/AuthenticationController.mjs:409-450`), `/oauth/authorize`나 `/oauth/token`을 제공하는 라우트도 없으므로 코드가 기록되는 일은 없습니다. 개인 액세스 토큰은 직접 생성됩니다. [OAuth Access Tokens](https://ayakaleaf-pro.mintlify.site/ko/dev/data-model/oauth-access-tokens-collection.md)를 참조하세요.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.