Documentation Index
Fetch the complete documentation index at: https://auth0.generaltranslation.app/llms.txt
Use this file to discover all available pages before exploring further.
フィルターフックはフィルタリングロジックのみを適用するため、現在のユーザー(または管理者の役割を果たしている人物)が特定のユーザーへのアクセス権を持っているかどうかを判定するには、2番目のロジック層が必要になります。
フィルターフックの詳細については、「委任管理:フィルターフック」をお読みください。
[Access Hook(アクセスフック) では、現在のユーザーが特定のユーザーを読み取り、削除、ブロック、ブロック解除、または更新することができるかどうかを判定できます。
-
ctx :コンテキストオブジェクト。
-
payload :ペイロードオブジェクト。
- action :実行されている現在のアクション( delete:user など)。
- user :アクションが実行されているユーザー。
-
callback(error) :アクセスが拒否された場合にエラーを返すことができるコールバック。
財務部の管理を担うケリーがアクセスできるのは、部署内のユーザーのみに限られるべきです。
function(ctx, callback) {
if (ctx.payload.action === 'delete:user') {
return callback(new Error('You are not allowed to delete users.'));
}
// Get the department from the current user's metadata.
var department = ctx.request.user.app_metadata && ctx.request.user.app_metadata.department;
if (!department || !department.length) {
return callback(new Error('The current user is not part of any department.'));
}
// The IT department can access all users.
if (department === 'IT') {
return callback();
}
ctx.log('Verifying access:', ctx.payload.user.app_metadata.department, department);
if (!ctx.payload.user.app_metadata.department || ctx.payload.user.app_metadata.department !== department) {
return callback(new Error('You can only access users within your own department.'));
}
return callback();
}
このフックが構成されていないと、現在のユーザーはすべてのユーザーにアクセスすることができます。
フックは以下のアクション名( ctx.payload.action の値として使用して設定)をサポートします。
- read:user
- delete:user
- reset:password
- change:password
- change:username
- change:email
- read:devices
- read:logs
- remove:multifactor-provider
- block:user
- unblock:user
- send:verification-email