コンテンツにスキップ

SCIM 2.0

SCIM 2.0 ユーザープロビジョニング

Section titled “SCIM 2.0 ユーザープロビジョニング”

Authrimは、自動化されたユーザーおよびグループプロビジョニングのためにSCIM 2.0(System for Cross-domain Identity Management)をサポートしています。

  • 標準: RFC 7643(コアスキーマ), RFC 7644(プロトコル)
  • ステータス: 完全実装
  • ベースURL: /scim/v2
  • ユーザーCRUD操作(作成、読み取り、更新、削除)
  • グループCRUD操作
  • Discoveryエンドポイント: /ServiceProviderConfig, /ResourceTypes, /Schemas
  • /BulkによるBulk操作
  • SCIMクエリ構文によるフィルタリング
  • startIndexcountによるページネーション
  • ETagによるリソースバージョニング
  • PATCH操作による部分更新
  • Enterprise User拡張
  • Bearerトークン認証

SCIMプロビジョニングリクエストにはBearerトークンが必要です:

Authorization: Bearer YOUR_SCIM_TOKEN

/scim/v2/ServiceProviderConfig/scim/v2/ResourceTypes/scim/v2/Schemas配下のDiscoveryエンドポイントは、SCIMクライアントがサーバー機能を検出できるようBearerトークンなしで利用できます。

  1. Admin UI > SCIMトークンに移動、またはPOST /api/admin/scim-tokensを呼び出す
  2. 説明を入力(例:「Okta SCIM統合」)
  3. expiresInDaysを設定(デフォルト: 365、最大: 3650)
  4. トークンをすぐにコピー(再表示されません)

Admin APIエンドポイント:

MethodEndpoint説明
GET/api/admin/scim-tokensSCIMトークンメタデータを一覧取得
POST/api/admin/scim-tokensSCIMトークンを作成
DELETE/api/admin/scim-tokens/{tokenHash}SCIMトークンを失効
GET /scim/v2/Users

クエリパラメータ:

パラメータ説明
filterstringSCIMフィルター式userName eq "john@example.com"
sortBystringソート属性userName
sortOrderstringascendingまたはdescendingascending
startIndexinteger1ベースのページネーションインデックス1
countinteger結果数(最大1000)100

レスポンス:

{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
"totalResults": 250,
"startIndex": 1,
"itemsPerPage": 100,
"Resources": [
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"id": "user-123",
"userName": "john@example.com",
"name": {
"givenName": "John",
"familyName": "Doe"
},
"emails": [{"value": "john@example.com", "primary": true}],
"active": true,
"meta": {
"resourceType": "User",
"created": "2024-01-01T00:00:00Z",
"lastModified": "2024-01-02T00:00:00Z",
"location": "https://auth.example.com/scim/v2/Users/user-123",
"version": "W/\"1704153600000\""
}
}
]
}
POST /scim/v2/Users
Content-Type: application/json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "john@example.com",
"name": {
"givenName": "John",
"familyName": "Doe"
},
"emails": [{"value": "john@example.com", "primary": true}],
"active": true
}
PATCH /scim/v2/Users/{id}
Content-Type: application/json
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations": [
{"op": "replace", "path": "name.givenName", "value": "Jane"},
{"op": "replace", "path": "active", "value": false}
]
}

サポートされる操作:

  • add - 新しい属性を追加
  • replace - 既存の属性を置換
  • remove - 属性を削除
DELETE /scim/v2/Users/{id}
GET /scim/v2/Groups
POST /scim/v2/Groups
Content-Type: application/json
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"],
"displayName": "Engineering",
"members": [
{"value": "user-123", "type": "User"}
]
}
GET /scim/v2/ServiceProviderConfig
GET /scim/v2/ResourceTypes
GET /scim/v2/Schemas
GET /scim/v2/Schemas/{schemaId}

ServiceProviderConfigでは、PATCH、Bulk、フィルタリング、ソート、ETag、OAuth Bearer token認証の対応状況を公開します。

POST /scim/v2/Bulk
Content-Type: application/scim+json
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:BulkRequest"],
"Operations": [
{
"method": "POST",
"bulkId": "user1",
"path": "/Users",
"data": {
"userName": "jane@example.com",
"active": true
}
}
]
}

