Skip to content

8. ACL기반 컬렉션 공유(Shared Access) API#

Shared Access는 ACL(Access Control List) 기반으로 컬렉션에 대한 접근 권한을 관리하며, 내 컬렉션을 다른 사용자에게 접근 권한을 부여할 수 있다. 컬렉션의 소유자가 특정 사용자에게 권한을 부여하면, 해당 사용자는 {소유자ID}.{컬렉션이름}으로 컬렉션에 접근할 수 있다.

Note

shared=true로 생성된 공유 컬렉션은 Shared Access API의 권한 부여 대상이 아니다.

8.1 권한 부여#

특정 사용자에게 특정 컬렉션에 대한 공유 권한 레벨(permission)을 부여한다.

엔드포인트 :

POST /api/collections/{collectionName}/grant

필요 권한 : CREATE 또는 ADMIN

요청 바디 :

필드 타입 필수 여부 설명
grantTo string 필수 권한을 부여할 사용자 ID
permission string 필수 공유 권한 레벨 (READ, WRITE, ADMIN)
expiresAt datetime 선택 권한 만료 시간 (생략 시, 무기한으로 설정됨)

공유 권한 레벨

권한 설명
READ 문서 조회만 가능
WRITE 문서 조회/생성/수정/삭제 가능
ADMIN 전체 컬렉션 관리 가능

예제#

curl -X POST http://localhost:8080/api/collections/reports/grant \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "grantTo": "userB",
    "permission": "READ",
    "expiresAt": "2025-06-30T23:59:59Z"
  }'

응답 (201 Created):

{
  "ownerUserId": "userA",
  "collectionName": "reports",
  "grantedToUserId": "userB",
  "permissionLevel": "READ",
  "grantedAt": "2025-06-15T10:30:00Z",
  "expiresAt": "2025-06-30T23:59:59Z"
}

8.2 권한 회수#

특정 사용자에게 부여한 권한을 회수한다.

엔드포인트 :

DELETE /api/collections/{collectionName}/grant/{userId}

필요 권한 : DROP 또는 ADMIN

경로 파라미터 :

파라미터 타입 설명 예시
collectionName string 컬렉션의 이름 salesData
userId string 권한을 회수할 사용자 ID reportService

예제#

curl -X DELETE http://localhost:8080/api/collections/reports/grant/userB \
  -H "Authorization: Bearer ${TOKEN}"

응답 (204 No Content): 빈 응답

8.3 부여한 권한 목록 조회#

내가 다른 사용자에게 부여한 권한 목록을 조회한다.

엔드포인트 :

GET /api/collections/grants

필요 권한 : READ 또는 ADMIN

예제#

curl -X GET http://localhost:8080/api/collections/grants \
  -H "Authorization: Bearer ${TOKEN}"

응답 (200 OK):

{
  "grants": [
    {
      "ownerUserId": "userA",
      "collectionName": "reports",
      "grantedToUserId": "userB",
      "permissionLevel": "READ",
      "grantedAt": "2025-06-15T10:30:00Z",
      "expiresAt": "2025-06-30T23:59:59Z"
    }
  ],
  "count": 1
}

8.4 공유받은 컬렉션 목록 조회#

다른 사용자가 현재 사용자에게 공유한 컬렉션 목록을 조회한다.

엔드포인트 :

GET /api/collections/shared-with-me

필요 권한 : READ, ADMIN 또는 SHARED

예제#

curl -X GET http://localhost:8080/api/collections/shared-with-me \
  -H "Authorization: Bearer ${TOKEN}"

응답 (200 OK):

{
  "grants": [
    {
      "expiresAt": "2025-06-30T23:59:59Z",
      "collectionName": "reports",
      "expired": false,
      "ownerUserId": "userA",
      "grantedToUserId": "userB",
      "permissionLevel": "READ",
      "grantedAt": "2025-06-15T10:30:00Z"
    }
  ],
  "count": 1
}

8.5 공유받은 컬렉션 접근#

공유받은 컬렉션은 {소유자ID}.{컬렉션이름} 형식으로 접근한다.

예제#

  • userA로부터 공유받은 reports 컬렉션 조회(userA.reports)
curl -X GET http://localhost:8080/api/collections/userA.reports/documents \
  -H "Authorization: Bearer ${TOKEN}"
  • 공유받은 컬렉션에서 문서 검색
curl -X POST http://localhost:8080/api/collections/userA.reports/documents/search \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "filter": {"region": "APAC"},
    "limit": 50
  }'