メインコンテンツまでスキップ

初期登録( ユーザー属性登録)

このドキュメントは、初期登録(ユーザーの属性登録)機能の概要・設定・利用方法及び内部ロジックについて説明するものです。


概要​

初期登録(ユーザー属性登録)は、OpenID Connect 認証フローの中で、ユーザーを新規作成するためのプロセスです。
この機能では、設定に基づき、登録時に必要なユーザー属性(例:メールアドレス、名前、パスワードなど)を柔軟に構成できます。

この登録プロセスは、認可サーバーの /v1/authorizations/{id}/initial-registration エンドポイントを通じて提供され、
prompt=create などの認可リクエストによって開始されます。

また、パスワードのハッシュ化や重複ユーザーの検出など、ユーザー管理における基本的な安全対策も組み込まれています。

テナントは initial-registration の登録を行うことでこの機能を利用することが可能です。

設定​

📘 全体構成​

すべての認証設定は、統一されたinteractions形式を使用します:

{
"id": "UUID",
"type": "initial-registration",
"attributes": {},
"metadata": {},
"interactions": {
"initial-registration": {
"request": {
"schema": {
"type": "object",
"required": [],
"properties": {}
}
}
}
}
}
フィールド説明
id設定ID(UUID)
type"initial-registration" 固定
attributesカスタム属性(オプション)
metadataメタデータ(オプション)
interactionsインタラクション定義

🔧 Request Schema の構成​

interactions.initial-registration.request.schema で、ユーザー登録時に受け付けるフィールドを定義します。

✔ required​

{
"required": [
"email",
"password",
"name"
]
}
  • 登録/更新時に必須となる属性キーの一覧。

🧩 properties​

項目一覧:

項目型説明
namestringEnd-User の表示用フルネーム。肩書きや称号 (suffix) を含むこともある
given_namestring名(Given Name)
family_namestring姓(Family Name)
middle_namestringミドルネーム
nicknamestringニックネーム
preferred_usernamestringEnd-User の選好するユーザー名(例:janedoe)
profilestringプロフィールページのURL
picturestringプロフィール画像のURL
websitestringEnd-User のWebサイトURL
emailstringEnd-User の選好するEmailアドレス
email_verifiedbooleanEmailアドレスが検証済みかどうか
genderstring性別(例:male, female)
birthdatestring生年月日(例:1990-01-01)
zoneinfostringタイムゾーン情報
localestringロケール(例:ja-JP)
phone_numberstring電話番号(E.164形式が推奨)
phone_number_verifiedboolean電話番号が検証済みかどうか
addressobject郵送先住所(JSONオブジェクト)
custom_propertiesobjectカスタムのユーザークレーム(JSONオブジェクト)
passwordobjectパスワード.DB登録時はハッシュ化を行う。

🧩 プロパティ属性​

プロパティごとに属性を定義します。

フィールド説明
typestring, integer, boolean, object, array のいずれか。
itemsarray型の場合の要素の型。
enum許可された値の一覧(例:["male", "female"])。
minLength文字列の最小文字数。
maxLength文字列の最大文字数。
pattern正規表現による文字列制約(例:^[A-Z][a-z]+$)。
formatemail, uuid, uri, date, mobile_phone_number など。
description項目の説明。UIなどで利用可能。

例:

{
"properties": {
"email": {
"type": "string",
"format": "email",
"minLength": 5,
"maxLength": 256,
"description": "ログインに使用するメールアドレス"
}
}
}

🧪 完全な設定例​

情報源: config/examples/e2e/test-tenant/authentication-config/initial-registration/standard.json

{
"id": "609dfa45-b475-4b50-b981-59c2975db2b3",
"type": "initial-registration",
"attributes": {},
"metadata": {},
"interactions": {
"initial-registration": {
"request": {
"schema": {
"type": "object",
"required": [
"email",
"password",
"name"
],
"properties": {
"name": {
"type": "string",
"maxLength": 255
},
"email": {
"type": "string",
"format": "email",
"maxLength": 255
},
"password": {
"type": "string",
"pattern": "^(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()]).+$",
"minLength": 8,
"maxLength": 64
},
"gender": {
"type": "string",
"maxLength": 255
},
"locale": {
"type": "string",
"maxLength": 255
},
"custom_properties": {
"type": "object",
"additionalProperties": true
}
}
}
}
}
}
}

利用方法​

  1. 方式:initial-registration の設定を登録する
  2. 認可リクエスト prompt=create を指定するなどして、signup画面を表示する
  3. 認可画面からinitial-registrationのschema定義に応じたリクエストボディで /v1/authorizations/{id}/initial-registration にリクエストを行う。

🔁 API リクエスト例​

POST /v1/authorizations/1234567890/initial-registration
Content-Type: application/json

{
"email": "user@example.com",
"password": "Secret123!",
"name": "Taro Yamada"
}

内部ロジック​

  1. スキーマ取得 AuthenticationConfigurationQueryRepository.get(tenant, "initial-registration", Map.class) により、テナントごとの属性スキーマ(JSON Schema)を取得。

  2. JSON Schemaバリデーション JsonSchemaValidator によって AuthenticationInteractionRequest の内容を検証。

  3. ユーザー重複チェック すでに登録済みのユーザーがいないかを確認。

  4. ユーザー生成 バリデーション済みの属性から User を生成し、password属性が存在する場合は passwordEncodeDelegation によりパスワードをハッシュ化。

  5. 成功レスポンス生成 認証成功時は user と authentication 情報を含むレスポンスを返却。

  6. バリデーションエラー時 or 重複時 適切な clientError レスポンスと共に user_signup_failure や user_signup_conflict の SecurityEventType を発行。

このように、初期登録ではテナントごとに定義されたJSON Schemaに従って、柔軟に入力項目の構造・制約をカスタマイズできます。

💡 補足事項​

  • additionalProperties: false により、未定義の項目は拒否されます。
  • スキーマは OpenID Connect や OAuth 2.0 におけるユーザー情報(claims)管理と連携可能です。
  • custom_properties により、動的拡張も可能です(管理画面による動的フォーム生成をサポート)。