委任管理:クエリ設定フック
クエリフック設定フックは、委任管理拡張機能の外観や操作性をカスタマイズできるようにします。
フックコントラクト
ctx:コンテキストオブジェクトです。
request.user:現在ログインしているユーザーです。
locale:ロケール(URLから推測)です。
https://{yourTenant}.us.webtask.io/auth0-delegated-admin/en/users
ではロケールがen
に設定されます。
callback(error, settings):エラーと設定オブジェクトを返すコールバックです。
使用例
function(ctx, callback) {
var department = ctx.request.user.app_metadata && ctx.request.user.app_metadata.department;
return callback(null, {
// Only these connections should be visible in the connections picker. If only one connection is available, the connections picker will not be shown in the UI.
connections: [ 'Username-Password-Authentication', 'My-Custom-DB' ],
// The dictionary allows you to overwrite the title of the dashboard and the "Memberships" label in the Create User dialog.
dict: {
title: department ? department + ' User Management' : 'User Management Dashboard',
memberships: 'Departments',
menuName: ctx.request.user.name
},
// The CSS option allows you to inject a custom CSS file depending on the context of the current user (eg: a different CSS for every customer)
css: (department && department !== 'IT') && 'https://rawgit.com/auth0-extensions/auth0-delegated-administration-extension/master/docs/theme/fabrikam.css',
// This option allows you to restrict creating new users
canCreateUser: (department === 'IT')
});
}
Was this helpful?
プロパティ
connections:管理者がユーザーの作成や編集を許可されている接続のリストです。
dict:ダッシュボートのタイトルと[Create User(ユーザー作成)]ダイアログの[Memberships(メンバーシップ)]ラベルを上書きできるようにする辞書です。
dict.title:UIの上部に表示されるタイトルです。
dict.memberships:メンバーシップフィールドに設定されるラベルです。
dict.menuName:右上にあるドロップダウンメニューに設定される名前です。
dict.logoutUrl:ログアウトメニューオプションの代替のURLです。
userFields:ユーザーフィールドの配列です(以下で「カスタムフィールド」を参照してください)。
css:CSSをインポートするための文字列のURLです。
altcss:2つ目のCSSをインポートするための文字列のURLです。大サイズフォント用のアクセシビリティCSSなどを指定するのに使用できます。ユーザーには、このCSSをオンまたはオフに切り替えるためのメニュー項目が表示されます。
languageDictionary:文字列のURLまたは辞書オブジェクトです(以下で「ローカリゼーション」を参照してください)。
suppressRawData:trueに設定すると、生のJSONを表示するページがスキップされます。
errorTranslator:ローカリゼーションに基づいてエラーメッセージを翻訳する関数です。例:
(function (error, languageDictionary) { return languageDictionary.customErrors[error] || error; }).toString()
canCreateUser:ブール型のフラグです。
false
に設定すると、[Create User
(ユーザーの作成)]ボタンが非表示になり、ユーザーの新規作成が禁止になります。デフォルトはtrue
です。
カスタムフィールド
委任管理拡張機能のバージョン3.0から、カスタムフィールドを定義して値を指定できるようになりました。カスタムフィールドは、ユーザーの作成時や更新プロセス中にユーザーメタデータやアプリメタデータのフィールドに保管することができます。
また、メールやユーザー名、名前、接続など、Auth0が定義した既存のフィールドをカスタマイズすることもできます。
カスタムフィールドを使用するには、以下を行う必要があります。
クエリ設定フックにuserFieldsのリストを追加する
書き込みフックを実装する。
user_metadata
やapp_metadata
を正しく更新するためには、カスタムフィールドが書き込みフックを使用する必要があります。フックに提供されたコンテキスト(ctx
オブジェクト)からのuser_metadata
やapp_metadata
を使用して、コールバック関数に渡されるユーザーオブジェクトを更新しなければなりません。
書き込みフックの詳細については、「委任管理:書き込みフック」をお読みください。
以下はuserFieldsのスキーマの例です。
userFields: [
{
"property": string, // required
"label": string,
"sortProperty": string,
"display": true || function.toString(),
"search": false || {
"display": true || function.toString()
"listOrder": 1,
"listSize": string(###%), // e.g. 15%
"filter": boolean,
"sort": boolean
},
"edit": false || {
"display": true || function.toString()
"type": "text || select || password || hidden",
"component": "InputText || Input Combo || InputMultiCombo || InputSelectCombo",
"options": Array(string) || Array ({ "value": string, "label": string }),
"disabled": true || false,
"validationFunction": function.toString()
},
"create": false || {
"display": true || function.toString()
"type": "text || select || password || hidden",
"component": "InputText || Input Combo || InputMultiCombo || InputSelectCombo",
"options": Array(string) || Array ({ "value": string, "label": string }),
"disabled": true || false,
"validationFunction": function.toString()
}
},
...
]
Was this helpful?
property(必須):書き込みフックのctx.payloadオブジェクトのプロパティ名です。書き込みフックで、
"property":"app_metadata.dbId"
はctx.payload.app_metadata.dbId
を設定します。label:ユーザー情報や作成、プロファイル編集、検索のページのフィールドにラベルを追加するときに使用されるラベルです。
sortProperty:異なるフィールドで検索テーブルを並べ替える場合には、このフィールドを使用します。ドット表記を使用することができます。
display:true || false || stringified => これがデフォルトの表示値です。検索や編集、作成でオーバーライドされない場合は、この値が使用されます。
true
の場合には、単にuser.<property>
を返します。デフォルト:
false
の場合、(検索や編集、作成でオーバーライドされない限り)この値はどのページにも表示されません。文字列化関数の場合には、関数を実行して、表示する値を取得します。例:
(function display(user, value, languageDictionary) { return moment(value).fromNow(); }).toString()
search:false || object => このフィールドが検索ページでどのように振る舞うかを指定します。
デフォルト:
false
の場合、検索テーブルには表示されません。search.display:デフォルトの表示値をオーバーライドします。
search.listOrder:検索表示テーブルの列の順序を指定します。
search.listSize:列のデフォルト幅を指定します。
search.filter:検索ドロップダウンでこのフィールドが検索されるかを指定します。デフォルトはfalseです。
search.sort:この列が並べ替え可能かを指定します。プロパティ以外のフィールドで並べ替えたい場合には、sortPropertyを使用します。デフォルトはfalseです。
edit:false || object => 編集ダイアログにこのフィールドを表示するかを指定します。デフォルトのフィールド以外で、オブジェクトに設定されている場合には、ユーザーページの[User Actions(ユーザーアクション)]ドロップダウンの[
Change Profile
(プロファイル変更)]ページにこれが表示されます。デフォルト:
false
の場合には、いかなる編集または更新のページにも表示されません。edit.display:デフォルトの表示値をオーバーライドします。
edit.required:trueに設定すると、値がなければ失敗します。デフォルトはfalseです。
edit.type(必須):text || select || password
edit.component:InputText || InputCombo || InputMultiCombo || InputSelectCombo
InputText(デフォルト):簡素なテキストボックスです。
InputCombo:検索可能なドロップダウンで、1つの値のみです。
InputMultiCombo:検索可能なドロップダウンで、複数の値を指定することができます。
InputSelectCombo:オプションのドロップダウンを選択します。
edit.options:コンポーネントがInputCombo、InputMultiCombo、InputSelectComboのいずれかの場合には、任意の値を指定する必要があります。
Array(string):値の配列です(ラベルと値のフィールドが同じ値に設定されます)。
Array({ "value": string, "label": string }):値とラベルにそれぞれ別の値を設定することができます。これによって、書き込みフックが同じ値を持つことになりますが、書き込みフックだけが値を持つように簡素化することができます。
サーバー側の検証によって、このフィールドに指定されたすべての値がオプション配列に確実に表示されるようになります。
edit.disabled:コンポーネントを読み取り専用にするには、
true
に設定します。デフォルトはfalseです。edit.validateFunction:検証のための文字列化関数です。この検証関数はサーバー側とクライアント側の両方で実行されることに注意してください。例:
(function validate(value, values, context, languageDictionary) { if (value...) return 'something went wrong'; return false; }).toString()
create:false || object => 作成ダイアログにこのフィールドを表示するかを指定します。
デフォルト:
false
の場合、作成ページには表示されません。create.placeholder:入力が空の場合にプレースホルダーのテキストを表示します。
create.required:trueに設定すると、値がなければ失敗します。デフォルトはfalseです。
create.type(必須):text || select || password
create.component:InputText || InputCombo || InputMultiCombo || InputSelectCombo
InputText(デフォルト):テキストボックスです。タイプがテキストやパスワードの場合のデフォルトです。
InputCombo:検索可能なドロップダウンで、1つの値のみです。
InputMultiCombo:検索可能なドロップダウンで、複数の値を指定することができます。
InputSelectCombo:オプションのドロップダウンを選択します。
create.options:コンポーネントがInputCombo、InputMultiCombo、InputSelectComboのいずれかの場合には、任意の値を指定する必要があります。
Array(string):単純な値の配列で、ラベルと値が同じ値に設定されます。
Array({ "value": string, "label": string }):値とラベルにそれぞれ別の値を設定することができます。これによって、書き込みフックが同じ値を持つことになりますが、書き込みフックだけが値を持つように簡素化することができます。
サーバー側の検証によって、このフィールドに指定されたすべての値がオプション配列で確実に指定されるようになります。
create.disabled:コンポーネントを読み取り専用にする場合は、trueに設定します。デフォルトはfalseです。
create.validateFunction:検証を確認するための文字列化関数です。
例:
(function validate(value, values, context, languageDictionary) { if (value...) return 'something went wrong'; return false; }).toString()
この検証関数はサーバー側とクライアント側の両方で実行されます。
事前定義されたフィールド
デフォルトの動作について、事前定義された検索可能なフィールドのセットがあります。
デフォルトの動作をオーバーライドするには、フィールドをuserFieldとして追加し、変えたい動作をオーバーライドします。これは、表示をfalseに設定して、フィールドを抑制するためによく行われます。
検索フィールド
name:他のフィールドから構築されたフィールドです。デフォルトの表示関数:
(function(user, value) { return (value || user.nickname || user.email || user.user_id); }).toString()
email:メールアドレスまたは該当なし
last_login_relative:最終ログイン時刻
logins_count:ログイン回数
connection:データベース接続
ユーザー情報フィールド
user_id:ユーザーID
name:ユーザーの名前
username:ユーザーのユーザー名
email:ユーザーのメール
identity.connection:接続値
isBlocked:ユーザーがブロックされているかどうか
blocked_for:ユーザーが攻撃防御でブロックされているかどうか
last_ip:ユーザーが前回のログインに使用したIP
logins_count:ユーザーがログインした回数
currentMemberships:このユーザーのメンバーシップのリスト
created_at:ユーザーが作成された日時
updated_at:ユーザーが更新された日時
last_login:ユーザーが最後にログインした日時
ユーザーの作成と編集のフィールド
connection:ユーザーのデータベース
password:新しいパスワード
repeatPassword:ユーザーのパスワードの再入力
email:ユーザーのメール
username:ユーザーのユーザー名
使用例
function(ctx, callback) {
var department = ctx.request.user.app_metadata && ctx.request.user.app_metadata.department;
return callback(null, {
// Only these connections should be visible in the connections picker.
// If only one connection is available, the connections picker will not be shown in the UI.
connections: [ 'Username-Password-Authentication', 'My-Custom-DB' ],
// The dictionary allows you to overwrite the title of the dashboard and the "Memberships" label in the Create User dialog.
dict: {
title: department ? department + ' User Management' : 'User Management Dashboard',
memberships: 'Departments'
},
// User Fields are the custom fields that can be displayed in create and edit, and can also be used for searching, and can be used to customize the view user page
userFields: [
{
"label": "Conexión",
"property": "connection",
},
{
"label": "Correo Electrónico",
"property": "email",
},
...
],
// The CSS option allows you to inject a custom CSS file depending on the context of the current user (eg: a different CSS for every customer)
css: (department && department !== 'IT') && 'https://rawgit.com/auth0-extensions/auth0-delegated-administration-extension/master/docs/theme/fabrikam.css',
languageDictionary: 'https://your-cdn.com/locale/es.json'
});
}
Was this helpful?
ローカリゼーション
委任管理拡張機能のバージョン3.0から、ローカリゼーションに使用する言語辞書を指定できるようになりました。言語辞書は静的なページのコンテンツにのみ使用されます。フィールドレベルのコンテンツについては、userFieldsラベルを使用しなければなりません。
ロケールの指定には、パスを使用することができます。例:https://{yourTenant}.us.webtask.io/auth0-delegated-admin/en/users
では、設定クエリでcontext.locale
をen
に設定します。
languageDictionaryは設定クエリの一部として設定され、以下を行うことができます。
languageDictionaryを明示的に定義する
URLを提供して、languageDictionaryパラメーターのコンテンツを取得する
詳細については、「委任管理拡張機能の言語辞書ファイル」をご覧ください。
例:言語辞書ファイルへのリンクを提供する
function(ctx, callback) {
var department = ctx.request.user.app_metadata && ctx.request.user.app_metadata.department;
return callback(null, {
// Only these connections should be visible in the connections picker.
// If only one connection is available, the connections picker will not be shown in the UI.
connections: [ 'Username-Password-Authentication', 'My-Custom-DB' ],
// The dictionary allows you to overwrite the title of the dashboard and the "Memberships" label in the Create User dialog.
dict: {
title: department ? department + ' User Management' : 'User Management Dashboard',
memberships: 'Departments'
},
// User Fields are the custom fields that can be displayed in create and edit, and can also be used for searching, and can be used to customize the view user page
userFields: [
{
"label": "Conexión",
"property": "connection",
},
{
"label": "Correo Electrónico",
"property": "email",
},
...
],
// The CSS option allows you to inject a custom CSS file depending on the context of the current user (eg: a different CSS for every customer)
css: (department && department !== 'IT') && 'https://rawgit.com/auth0-extensions/auth0-delegated-administration-extension/master/docs/theme/fabrikam.css',
languageDictionary: 'https://your-cdn.com/locale/es.json'
});
}
Was this helpful?
例:言語辞書オブジェクトを提供する
function(ctx, callback) {
var department = ctx.request.user.app_metadata && ctx.request.user.app_metadata.department;
return callback(null, {
// Only these connections should be visible in the connections picker.
// If only one connection is available, the connections picker will not be shown in the UI.
connections: [ 'Username-Password-Authentication', 'My-Custom-DB' ],
// The dictionary allows you to overwrite the title of the dashboard and the "Memberships" label in the Create User dialog.
dict: {
title: department ? department + ' User Management' : 'User Management Dashboard',
memberships: 'Departments'
},
// User Fields are the custom fields that can be displayed in create and edit, and can also be used for searching, and can be used to customize the view user page
userFields: [
{
"label": "Conexión",
"property": "connection",
},
{
"label": "Correo Electrónico",
"property": "email",
},
...
],
// The CSS option allows you to inject a custom CSS file depending on the context of the current user (eg: a different CSS for every customer)
css: (department && department !== 'IT') && 'https://rawgit.com/auth0-extensions/auth0-delegated-administration-extension/master/docs/theme/fabrikam.css',
languageDictionary: {
loginsCountLabel: 'Cantidad de Logins:',
searchBarPlaceholder: 'Busqueda de usuarios usando la sintaxis de Lucene',
deviceNameColumnHeader: 'Dispositivo',
...
}
});
}
Was this helpful?