一括ユーザーインポートのデータベーススキーマと例
ユーザーファイルには、ユーザーの情報をJSON形式の配列として含める必要があります。
ユーザーのJSONスキーマ
以下のJSONスキーマは有効なユーザーを記述しています。
{
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "The user's email address.",
"format": "email"
},
"email_verified": {
"type": "boolean",
"default": false,
"description": "Indicates whether the user has verified their email address."
},
"user_id": {
"type": "string",
"description": "The user's unique identifier. This will be prepended by the connection strategy."
},
"username": {
"type": "string",
"description": "The user's username."
},
"given_name": {
"type": "string",
"description": "The user's given name."
},
"family_name": {
"type": "string",
"description": "The user's family name."
},
"name": {
"type": "string",
"description": "The user's full name."
},
"nickname": {
"type": "string",
"description": "The user's nickname."
},
"picture": {
"type": "string",
"description": "URL pointing to the user's profile picture."
},
"blocked": {
"type": "boolean",
"description": "Indicates whether the user has been blocked."
},
"password_hash": {
"type": "string",
"description": "Hashed password for the user. Passwords should be hashed using bcrypt $2a$ or $2b$ and have 10 saltRounds."
},
"custom_password_hash": {
"type": "object",
"description": "A more generic way to provide the users password hash. This can be used in lieu of the password_hash field when the users password hash was created with an alternate algorithm. Note that this field and password_hash are mutually exclusive.",
"properties": {
"algorithm": {
"type": "string",
"enum": [
"argon2",
"bcrypt",
"hmac",
"ldap",
"md4",
"md5",
"sha1",
"sha256",
"sha512",
"pbkdf2",
"scrypt"
],
"description": "The algorithm that was used to hash the password."
},
"hash": {
"type": "object",
"properties": {
"value": {
"type": "string",
"description": "The password hash."
},
"encoding": {
"type": "string",
"enum": [
"base64",
"hex",
"utf8"
],
"description": "The encoding of the provided hash. Note that both upper and lower case hex variants are supported, as well as url-encoded base64."
},
"digest": {
"type": "string",
"description": "The algorithm that was used to generate the HMAC hash",
"enum": [
"md4",
"md5",
"ripemd160",
"sha1",
"sha224",
"sha256",
"sha384",
"sha512",
"whirlpool"
]
},
"key": {
"type": "object",
"description": "The key that was used to generate the HMAC hash",
"required": [
"value"
],
"properties": {
"value": {
"type": "string",
"description": "The key value"
},
"encoding": {
"type": "string",
"enum": [
"base64",
"hex",
"utf8"
],
"default": "utf8",
"description": "The key encoding"
}
}
}
}
},
"salt": {
"type": "object",
"properties": {
"value": {
"type": "string",
"description": "The salt value used to generate the hash."
},
"encoding": {
"type": "string",
"enum": [
"base64",
"hex",
"utf8"
],
"default": "utf8",
"description": "The encoding of the provided salt. Note that both upper and lower case hex variants are supported, as well as url-encoded base64."
},
"position": {
"type": "string",
"enum": [
"prefix",
"suffix"
],
"default": "prefix",
"description": "The position of the salt when the hash was calculated. For example; MD5('salt' + 'password') = '67A1E09BB1F83F5007DC119C14D663AA' would have \"position\":\"prefix\"."
}
},
"required": [
"value"
]
},
"password": {
"type": "object",
"properties": {
"encoding": {
"type": "string",
"enum": [
"ascii",
"utf8",
"utf16le",
"ucs2",
"latin1",
"binary"
],
"default": "utf8",
"description": "The encoding of the password used to generate the hash. On login, the user-provided password will be transcoded from utf8 before being checked against the provided hash. For example; if your hash was generated from a ucs2 encoded string, then you would supply \"encoding\":\"ucs2\"."
}
}
},
"keylen" : {
"type": "integer",
"description": "Desired key length in bytes for the scrypt hash. Must be an integer greater than zero. Required when algorithm is set to scrypt."
},
"cost" : {
"type": "integer",
"default": 16384,
"description": "CPU/memory cost parameter used for the scrypt hash. Must be a power of two greater than one. Only used when algorithm is set to scrypt."
},
"blockSize" : {
"type": "integer",
"default": 8,
"description": "Block size parameter used for the scrypt hash. Must be a positive integer. Only used when algorithm is set to scrypt."
},
"parallelization" : {
"type": "integer",
"default": 1,
"description": "Parallelization parameter used for the scrypt hash. Must be a positive integer. Only used when algorithm is set to scrypt."
}
},
"required": [
"algorithm",
"hash"
],
"additionalProperties": false
},
"app_metadata": {
"type": "object",
"description": "Data related to the user that does affect the application's core functionality."
},
"user_metadata": {
"type": "object",
"description": "Data related to the user that does not affect the application's core functionality."
},
"mfa_factors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"totp": {
"type": "object",
"properties": {
"secret": {
"type": "string",
"pattern": "^[A-Z2-7]+$",
"description": "The OTP secret is used with authenticator apps (Google Authenticator, Microsoft Authenticator, Authy, 1Password, LastPass). It must be supplied in un-padded Base32 encoding, such as: JBTWY3DPEHPK3PNP"
}
},
"additionalProperties": false,
"required": [
"secret"
]
},
"phone": {
"type": "object",
"properties": {
"value": {
"type": "string",
"pattern": "^\\+[0-9]{1,15}$",
"description": "The phone number for SMS MFA. The phone number should include a country code and begin with +, such as: +12125550001"
}
},
"additionalProperties": false,
"required": [
"value"
]
},
"email": {
"type": "object",
"properties": {
"value": {
"type": "string",
"format": "email",
"description": "The email address for MFA"
}
},
"additionalProperties": false,
"required": [
"value"
]
}
},
"maxProperties": 1,
"additionalProperties": false
},
"minItems": 1,
"maxItems": 10
}
},
"required": [
"email"
],
"additionalProperties": false
}
Was this helpful?
JSONスキーマの詳細については、jsonschema.orgをご覧ください。
プロパティ
ユーザーは以下のプロパティを使用してインポートすることができます。
プロパティ | タイプ | 説明 | インポート中のアップサート? |
---|---|---|---|
app_metadata |
オブジェクト | アプリケーションの主要な機能またはユーザーがアクセスできるものに影響を与えるデータ。app_metadata に保管されているデータをユーザーは編集できません。これには、サポートプラン、ロール、アクセスグループなどが含まれます。 |
Yes |
blocked |
ブール値 | ユーザーがブロックされているかどうかを示します。 | No |
email |
文字列 | ユーザーのメールアドレス。 | No |
email_verified |
ブール値 | ユーザーがメールアドレスを検証したかどうかを示します。デフォルトでemail がアップサートにより更新され、email_verified でない場合はfalse に設定されます。 |
Yes |
family_name |
文字列 | ユーザーの姓。 | Yes |
given_name |
文字列 | ユーザーの名。 | Yes |
name |
文字列 | ユーザーのフルネーム。 | Yes |
nickname |
文字列 | ユーザーのニックネーム。 | Yes |
picture |
文字列 | ユーザーのプロファイル画像を指すURL | Yes |
user_id |
文字列 | ユーザーの一意の識別子。これは、接続戦略によりプリペンドされます。 | No |
user_metadata |
オブジェクト | 勤務先住所、自宅住所、ユーザーのお気に入りなど、ユーザーのアクセスに影響を与えないデータ。 | Yes |
username |
文字列 | ユーザーのユーザー名。 | No |
password_hash |
文字列 | ユーザーの接続のためにハッシュ化されたパスワード。ユーザーが作成されると、Auth0は[bcrypt](https://auth0.com/blog/hashing-in-action-understanding-bcrypt/)を使用してパスワードを保護します。ハッシュ化されたパスワードをインポートすることで、ユーザーはパスワードを保持できるようになるため、スムーズなエクスペリエンスを提供できます。互換性のあるパスワードは、bcrypt $2a$または$2b$を使ってハッシュ化し、saltRoundsを10回繰り返したものでなければなりません。このプロパティはユーザーが最初にインポートされたときのみ提供され、後で更新できません。 | No |
custom_password_hash |
オブジェクト | ユーザーのパスワードハッシュを提供するより一般的な方法。これは、ユーザーのパスワードハッシュが他のアルゴリズムで作成された場合に、password_hash フィールドの代わりに使用できます。ユーザーが最初にインポートされたcustom_password_hash を使ってログインしなかった場合、一括インポートの処理中にcustom_password_hash を更新できます。 |
Yes |
mfa_factors |
配列 | このユーザーを認証するために使用できるMFA要素 | No |
app_metadata
とuser_metadata
の詳細については、「ユーザープロファイルでのメタデータの使い方」をお読みください。
アプリメタデータ
user.app_metadata
オブジェクトには、以下のいずれのプロパティも含めてはいけません。
__tenant
_id
blocked
clientID
created_at
email_verified
email
globalClientID
global_client_id
identities
lastIP
lastLogin
loginsCount
metadata
multifactor_last_modified
multifactor
updated_at
user_id
カスタムパスワードハッシュ
user.custom_password_hash
オブジェクトは、ユーザーのパスワードハッシュが他のアルゴリズムで作成された場合に、user.password_hash
プロパティの代わりに使用できます。このフィールドとpassword_hash
が相互に排他的であることに注意してください。
user.custom_password_hash
オブジェクトは以下のプロパティに対応しています。
プロパティ | タイプ | 説明 |
---|---|---|
algorithm |
string | パスワードをハッシュするために使用されるアルゴリズム。以下のうちの1つである必要があります:
|
hash |
オブジェクト | |
hash.value |
文字列 | パスワードハッシュ。 |
hash.encoding |
文字列 | 提供されたハッシュのエンコーディング。以下のうちの1つである必要があります:
|
hash.digest |
文字列 | HMACハッシュを生成するために使用されるアルゴリズム。以下のうちの1つである必要があります:
|
hash.key |
オブジェクト | HMACハッシュを生成するために使用される鍵。 |
hash.key.value |
文字列 | 鍵値。 |
hash.key.encoding |
文字列 | 鍵エンコーディング。以下のうちの1つである必要があります:
hash.key.encoding はutf8 です。 |
salt |
object | |
salt.value |
文字列 | ハッシュを生成するために使用されるソルト値。 |
salt.encoding |
文字列 | 提供されたソルトのエンコーディング。以下のうちの1つである必要があります:
salt.encoding はutf8 です。 |
salt.position |
文字列 | ハッシュが計算されたときのソルトの位置。デフォルトで、salt.position はprefix です。 |
password.encoding |
文字列 | ハッシュを生成するために使用されるパスワードのエンコーディング。以下のうちの1つである必要があります:
password.encoding からトランスコードされます。たとえば、ハッシュがucs2 エンコードされた文字列から生成された場合は、次のように設定します: "encoding": 「ucs2" |
keylen |
整数 | スクリプトハッシュのバイト単位での望ましい鍵長。ゼロよりも大きい整数でなければなりません。algorithm がscrypt に設定されている場合、このアルゴリズムが必要です。 |
cost |
整数 | スクリプトハッシュに使用されるCPU/メモリーコストパラメーター。1より大きい2の冪でなければなりません。デフォルトで、cost は16384です。algorithm がscrypt に設定されている場合のみ、このアルゴリズムが使用されます。 |
blockSize |
整数 | スクリプトハッシュに使用されるブロックサイズパラメーター。正の整数でなければなりません。デフォルトで、blockSize は8です。algorithm がscrypt に設定されている場合のみ、このアルゴリズムが使用されます。 |
parallelization |
整数 | スクリプトハッシュに使用される並列化パラメーター。正の整数でなければなりません。デフォルトで、parallelization は1です。algorithm がscrypt に設定されている場合のみ、このアルゴリズムが使用されます。 |
カスタムパスワードハッシュを更新する
ユーザーが最初にインポートされたcustom_password_hash
を使ってログインしなかった場合、一括インポートの処理中にcustom_password_hash
を更新できます。たとえば、以下のJSONは、custom_password_hash
に異なる値を指定して、/api/v2/jobs/users-imports
エンドポイントに2回送信することができます。2回目の送信では、upsert
フラグをtrue
に設定します。
[
{
"user_id": "2000",
"email": "examplecouser20@gmail.com",
"given_name": "ExampleCo User",
"name" : "ExampleCoUser20",
"custom_password_hash": {
"algorithm": "bcrypt",
"hash": {
"value": "$2a$10$aHF7mbpWT6tZ7PJVtwtjNelaKbszikcYBCB2jibvbFcGFmOsu/s4K"
}
}
}
]
Was this helpful?
browserling.comでBcryptパスワードジェネレーターを使用して、bcryptパスワードハッシュを生成することができます。
対応しているハッシュアルゴリズム
Auth0は現在、以下のユーザーパスワードハッシュのインポートに対応しています。
custom_password_hash
を提供する際には、以下のセクションを考慮してください。
Argon2
algorithm
がargon2
に設定されている場合には:
hash.encoding
はutf8
でなければなりません。hash.salt
は使用できません。hash.value
は、GitHubのP-H-C / phc-string-formatで指定されているように、PHC文字列形式でなければなりませんまた、GitHubのAuth0 / magicで指定されている要件に従う必要があります。hash.value
にはbase64エンコードされたソルトが含まれなければなりません(PHC
のドキュメントで指定されています)。
bcrypt
algorithm
がbcrypt
に設定されている場合には:
hash.encoding
はutf8
でなければなりません。hash.salt
は使用できません。hash.value
には以下の1つのプレフィックスが含まれなければなりません。$2a$
$2b$
$2y$
$2$
、$sha1$
や$2x$
など、他のプレフィックスには現在対応していません。
たとえば、次はコストパラメーターの値を10に指定して「hello
」の文字列から生成したものです:
$2b$10$nFguVi9LsCAcvTZFKQlRKeLVydo8ETv483lkNsSFI/Wl1Rz1Ypo1K
algorithm
がhmac
に設定されている場合には:
algorithm
がldap
に設定されている場合には:
HMAC
algorithm
がmd4
、md5
、sha1
、sha256
、またはsha512
に設定されている場合には:
hash.encoding
はhex
またはbase64
でなければなりません。hash.digest
は必須で、以下のいずれかでなければなりません。md4
md5
ripemd160
sha1
sha224
sha256
sha384
sha512
whirlpool
hash.key.value
は必須です。hash.key.encoding
はbase64
、hex
、またはutf8
でなければなりません。
LDAP
algorithm
がpbkdf2
に設定されている場合には:
hash.encoding
はutf8
でなければなりません。salt
は使用できません。hash.value
では、IETF Datatrackerに掲載のRFC-2307セクション5.3で説明されている形式を厳守する必要があります。スキーマは
md5|smd5|sha*|ssha*
のいずれかになります。詳細についてはこちらを参照してください。cryptスキーマは、動作がシステムや実装に依存するため、非対応であることに注意してください。詳細については、Open LDAPが提供するAdmin Guideの「4.4.2.CRYPT password storage scheme」をお読みください。
MDおよびSHA
algorithm
がscrypt
に設定されている場合には:
hash.encoding
はhex
またはbase64
でなければなりません。
PBKDF2
user.mfa_factors
配列には、ユーザーのMFA登録が含まれます。詳細については、「Auth0での多要素認証」をお読みください。登録をインポートすると、インポート後にユーザーがMFAに再登録する必要がなくなります。以下の登録タイプに対応しています。
hash.encoding
はutf8
でなければなりません。hash.salt
は使用できません。hash.value
は、GitHubのP-H-C / phc-string-formatで指定されているように、PHC文字列形式でなければなりませんhash.value
にはB64エンコードされたソルトが含まれなければなりません(埋め込み文字「=
」を省略したbase64で、PHC
のドキュメントで指定されています)。hash.value
には、i
(iterations)とl
(keylen)パラメーターが含まれなければなりません。これらのパラメーターを省略すると、デフォルトのi=100000
およびl=64
が使用されます。id
はpbkdf2-<digest>
形式(pbkdf2-sha512
、pbkdf2-md5
など)でなければなりません。以下のダイジェストに対応しています。RSA-MD4
RSA-MD5
RSA-MDC2
RSA-RIPEMD160
RSA-SHA1
RSA-SHA1-2
RSA-SHA224
RSA-SHA256
RSA-SHA384
RSA-SHA512
md4
md4WithRSAEncryption
md5
md5WithRSAEncryption
mdc2
mdc2WithRSA
ripemd
ripemd160
ripemd160WithRSA
rmd160
sha1
sha1WithRSAEncryption
sha224
sha224WithRSAEncryption
sha256
sha256WithRSAEncryption
sha384
sha384WithRSAEncryption
sha512
sha512WithRSAEncryption
ssl3-md5
ssl3-sha1
whirlpool
scrypt
プロパティ | タイプ | 説明 |
---|---|---|
email |
オブジェクト | |
email.value |
文字列 | MFAのメールアドレス。 |
phone |
オブジェクト | |
phone.value |
文字列 | SMS MFAの電話番号。国コードがあり、先頭が+ でなければなりません。例:"+12125550001" |
totp |
オブジェクト | |
totp.secret |
文字列 | Authenticatorアプリ(Google Authenticator、Microsoft Authenticator、Authy、1Password, LastPass)を使ったMFA認証のOTPシークレット。パッドなしのBase32エンコーディングで指定する必要があります。例: "JBTWY3DPEHPK3PNP" |
hash.encoding
はhex
またはbase64
でなければなりません。keylen
パラメーターは必須です。cost
パラメーターを使用することができます。指定しない場合には、デフォルトの16384が使用されます。blockSize
パラメーターを使用することができます。指定しない場合には、デフォルトの8が使用されます。parallelization
パラメーターを使用することができます。指定しない場合には、デフォルトの1が使用されます。
MFA要素
以下の内容のあるファイルが有効です。
[
{
"email": "john.doe@contoso.com",
"email_verified": false,
"app_metadata": {
"roles": ["admin"],
"plan": "premium"
},
"user_metadata": {
"theme": "light"
}
}
]
Was this helpful?
例
基本例
以下は、提供されたハッシュのあるユーザーの例です。
[
{
"email": "antoinette@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "md4",
"hash": {
"value": "AbuUujgF0pPPkJPSFRTpmA==",
"encoding": "base64"
}
}
},
{
"email": "mary@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "sha256",
"hash": {
"value": "d24e794fce503c3ddb1cd1ba1dd5d9b250cf9917336a0316fefd87fecf79200f",
"encoding": "hex"
},
"salt": {
"value": "abc123",
"position": "prefix"
}
}
},
{
"email": "velma@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "bcrypt",
"hash": {
"value": "$2b$10$C9hB01.YxRSTcn/ZOOo4j.TW7xCKKFKBSF.C7E0xiUwumqIDqWUXG"
}
}
},
{
"email": "edward@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "argon2",
"hash": {
"value": "$argon2id$v=19$m=65536,t=2,p=1$J6Q/82PCyaNpYKRELJyTZg$m04qUAB8rexWDR4+/0f+SFB+4XMFxt7YAvAq2UycYos"
}
}
},
{
"email": "terrell@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "pbkdf2",
"hash": {
"value": "$pbkdf2-md4$i=100000,l=64$+N375B8q0Fw$fp2R9KAM4hK/votGHC5Fu+jhqbxUD8+Nic/EMSGvNC3UP/k7wSHI0uXluHRSkZfl/BOheYqNOemayG90ZaSSQw",
"encoding": "utf8"
}
}
},
{
"email": "cecil@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "pbkdf2",
"hash": {
"value": "$pbkdf2-sha512$i=100000,l=64$KNyFsA2rWoE$I2CQGI9H0JxdDf3kERRI97kPCGxh0KWBIV3MxyaS191gDGfzVBGyS4BibhgqWQ0/ails8mHuU9ckASxHOOq58w"
}
}
},
{
"email": "sean@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "ldap",
"hash": {
"value": "{SSHA384}/cgEjdoZh85DhurDeOQEMO1rMlAur93SVPbYe5XSD4lF7nNuvrBju5hUeg9A6agRemgSXGl5YuE=",
"encoding": "utf8"
}
}
},
{
"email": "peter@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "hmac",
"hash": {
"value": "cg7f42jH39/2EaAU4wNd4s2lKIk=",
"encoding": "base64",
"digest": "sha1",
"key": {
"value": "736868",
"encoding": "hex"
}
}
}
},
{
"email": "carmella@contoso.com",
"email_verified": false,
"custom_password_hash": {
"algorithm": "scrypt",
"hash": {
"value": "097f6197e1b41538f723e32aa7a68e8d76227d8e432ce5faa4882a913032db29",
"encoding": "hex"
},
"salt": {
"value": "abc123",
"encoding": "utf8"
},
"keylen": 32,
"cost": 4096
}
}
]
Was this helpful?
カスタムパスワードハッシュの例
ご推察のとおり、user.mfa_factors
配列は、ユーザーのMFA登録を提供できるようにします。以下の登録タイプに対応しています。
以下は、MFA要素のあるユーザーの例です。
MFA要素の例
[
{
"email": "antoinette@contoso.com",
"mfa_factors": [
{
"totp": {
"secret": "2PRXZWZAYYDAWCD"
}
},
{
"phone": {
"value": "+15551112233"
}
},
{
"email": {
"value": "antoinette@antoinette.biz"
}
}
]
},
{
"email": "mary@contoso.com",
"mfa_factors": [
{
"totp": {
"secret": "JBTWY3DPEHPK3PNP"
}
}
]
},
{
"email": "velma@contoso.com",
"mfa_factors": [
{
"phone": {
"value": "+15551234567"
}
},
]
},
{
"email": "edward@contoso.com",
"mfa_factors": [
{
"email": {
"value": "edward@edward.biz"
}
}
]
}
]
Was this helpful?
電話:SMSベースの検証に使用されます。
TOTP:MFAタイプのアプリ(Google Authenticator、Microsoft Authenticator、Authy、1Password、LastPass)で使用するOTPシークレットです。
メール:メールベースの検証に使用されます。
以下は、MFA要素のあるユーザーの例です。
[
{
"email": "antoinette@contoso.com",
"mfa_factors": [
{
"totp": {
"secret": "2PRXZWZAYYDAWCD"
}
},
{
"phone": {
"value": "+15551112233"
}
},
{
"email": {
"value": "antoinette@antoinette.biz"
}
}
]
},
{
"email": "mary@contoso.com",
"mfa_factors": [
{
"totp": {
"secret": "JBTWY3DPEHPK3PNP"
}
}
]
},
{
"email": "velma@contoso.com",
"mfa_factors": [
{
"phone": {
"value": "+15551234567"
}
},
]
},
{
"email": "edward@contoso.com",
"mfa_factors": [
{
"email": {
"value": "edward@edward.biz"
}
}
]
}
]
Was this helpful?