Bulkのデフォルト上限は100 operations、1 MB payloadです。KVのSCIM_BULK_MAX_OPERATIONSSCIM_BULK_MAX_PAYLOAD_SIZEで変更できます。

SCIMは標準化されたクエリ構文を使用した複雑なフィルタリングをサポートしています。

演算子説明
eq等しいuserName eq "john@example.com"
ne等しくないactive ne false
co含むuserName co "john"
swで始まるuserName sw "john"
ewで終わるuserName ew "example.com"
pr存在するphoneNumber pr
gtより大きいmeta.created gt "2024-01-01"
ltより小さいmeta.created lt "2024-12-31"
演算子説明
and論理ANDuserName eq "john" and active eq true
or論理ORuserName eq "john" or userName eq "jane"
not論理NOTnot (active eq false)
Terminal window
# メールでユーザーを検索
GET /scim/v2/Users?filter=userName eq "john@example.com"
# アクティブなユーザーを検索
GET /scim/v2/Users?filter=active eq true
# 複合フィルター
GET /scim/v2/Users?filter=(userName co "john" or userName co "jane") and active eq true

SCIMはstartIndexcountパラメータで1ベースのページネーションを使用します。

Terminal window
# 最初のページ(アイテム1-100)
GET /scim/v2/Users?startIndex=1&count=100
# 2番目のページ(アイテム101-200)
GET /scim/v2/Users?startIndex=101&count=100

リソースバージョニング(ETag)

Section titled “リソースバージョニング(ETag)”

SCIMは楽観的同時実行制御のためにETagをサポートしています:

# ETag付きでユーザーを取得
GET /scim/v2/Users/user-123
Response: ETag: W/"1704153600000"
# ETag付きで更新
PUT /scim/v2/Users/user-123
If-Match: W/"1704153600000"
{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"],
"status": "400",
"scimType": "invalidValue",
"detail": "userNameは必須です"
}
scimTypeHTTPステータス説明
invalidFilter400無効なフィルター構文
invalidValue400無効な属性値
uniqueness409リソースが既に存在
mutability400読み取り専用属性の変更試行
noTarget404リソースが見つからない
invalidVers412ETag不一致
  1. Authrim Admin UIでSCIMトークンを生成
  2. Oktaアプリを設定:
    • SCIM Base URL: https://YOUR_DOMAIN/scim/v2
    • 認証: HTTPヘッダー
    • Authorization: Bearer YOUR_TOKEN
  3. プロビジョニングを有効化:
    • ユーザー作成
    • ユーザー属性更新
    • ユーザー無効化
SCIM属性Authrim canonical storage
ididentity_accounts.legacy_user_id projectionstring(読み取り専用)
externalIdidentity_accounts.external_idstring
userNamepreferred_username sensitive attribute、なければprimary emailstring(必須)
name.givenNameprofile_attribute_values + identity_sensitive_valuesstring
name.familyNameprofile_attribute_values + identity_sensitive_valuesstring
emails[primary].valuecontact_points + identity_sensitive_valuesstring(必須)
phoneNumbers[primary].valuecontact_points + identity_sensitive_valuesstring
activeidentity_accounts.lifecycle_state projectionboolean
localesensitive profile attributestring
timezonezoneinfo sensitive profile attributestring

SCIMはcanonical runtime identity projectionを通じて読み書きします。PII DBが設定されている場合、PII値はPII DBに保存され、lookup hashやlifecycle stateはcore DBに保持されます。

  • トークンを定期的にローテーション(例:90日ごと)
  • 統合ごとに別々のトークンを使用
  • 監査ログでトークン使用状況を監視
  • すべてのSCIMリクエストにHTTPSを使用
  • フィルタリングを使用してレスポンスサイズを削減
  • 大きなデータセットにページネーションを実装
  • 不要な更新を避けるためにETagを使用
  • 指数バックオフでリトライロジックを実装
  • 429(レート制限)レスポンスを処理
  • トラブルシューティングのためにすべてのエラーをログ
  • 通常のSCIM操作は設定済みのmoderate rate-limit profileを使用
  • /scim/v2/Bulkは設定済みのstrict rate-limit profileを使用
  • 超過時は429 Too Many Requestsを返し、可能な場合はRetry-Afterヘッダーを含める