mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: use header scheme keys in locationAuth, add impersonateUserEmail/Phone param aliases
Use ImpersonateUserId/Email/Phone directly in locationAuth — their caseLower maps to existing config keys set by the corresponding setters. Add impersonateUserEmail and impersonateUserPhone as backend param fallbacks to match caseCamel output of those keys in LOCATION method URLs.
This commit is contained in:
1 parent
81c33855fe
commit
29272b7186
16 files changed
+17
-71
No files matched your search
@@ -330,8 +330,8 @@ return function (Container $container): void {
|
||||
// Query params mirror the header fallback pattern used by ?project= and ?devKey=,
|
||||
// allowing Console to embed impersonation in direct file/image URLs where headers cannot be set.
|
||||
$impersonateUserId = $request->getHeader('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeader('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeader('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
$impersonateEmail = $request->getHeader('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '') ?: $request->getParam('impersonateUserEmail', '')));
|
||||
$impersonatePhone = $request->getHeader('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '') ?: $request->getParam('impersonateUserPhone', '')));
|
||||
|
||||
if (!$user->isEmpty() && $user->getAttribute('impersonator', false)) {
|
||||
$userDb = ($mode === APP_MODE_ADMIN || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
|
||||
@@ -492,8 +492,8 @@ return function (Container $context): void {
|
||||
// Query params mirror the header fallback pattern used by ?project= and ?devKey=,
|
||||
// allowing Console to embed impersonation in direct file/image URLs where headers cannot be set.
|
||||
$impersonateUserId = $request->getHeader('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeader('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeader('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
$impersonateEmail = $request->getHeader('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '') ?: $request->getParam('impersonateUserEmail', '')));
|
||||
$impersonatePhone = $request->getHeader('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '') ?: $request->getParam('impersonateUserPhone', '')));
|
||||
if (!$user->isEmpty() && $user->getAttribute('impersonator', false)) {
|
||||
$userDb = (APP_MODE_ADMIN === $mode || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
$targetUser = null;
|
||||
|
||||
@@ -42,7 +42,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-browser.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -42,7 +42,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-credit-card.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -54,7 +54,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-favicon.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -42,7 +42,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-flag.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -45,7 +45,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-image.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -44,7 +44,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-initials.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -42,7 +42,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-qr.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -57,7 +57,7 @@ class Get extends Action
|
||||
description: '/docs/references/avatars/get-screenshot.md',
|
||||
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::KEY, AuthType::JWT],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: Response::STATUS_CODE_OK,
|
||||
|
||||
@@ -53,7 +53,7 @@ class Get extends Action
|
||||
],
|
||||
contentType: ContentType::ANY,
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
))
|
||||
->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject'])
|
||||
->param('deploymentId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Deployment ID.', false, ['dbForProject'])
|
||||
|
||||
@@ -51,7 +51,7 @@ class Get extends Action
|
||||
)
|
||||
],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
contentType: ContentType::ANY,
|
||||
))
|
||||
->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject'])
|
||||
|
||||
@@ -58,7 +58,7 @@ class Get extends Action
|
||||
],
|
||||
contentType: ContentType::ANY,
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
))
|
||||
->param('bucketId', '', new UID(), 'Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).')
|
||||
->param('fileId', '', new UID(), 'File ID.')
|
||||
|
||||
@@ -71,7 +71,7 @@ class Get extends Action
|
||||
)
|
||||
],
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
contentType: ContentType::IMAGE
|
||||
))
|
||||
->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).')
|
||||
|
||||
@@ -59,7 +59,7 @@ class Get extends Action
|
||||
],
|
||||
contentType: ContentType::ANY,
|
||||
type: MethodType::LOCATION,
|
||||
locationAuth: ['Project', 'ImpersonateUserQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'],
|
||||
locationAuth: ['Project', 'ImpersonateUserId', 'ImpersonateUserEmail', 'ImpersonateUserPhone'],
|
||||
))
|
||||
->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).')
|
||||
->param('fileId', '', new UID(), 'File ID.')
|
||||
|
||||
@@ -181,36 +181,18 @@ class Specs extends Action
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateUserId',
|
||||
'description' => 'Impersonate a user by ID via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserEmailQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateEmail',
|
||||
'description' => 'Impersonate a user by email via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserPhoneQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonatePhone',
|
||||
'description' => 'Impersonate a user by phone via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
],
|
||||
APP_SDK_PLATFORM_SERVER => [
|
||||
'Project' => [
|
||||
@@ -273,36 +255,18 @@ class Specs extends Action
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateUserId',
|
||||
'description' => 'Impersonate a user by ID via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserEmailQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateEmail',
|
||||
'description' => 'Impersonate a user by email via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserPhoneQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonatePhone',
|
||||
'description' => 'Impersonate a user by phone via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
],
|
||||
APP_SDK_PLATFORM_CONSOLE => [
|
||||
'Project' => [
|
||||
@@ -365,36 +329,18 @@ class Specs extends Action
|
||||
'description' => 'Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateUserId',
|
||||
'description' => 'Impersonate a user by ID via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserEmail' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Email',
|
||||
'description' => 'Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserEmailQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonateEmail',
|
||||
'description' => 'Impersonate a user by email via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
'ImpersonateUserPhone' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'X-Appwrite-Impersonate-User-Phone',
|
||||
'description' => 'Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.',
|
||||
'in' => 'header',
|
||||
],
|
||||
'ImpersonateUserPhoneQuery' => [
|
||||
'type' => 'apiKey',
|
||||
'name' => 'impersonatePhone',
|
||||
'description' => 'Impersonate a user by phone via query param. Used for location-type methods where headers cannot be set.',
|
||||
'in' => 'query',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user