mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge branch 'main' into feat-notifications-worker
Resolved conflicts: - .env: took main's layout, re-added _APP_NOTIFICATIONS_TRACKING_SECRET. - Templates/Email/Update.php: took main's refactored version (not part of the notifications work). - self-hosted-release skill doc: took main's version.
This commit is contained in:
commit
ada9845555
318 files changed
+3217
-518
No files matched your search
@@ -41,7 +41,7 @@ Build and run the target release with the local Docker Compose stack, then test
|
||||
docker compose down -v
|
||||
docker compose up -d --force-recreate --build --wait
|
||||
docker compose exec -T appwrite vars
|
||||
curl -fsS http://localhost/v1/health/version
|
||||
curl -fsS http://localhost:9520/v1/health/version
|
||||
```
|
||||
|
||||
2. Inspect runtime health before running tests:
|
||||
|
||||
@@ -11,6 +11,7 @@ _APP_WORKER_PER_CORE=6
|
||||
_APP_WORKERS_NUM=1
|
||||
_APP_WORKER_MAX_COROUTINES=1
|
||||
_APP_WORKER_SCREENSHOTS_ROUTER=http://appwrite
|
||||
_APP_REALTIME_TAIL_RATE=50
|
||||
_APP_COMPRESSION_ENABLED=enabled
|
||||
_APP_COMPRESSION_MIN_SIZE_BYTES=1024
|
||||
_APP_DOMAIN=appwrite.test
|
||||
@@ -151,5 +152,3 @@ _APP_VCS_GITHUB_CLIENT_SECRET=
|
||||
_APP_VCS_GITHUB_PRIVATE_KEY=disabled
|
||||
_APP_VCS_GITHUB_WEBHOOK_SECRET=
|
||||
_APP_WEBHOOK_MAX_FAILED_ATTEMPTS=10
|
||||
_TESTS_OAUTH2_GITHUB_CLIENT_ID=
|
||||
_TESTS_OAUTH2_GITHUB_CLIENT_SECRET=
|
||||
@@ -51,42 +51,37 @@ function buildComment(core) {
|
||||
const baseRef = markdownText(process.env.BENCHMARK_BASE_REF || 'base');
|
||||
const headRef = markdownText(process.env.BENCHMARK_HEAD_REF || 'head');
|
||||
const rows = benchmarkRows(before, after, beforeSamples, afterSamples);
|
||||
const topWaits = topSamples(afterSamples, 'appwrite_api_waiting', 3);
|
||||
const total = rows[0];
|
||||
const topWaits = topSamples(afterSamples, 'appwrite_api_waiting', 5);
|
||||
const lines = [
|
||||
marker,
|
||||
'## :sparkles: Benchmark results',
|
||||
'',
|
||||
`Comparing ${baseRef} (before) to ${headRef} (after).`,
|
||||
`Comparing \`${baseRef}\` (before) → \`${headRef}\` (after).`,
|
||||
'',
|
||||
];
|
||||
|
||||
if (before === null) {
|
||||
lines.push('> Before benchmark did not complete; showing current branch metrics only.', '');
|
||||
lines.push('> :warning: Before benchmark did not complete — change column unavailable.', '');
|
||||
}
|
||||
if (after === null) {
|
||||
lines.push('> Current branch benchmark did not complete; showing available metrics only.', '');
|
||||
lines.push('> :warning: Current branch benchmark did not complete — showing available metrics only.', '');
|
||||
}
|
||||
|
||||
lines.push(
|
||||
'**Before**',
|
||||
'',
|
||||
metricTable(rows, 'before'),
|
||||
'',
|
||||
'**After**',
|
||||
'',
|
||||
metricTable(rows, 'after'),
|
||||
'',
|
||||
'**Delta**',
|
||||
'',
|
||||
'| Scenario | P95 delta (ms) |',
|
||||
'| --- | ---: |',
|
||||
...rows.map(deltaRow),
|
||||
...headlineTable(total),
|
||||
'',
|
||||
'<details>',
|
||||
'<summary><strong>Top API waits</strong></summary>',
|
||||
'<summary><strong>Per-scenario breakdown & investigation details</strong></summary>',
|
||||
'',
|
||||
'<br>',
|
||||
'',
|
||||
'_Metrics below reflect the current branch (after). Δ P95 compares against the base._',
|
||||
'',
|
||||
detailTable(rows),
|
||||
'',
|
||||
'**Top API waits (after)**',
|
||||
'',
|
||||
'| API request | Max wait (ms) |',
|
||||
'| --- | ---: |',
|
||||
...topWaitRows(topWaits),
|
||||
@@ -97,6 +92,46 @@ function buildComment(core) {
|
||||
return `${lines.join('\n')}\n`;
|
||||
}
|
||||
|
||||
function headlineTable(total) {
|
||||
const { before, after } = total;
|
||||
return [
|
||||
'| Metric | Before | After | Change |',
|
||||
'| --- | ---: | ---: | :--- |',
|
||||
`| :rocket: Requests/sec | ${formatRate(before?.rps)} | ${formatRate(after?.rps)} | ${changeCell(before?.rps, after?.rps, false)} |`,
|
||||
`| :stopwatch: Latency P50 | ${formatMsUnit(before?.p50)} | ${formatMsUnit(after?.p50)} | ${changeCell(before?.p50, after?.p50, true)} |`,
|
||||
`| :stopwatch: Latency P95 | ${formatMsUnit(before?.p95)} | ${formatMsUnit(after?.p95)} | ${changeCell(before?.p95, after?.p95, true)} |`,
|
||||
];
|
||||
}
|
||||
|
||||
function changeCell(before, after, lowerIsBetter) {
|
||||
if (before === null || before === undefined || after === null || after === undefined || Number.isNaN(before) || Number.isNaN(after) || before === 0) {
|
||||
return 'n/a';
|
||||
}
|
||||
|
||||
const percent = Number((((after - before) / before) * 100).toFixed(1));
|
||||
const label = code(`${percent > 0 ? '+' : ''}${trimNumber(percent)}%`);
|
||||
|
||||
if (Math.abs(percent) <= 5) {
|
||||
return `:white_circle: ${label}`;
|
||||
}
|
||||
|
||||
const improved = lowerIsBetter ? percent < 0 : percent > 0;
|
||||
return `${improved ? ':green_circle:' : ':red_circle:'} ${label}`;
|
||||
}
|
||||
|
||||
function detailTable(rows) {
|
||||
return [
|
||||
'| Scenario | P50 (ms) | P95 (ms) | Requests | RPS | Δ P95 (ms) |',
|
||||
'| --- | ---: | ---: | ---: | ---: | ---: |',
|
||||
...rows.map(detailRow),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function detailRow(row) {
|
||||
const values = row.after;
|
||||
return `| ${row.label} | ${formatMs(values?.p50)} | ${formatMs(values?.p95)} | ${formatCount(values?.iterations)} | ${formatRate(values?.rps)} | ${formatDelta(row.before?.p95, row.after?.p95)} |`;
|
||||
}
|
||||
|
||||
function readSummary(path, core) {
|
||||
if (!fs.existsSync(path)) {
|
||||
return null;
|
||||
@@ -256,23 +291,6 @@ function metricValue(data, metric, stat) {
|
||||
return metricValues(data, metric)?.[stat] ?? null;
|
||||
}
|
||||
|
||||
function metricTable(rows, side) {
|
||||
return [
|
||||
'| Scenario | P50 (ms) | P95 (ms) | Requests | RPS |',
|
||||
'| --- | ---: | ---: | ---: | ---: |',
|
||||
...rows.map((row) => metricRow(row, side)),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function metricRow(row, side) {
|
||||
const values = row[side];
|
||||
return `| ${row.label} | ${formatMs(values?.p50)} | ${formatMs(values?.p95)} | ${formatCount(values?.iterations)} | ${formatRate(values?.rps)} |`;
|
||||
}
|
||||
|
||||
function deltaRow(row) {
|
||||
return `| ${row.label} | ${formatDelta(row.before?.p95, row.after?.p95)} |`;
|
||||
}
|
||||
|
||||
function topSamples(samples, metric, limit) {
|
||||
const byName = samples.reduce((result, sample) => {
|
||||
if (sample.metric !== metric || typeof sample.data?.value !== 'number') {
|
||||
@@ -310,11 +328,16 @@ function markdownText(value) {
|
||||
}
|
||||
|
||||
function formatMs(value) {
|
||||
return formatNumber(value, 2);
|
||||
return code(formatNumber(value, 2));
|
||||
}
|
||||
|
||||
function formatMsUnit(value) {
|
||||
const formatted = formatNumber(value, 2);
|
||||
return formatted === 'n/a' ? formatted : code(`${formatted} ms`);
|
||||
}
|
||||
|
||||
function formatRate(value) {
|
||||
return formatNumber(value, 2);
|
||||
return code(formatNumber(value, 2));
|
||||
}
|
||||
|
||||
function formatCount(value) {
|
||||
@@ -322,7 +345,7 @@ function formatCount(value) {
|
||||
return 'n/a';
|
||||
}
|
||||
|
||||
return `${Math.round(value)}`;
|
||||
return code(Math.round(value).toLocaleString('en-US'));
|
||||
}
|
||||
|
||||
function formatDelta(before, after) {
|
||||
@@ -331,7 +354,8 @@ function formatDelta(before, after) {
|
||||
}
|
||||
|
||||
const difference = Number((after - before).toFixed(2));
|
||||
return `${difference > 0 ? '+' : ''}${trimNumber(difference)}`;
|
||||
const sign = difference > 0 ? '+' : difference < 0 ? '-' : '';
|
||||
return code(`${sign}${formatNumber(Math.abs(difference), 2)}`);
|
||||
}
|
||||
|
||||
function formatNumber(value, decimals) {
|
||||
@@ -339,7 +363,14 @@ function formatNumber(value, decimals) {
|
||||
return 'n/a';
|
||||
}
|
||||
|
||||
return trimNumber(Number(value).toFixed(decimals));
|
||||
return trimNumber(Number(value).toLocaleString('en-US', {
|
||||
minimumFractionDigits: decimals,
|
||||
maximumFractionDigits: decimals,
|
||||
}));
|
||||
}
|
||||
|
||||
function code(text) {
|
||||
return text === 'n/a' ? text : `\`${text}\``;
|
||||
}
|
||||
|
||||
function trimNumber(value) {
|
||||
|
||||
@@ -13,6 +13,7 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 1.9.x
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -668,7 +669,7 @@ jobs:
|
||||
docker tag ${{ env.IMAGE }}:before ${{ env.IMAGE }}
|
||||
docker compose up -d --wait --no-build
|
||||
for attempt in $(seq 1 10); do
|
||||
if curl -fsS http://localhost/v1/health/version; then
|
||||
if curl -fsS http://localhost:9520/v1/health/version; then
|
||||
break
|
||||
fi
|
||||
if [ "$attempt" -eq 10 ]; then
|
||||
@@ -685,9 +686,9 @@ jobs:
|
||||
continue-on-error: true
|
||||
uses: grafana/run-k6-action@de51a7390bdf0ac85a3bef493691bd71d4c7c158 # v1.4.0
|
||||
env:
|
||||
APPWRITE_ENDPOINT: 'http://localhost/v1'
|
||||
APPWRITE_BENCHMARK_ITERATIONS: '5'
|
||||
APPWRITE_BENCHMARK_VUS: '1'
|
||||
APPWRITE_ENDPOINT: 'http://localhost:9520/v1'
|
||||
APPWRITE_BENCHMARK_DURATION: '1m'
|
||||
APPWRITE_BENCHMARK_VUS: '20'
|
||||
APPWRITE_WORKER_TIMEOUT_MS: '120000'
|
||||
APPWRITE_BENCHMARK_SUMMARY_PATH: 'benchmark-before-summary.json'
|
||||
with:
|
||||
@@ -707,7 +708,7 @@ jobs:
|
||||
- name: Wait for benchmark ports
|
||||
if: always()
|
||||
run: |
|
||||
for port in 80 443 8080 9503; do
|
||||
for port in 9520 9521 9522 9503; do
|
||||
for attempt in $(seq 1 30); do
|
||||
if ! ss -ltn | awk '{print $4}' | grep -Eq "[:.]${port}$"; then
|
||||
break
|
||||
@@ -732,7 +733,7 @@ jobs:
|
||||
docker tag ${{ env.IMAGE }}:after ${{ env.IMAGE }}
|
||||
docker compose up -d --wait --no-build
|
||||
for attempt in $(seq 1 10); do
|
||||
if curl -fsS http://localhost/v1/health/version; then
|
||||
if curl -fsS http://localhost:9520/v1/health/version; then
|
||||
break
|
||||
fi
|
||||
if [ "$attempt" -eq 10 ]; then
|
||||
@@ -746,9 +747,9 @@ jobs:
|
||||
continue-on-error: true
|
||||
uses: grafana/run-k6-action@de51a7390bdf0ac85a3bef493691bd71d4c7c158 # v1.4.0
|
||||
env:
|
||||
APPWRITE_ENDPOINT: 'http://localhost/v1'
|
||||
APPWRITE_BENCHMARK_ITERATIONS: '5'
|
||||
APPWRITE_BENCHMARK_VUS: '1'
|
||||
APPWRITE_ENDPOINT: 'http://localhost:9520/v1'
|
||||
APPWRITE_BENCHMARK_DURATION: '1m'
|
||||
APPWRITE_BENCHMARK_VUS: '20'
|
||||
APPWRITE_WORKER_TIMEOUT_MS: '120000'
|
||||
APPWRITE_BENCHMARK_PREVIOUS_SUMMARY_PATH: '../../benchmark-before-summary.json'
|
||||
APPWRITE_BENCHMARK_SUMMARY_PATH: 'benchmark-after-summary.json'
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ tasks:
|
||||
--prefer-dist
|
||||
|
||||
ports:
|
||||
- port: 8080
|
||||
- port: 9520
|
||||
visibility: public
|
||||
|
||||
vscode:
|
||||
|
||||
+25
-2
@@ -281,11 +281,34 @@ Although the Appwrite API is a monolithic app, it has a very clear separation of
|
||||
|
||||
Each container in Appwrite is a microservice on its own. Each service is an independent process that can scale without regard to any of the other services.
|
||||
|
||||
Currently, all the Appwrite microservices are intended to communicate using the TCP protocol over a private network. With the exception of the public-facing port 80 and 443, which by default are used to expose the Appwrite HTTP API, you should **avoid exposing any other services' ports**.
|
||||
Currently, all the Appwrite microservices are intended to communicate using the TCP protocol over a private network. You should **avoid exposing services' ports** beyond what is needed for local development and debugging.
|
||||
|
||||
## Ports
|
||||
|
||||
Appwrite dev version uses ports 80 and 443 as an entry point to the Appwrite API and console. We also expose multiple ports in the range of 9500-9504 for debugging some of the Appwrite containers on dev mode. If you have any conflicts with the ports running on your system, you can easily replace them by editing Appwrite's docker-compose.yml file and executing `docker compose up -d` command.
|
||||
Appwrite server dev publishes all host ports in the **9500–9522** range so the stack can run alongside other local services (including Appwrite Cloud on **9600–9699**). Access the API and console at `http://localhost:9520` (or `https://localhost:9521`).
|
||||
|
||||
| Host port | Service |
|
||||
|-----------|---------|
|
||||
| 9520 | Traefik HTTP (API, console, dev hostnames) |
|
||||
| 9521 | Traefik HTTPS |
|
||||
| 9522 | Traefik HTTP (alt) |
|
||||
| 9500 | Traefik dashboard |
|
||||
| 9501 | Appwrite API only (direct; no console) |
|
||||
| 9502 | Realtime only (direct; no console) |
|
||||
| 9503 | Mail catcher |
|
||||
| 9504 | Request catcher (webhook) |
|
||||
| 9505 | Embedding |
|
||||
| 9506 | Adminer |
|
||||
| 9507 | Request catcher (SMS) |
|
||||
| 9508 | Mongo Express |
|
||||
| 9509 | GraphQL explorer |
|
||||
| 9510 | MariaDB |
|
||||
| 9511 | MongoDB |
|
||||
| 9512 | PostgreSQL |
|
||||
| 9513 | Redis |
|
||||
| 9514 | Redis Insight |
|
||||
|
||||
Containers still talk to each other on the internal Docker network using standard service ports (for example, `mariadb:3306`). The table above is only for connections from your host machine. If you still have a conflict, change the host side in `docker-compose.yml` or `docker-compose.override.yml` and run `docker compose up -d`.
|
||||
|
||||
## Technology Stack
|
||||
|
||||
|
||||
@@ -1306,7 +1306,7 @@ return [
|
||||
'size' => 128,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => APP_COMPUTE_SPECIFICATION_DEFAULT,
|
||||
'default' => APP_SITES_BUILD_SPECIFICATION_DEFAULT,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
|
||||
@@ -447,13 +447,13 @@ Http::get('/v1/account')
|
||||
contentType: ContentType::JSON
|
||||
))
|
||||
->inject('response')
|
||||
->inject('user')
|
||||
->action(function (Response $response, Document $user) {
|
||||
if ($user->isEmpty()) {
|
||||
->inject('targetUser')
|
||||
->action(function (Response $response, User $targetUser) {
|
||||
if ($targetUser->isEmpty()) {
|
||||
throw new Exception(Exception::USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
$response->dynamic($user, Response::MODEL_ACCOUNT);
|
||||
$response->dynamic($targetUser, Response::MODEL_ACCOUNT);
|
||||
});
|
||||
|
||||
Http::delete('/v1/account')
|
||||
@@ -476,20 +476,20 @@ Http::delete('/v1/account')
|
||||
],
|
||||
contentType: ContentType::NONE
|
||||
))
|
||||
->inject('user')
|
||||
->inject('targetUser')
|
||||
->inject('project')
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->inject('queueForEvents')
|
||||
->inject('publisherForDeletes')
|
||||
->inject('authorization')
|
||||
->action(function (Document $user, Document $project, Response $response, Database $dbForProject, Event $queueForEvents, DeletePublisher $publisherForDeletes, Authorization $authorization) {
|
||||
if ($user->isEmpty()) {
|
||||
->action(function (User $targetUser, Document $project, Response $response, Database $dbForProject, Event $queueForEvents, DeletePublisher $publisherForDeletes, Authorization $authorization) {
|
||||
if ($targetUser->isEmpty()) {
|
||||
throw new Exception(Exception::USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($project->getId() === 'console') {
|
||||
$memberships = $user->getAttribute('memberships', []);
|
||||
$memberships = $targetUser->getAttribute('memberships', []);
|
||||
foreach ($memberships as $membership) {
|
||||
if (!$membership->getAttribute('confirm', false)) {
|
||||
continue;
|
||||
@@ -505,17 +505,17 @@ Http::delete('/v1/account')
|
||||
}
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('users', $user->getId());
|
||||
$dbForProject->deleteDocument('users', $targetUser->getId());
|
||||
|
||||
$publisherForDeletes->enqueue(new DeleteMessage(
|
||||
project: $project,
|
||||
type: DELETE_TYPE_DOCUMENT,
|
||||
document: $user,
|
||||
document: $targetUser,
|
||||
));
|
||||
|
||||
$queueForEvents
|
||||
->setParam('userId', $user->getId())
|
||||
->setPayload($response->output($user, Response::MODEL_USER));
|
||||
->setParam('userId', $targetUser->getId())
|
||||
->setPayload($response->output($targetUser, Response::MODEL_USER));
|
||||
|
||||
$response->noContent();
|
||||
});
|
||||
|
||||
@@ -64,6 +64,8 @@ Http::patch('/v1/projects/:projectId/oauth2')
|
||||
]));
|
||||
});
|
||||
|
||||
$dbForPlatform->purgeCachedDocument('projects', $project->getId());
|
||||
|
||||
$response->dynamic($project, Response::MODEL_PROJECT);
|
||||
});
|
||||
|
||||
|
||||
@@ -988,7 +988,7 @@ Http::init()
|
||||
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
||||
*/
|
||||
Http::init()
|
||||
->groups(['api', 'web'])
|
||||
->groups(['api', 'web', 'graphql'])
|
||||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('cors')
|
||||
|
||||
@@ -18,6 +18,7 @@ use Appwrite\Extend\Exception as AppwriteException;
|
||||
use Appwrite\Functions\EventProcessor;
|
||||
use Appwrite\Platform\Modules\Storage\Config\CacheControl;
|
||||
use Appwrite\Platform\Modules\Storage\Config\StorageCacheControl;
|
||||
use Appwrite\Reference\Renderer;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\Usage\Context;
|
||||
use Appwrite\Utopia\Database\Documents\User;
|
||||
@@ -43,47 +44,6 @@ use Utopia\System\System;
|
||||
use Utopia\Telemetry\Adapter as Telemetry;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
$parseLabel = function (string $label, array $responsePayload, array $requestParams, User $user, Document $project) {
|
||||
preg_match_all('/{(.*?)}/', $label, $matches);
|
||||
foreach ($matches[1] as $pos => $match) {
|
||||
$find = $matches[0][$pos];
|
||||
$parts = explode('.', $match);
|
||||
|
||||
if (count($parts) !== 2) {
|
||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, "The server encountered an error while parsing the label: $label. Please create an issue on GitHub to allow us to investigate further https://github.com/appwrite/appwrite/issues/new/choose");
|
||||
}
|
||||
|
||||
$namespace = $parts[0];
|
||||
$replace = $parts[1];
|
||||
|
||||
$params = match ($namespace) {
|
||||
'user' => (array) $user,
|
||||
'project' => $project->getArrayCopy(),
|
||||
'request' => $requestParams,
|
||||
default => $responsePayload,
|
||||
};
|
||||
|
||||
if (array_key_exists($replace, $params)) {
|
||||
$replacement = $params[$replace];
|
||||
// Convert to string if it's not already a string
|
||||
if (! is_string($replacement)) {
|
||||
if (is_array($replacement)) {
|
||||
$replacement = json_encode($replacement);
|
||||
} elseif (is_object($replacement) && method_exists($replacement, '__toString')) {
|
||||
$replacement = (string) $replacement;
|
||||
} elseif (is_scalar($replacement)) {
|
||||
$replacement = (string) $replacement;
|
||||
} else {
|
||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, "The server encountered an error while parsing the label: $label. Please create an issue on GitHub to allow us to investigate further https://github.com/appwrite/appwrite/issues/new/choose");
|
||||
}
|
||||
}
|
||||
$label = \str_replace($find, $replacement, $label);
|
||||
}
|
||||
}
|
||||
|
||||
return $label;
|
||||
};
|
||||
|
||||
Http::init()
|
||||
->groups(['api'])
|
||||
->inject('route')
|
||||
@@ -99,7 +59,9 @@ Http::init()
|
||||
->inject('team')
|
||||
->inject('apiKey')
|
||||
->inject('authorization')
|
||||
->action(function (Route $route, Request $request, Database $dbForPlatform, Database $dbForProject, AuditContext $auditContext, Document $project, User $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey, Authorization $authorization) {
|
||||
->inject('impersonatorUser')
|
||||
->inject('targetUser')
|
||||
->action(function (Route $route, Request $request, Database $dbForPlatform, Database $dbForProject, AuditContext $auditContext, Document $project, User $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey, Authorization $authorization, Document $impersonatorUser, User $targetUser) {
|
||||
|
||||
/**
|
||||
* Handle user authentication and session validation.
|
||||
@@ -297,7 +259,8 @@ Http::init()
|
||||
elseif (($project->getId() === 'console' && ! $team->isEmpty() && ! $user->isEmpty()) || ($project->getId() !== 'console' && ! $user->isEmpty() && $mode === APP_MODE_ADMIN)) {
|
||||
$teamId = $team->getId();
|
||||
$adminRoles = [];
|
||||
$memberships = $user->getAttribute('memberships', []);
|
||||
$membershipSource = !$impersonatorUser->isEmpty() ? $targetUser : $user;
|
||||
$memberships = $membershipSource->getAttribute('memberships', []);
|
||||
foreach ($memberships as $membership) {
|
||||
if ($membership->getAttribute('confirm', false) === true && $membership->getAttribute('teamId') === $teamId) {
|
||||
$adminRoles = $membership->getAttribute('roles', []);
|
||||
@@ -353,7 +316,7 @@ Http::init()
|
||||
!$user->isEmpty()
|
||||
&& (
|
||||
$user->getAttribute('impersonator', false)
|
||||
|| $user->getAttribute('impersonatorUserId')
|
||||
|| !$impersonatorUser->isEmpty()
|
||||
)
|
||||
) {
|
||||
$scopes[] = 'users.read';
|
||||
@@ -361,16 +324,33 @@ Http::init()
|
||||
}
|
||||
|
||||
$authorization->addRole($role);
|
||||
foreach ($user->getRoles($authorization) as $authRole) {
|
||||
$rolesSource = $impersonatorUser->isEmpty() ? $user : $targetUser;
|
||||
foreach ($rolesSource->getRoles($authorization) as $authRole) {
|
||||
$authorization->addRole($authRole);
|
||||
}
|
||||
|
||||
$isAdminProjectRequest = ! $user->isEmpty()
|
||||
&& $project->getId() !== 'console'
|
||||
&& $mode === APP_MODE_ADMIN;
|
||||
$isOAuthAdminKey = ! empty($apiKey)
|
||||
&& $apiKey->getType() === API_KEY_OAUTH2
|
||||
&& $apiKey->getRole() === User::ROLE_OWNER;
|
||||
|
||||
if ($isAdminProjectRequest && $isOAuthAdminKey) {
|
||||
$authorization->setDefaultStatus(false);
|
||||
}
|
||||
|
||||
if (!$impersonatorUser->isEmpty() && !$targetUser->isEmpty()) {
|
||||
$dbForProject->setMetadata('user', $targetUser->getId());
|
||||
$dbForPlatform->setMetadata('user', $targetUser->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* We disable authorization checks above to ensure other endpoints (list teams, members, etc.) will continue working.
|
||||
* But, for actions on resources (sites, functions, etc.) in a non-console project, we explicitly check
|
||||
* whether the admin user has necessary permission on the project (sites, functions, etc. don't have permissions associated to them).
|
||||
*/
|
||||
if (empty($apiKey) && ! $user->isEmpty() && $project->getId() !== 'console' && $mode === APP_MODE_ADMIN) {
|
||||
if ($isAdminProjectRequest && (empty($apiKey) || $isOAuthAdminKey)) {
|
||||
$input = new Input(Database::PERMISSION_READ, $project->getPermissionsByType(Database::PERMISSION_READ));
|
||||
$initialStatus = $authorization->getStatus();
|
||||
$authorization->enable();
|
||||
@@ -391,11 +371,10 @@ Http::init()
|
||||
}
|
||||
|
||||
if (! empty($user->getId())) {
|
||||
$impersonatorUserId = $user->getAttribute('impersonatorUserId');
|
||||
$accessedAt = $user->getAttribute('accessedAt', 0);
|
||||
|
||||
// Skip updating accessedAt for impersonated requests so we don't attribute activity to the target user.
|
||||
if (! $impersonatorUserId && DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_USER_ACCESS)) > $accessedAt) {
|
||||
if ($impersonatorUser->isEmpty() && DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_USER_ACCESS)) > $accessedAt) {
|
||||
$user->setAttribute('accessedAt', DateTime::now());
|
||||
|
||||
if ($project->getId() !== 'console' && $mode !== APP_MODE_ADMIN) {
|
||||
@@ -410,6 +389,8 @@ Http::init()
|
||||
}
|
||||
}
|
||||
|
||||
$rolesSource = $impersonatorUser->isEmpty() ? $user : $targetUser;
|
||||
|
||||
// Steps 7-9: Access Control - Method, Namespace and Scope Validation
|
||||
$method = $route->getLabel('sdk', false);
|
||||
|
||||
@@ -425,7 +406,7 @@ Http::init()
|
||||
if (
|
||||
array_key_exists($namespace, $project->getAttribute('services', []))
|
||||
&& ! $project->getAttribute('services', [])[$namespace]
|
||||
&& ! ($user->isPrivileged($authorization->getRoles()) || $user->isKey($authorization->getRoles()))
|
||||
&& ! ($rolesSource->isPrivileged($authorization->getRoles()) || $rolesSource->isKey($authorization->getRoles()))
|
||||
) {
|
||||
throw new Exception(Exception::GENERAL_SERVICE_DISABLED);
|
||||
}
|
||||
@@ -435,7 +416,7 @@ Http::init()
|
||||
if (
|
||||
array_key_exists('rest', $project->getAttribute('apis', []))
|
||||
&& ! $project->getAttribute('apis', [])['rest']
|
||||
&& ! ($user->isPrivileged($authorization->getRoles()) || $user->isKey($authorization->getRoles()))
|
||||
&& ! ($rolesSource->isPrivileged($authorization->getRoles()) || $rolesSource->isKey($authorization->getRoles()))
|
||||
) {
|
||||
throw new AppwriteException(AppwriteException::GENERAL_API_DISABLED);
|
||||
}
|
||||
@@ -447,20 +428,20 @@ Http::init()
|
||||
}
|
||||
|
||||
// Step 10: Check if user is blocked
|
||||
if ($user->getAttribute('status') === false) { // Account is blocked
|
||||
if ($rolesSource->getAttribute('status') === false) { // Account is blocked
|
||||
throw new Exception(Exception::USER_BLOCKED);
|
||||
}
|
||||
|
||||
// Step 11: Verify password status
|
||||
if ($user->getAttribute('reset')) {
|
||||
if ($rolesSource->getAttribute('reset')) {
|
||||
throw new Exception(Exception::USER_PASSWORD_RESET_REQUIRED);
|
||||
}
|
||||
|
||||
// Step 12: Validate MFA requirements
|
||||
$mfaEnabled = $user->getAttribute('mfa', false);
|
||||
$hasVerifiedEmail = $user->getAttribute('emailVerification', false);
|
||||
$hasVerifiedPhone = $user->getAttribute('phoneVerification', false);
|
||||
$hasVerifiedAuthenticator = TOTP::getAuthenticatorFromUser($user)?->getAttribute('verified') ?? false;
|
||||
$mfaEnabled = $rolesSource->getAttribute('mfa', false);
|
||||
$hasVerifiedEmail = $rolesSource->getAttribute('emailVerification', false);
|
||||
$hasVerifiedPhone = $rolesSource->getAttribute('phoneVerification', false);
|
||||
$hasVerifiedAuthenticator = TOTP::getAuthenticatorFromUser($rolesSource)?->getAttribute('verified') ?? false;
|
||||
$hasMoreFactors = $hasVerifiedEmail || $hasVerifiedPhone || $hasVerifiedAuthenticator;
|
||||
$minimumFactors = ($mfaEnabled && $hasMoreFactors) ? 2 : 1;
|
||||
|
||||
@@ -566,10 +547,13 @@ Http::init()
|
||||
->inject('platform')
|
||||
->inject('authorization')
|
||||
->inject('cacheControlForStorage')
|
||||
->action(function (Route $route, Request $request, Response $response, Document $project, User $user, Event $queueForEvents, AuditContext $auditContext, Context $usage, FunctionPublisher $publisherForFunctions, Database $dbForProject, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Telemetry $telemetry, array $platform, Authorization $authorization, callable $cacheControlForStorage) {
|
||||
->inject('impersonatorUser')
|
||||
->inject('targetUser')
|
||||
->action(function (Route $route, Request $request, Response $response, Document $project, User $user, Event $queueForEvents, AuditContext $auditContext, Context $usage, FunctionPublisher $publisherForFunctions, Database $dbForProject, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Telemetry $telemetry, array $platform, Authorization $authorization, callable $cacheControlForStorage, Document $impersonatorUser, User $targetUser) {
|
||||
|
||||
$response->setUser($user);
|
||||
$request->setUser($user);
|
||||
$response->setUser($targetUser);
|
||||
$response->setImpersonatorUser($impersonatorUser);
|
||||
$request->setUser($targetUser);
|
||||
|
||||
$path = $route->getPath();
|
||||
$databaseType = match (true) {
|
||||
@@ -588,7 +572,7 @@ Http::init()
|
||||
$queueForEvents
|
||||
->setEvent($route->getLabel('event', ''))
|
||||
->setProject($project)
|
||||
->setUser($user);
|
||||
->setUser($targetUser);
|
||||
|
||||
$auditContext->mode = $mode;
|
||||
$auditContext->userAgent = $request->getUserAgent('');
|
||||
@@ -596,24 +580,27 @@ Http::init()
|
||||
$auditContext->hostname = $request->getHostname();
|
||||
$auditContext->event = $route->getLabel('audits.event', '');
|
||||
$auditContext->project = $project;
|
||||
$auditContext->impersonatorUser = $impersonatorUser->isEmpty() ? null : $impersonatorUser;
|
||||
|
||||
/* If a session exists, use the user associated with the session */
|
||||
if (! $user->isEmpty()) {
|
||||
$userClone = clone $user;
|
||||
/* If a session exists, use the target user (impersonated target or actor) for audit */
|
||||
if (! $targetUser->isEmpty()) {
|
||||
$userClone = clone $targetUser;
|
||||
// $user doesn't support `type` and can cause unintended effects.
|
||||
if (empty($user->getAttribute('type'))) {
|
||||
if (empty($targetUser->getAttribute('type'))) {
|
||||
$userClone->setAttribute('type', $mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER);
|
||||
}
|
||||
$auditContext->user = $userClone;
|
||||
}
|
||||
|
||||
$rolesSource = $impersonatorUser->isEmpty() ? $user : $targetUser;
|
||||
|
||||
$useCache = $route->getLabel('cache', false);
|
||||
$storageCacheOperationsCounter = $telemetry->createCounter('storage.cache.operations.load');
|
||||
if ($useCache) {
|
||||
$roles = $authorization->getRoles();
|
||||
$isAppUser = $user->isKey($roles);
|
||||
$isAppUser = $rolesSource->isKey($roles);
|
||||
$isImageTransformation = $route->getPath() === '/v1/storage/buckets/:bucketId/files/:fileId/preview';
|
||||
$isDisabled = isset($plan['imageTransformations']) && $plan['imageTransformations'] === -1 && ! $user->isPrivileged($roles);
|
||||
$isDisabled = isset($plan['imageTransformations']) && $plan['imageTransformations'] === -1 && ! $rolesSource->isPrivileged($roles);
|
||||
|
||||
$key = $request->cacheIdentifier();
|
||||
Span::add('storage.cache.key', $key);
|
||||
@@ -903,24 +890,31 @@ Http::shutdown()
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('user')
|
||||
->inject('targetUser')
|
||||
->inject('auditContext')
|
||||
->inject('publisherForAudits')
|
||||
->inject('mode')
|
||||
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, AuditContext $auditContext, Audit $publisherForAudits, string $mode) use ($parseLabel) {
|
||||
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, User $targetUser, AuditContext $auditContext, Audit $publisherForAudits, string $mode) {
|
||||
$responsePayload = $response->getPayload();
|
||||
|
||||
$pattern = $route->getLabel('audits.resource', null);
|
||||
if (! empty($pattern)) {
|
||||
$resource = $parseLabel($pattern, $responsePayload, $params, $user, $project);
|
||||
$renderer = new Renderer(new Document([
|
||||
'user' => (array) $targetUser,
|
||||
'project' => $project,
|
||||
'request' => $params,
|
||||
'response' => $responsePayload,
|
||||
]));
|
||||
$resource = $renderer->render($pattern);
|
||||
if (! empty($resource) && $resource !== $pattern) {
|
||||
$auditContext->resource = $resource;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $user->isEmpty()) {
|
||||
$userClone = clone $user;
|
||||
if (! $targetUser->isEmpty()) {
|
||||
$userClone = clone $targetUser;
|
||||
// $user doesn't support `type` and can cause unintended effects.
|
||||
if (empty($user->getAttribute('type'))) {
|
||||
if (empty($targetUser->getAttribute('type'))) {
|
||||
$userClone->setAttribute('type', $mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER);
|
||||
}
|
||||
$auditContext->user = $userClone;
|
||||
@@ -970,7 +964,7 @@ Http::shutdown()
|
||||
->inject('user')
|
||||
->inject('dbForProject')
|
||||
->inject('authorization')
|
||||
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, Database $dbForProject, Authorization $authorization) use ($parseLabel) {
|
||||
->action(function (Route $route, array $params, Request $request, Response $response, Document $project, User $user, Database $dbForProject, Authorization $authorization) {
|
||||
if (! $route->getLabel('cache', false)) {
|
||||
return;
|
||||
}
|
||||
@@ -1000,11 +994,18 @@ Http::shutdown()
|
||||
$resourcePattern = $route->getLabel('cache.resource', null);
|
||||
$resourceTypePattern = $route->getLabel('cache.resourceType', null);
|
||||
|
||||
$renderer = new Renderer(new Document([
|
||||
'user' => (array) $user,
|
||||
'project' => $project,
|
||||
'request' => $requestParams,
|
||||
'response' => $data,
|
||||
]));
|
||||
|
||||
try {
|
||||
$authorization->skip(fn () => $dbForProject->createDocument('cache', new Document([
|
||||
'$id' => $key,
|
||||
'resource' => empty($resourcePattern) ? null : $parseLabel($resourcePattern, $data, $requestParams, $user, $project),
|
||||
'resourceType' => empty($resourceTypePattern) ? null : $parseLabel($resourceTypePattern, $data, $requestParams, $user, $project),
|
||||
'resource' => empty($resourcePattern) ? null : $renderer->render($resourcePattern),
|
||||
'resourceType' => empty($resourceTypePattern) ? null : $renderer->render($resourceTypePattern),
|
||||
'mimeType' => $response->getContentType(),
|
||||
'accessedAt' => $now,
|
||||
'signature' => $signature,
|
||||
|
||||
@@ -98,6 +98,7 @@ const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation=
|
||||
const APP_COMPUTE_CPUS_DEFAULT = 0.5;
|
||||
const APP_COMPUTE_MEMORY_DEFAULT = 512;
|
||||
const APP_COMPUTE_SPECIFICATION_DEFAULT = Specification::S_1VCPU_512MB;
|
||||
const APP_SITES_BUILD_SPECIFICATION_DEFAULT = Specification::S_2VCPU_2GB;
|
||||
const APP_COMPUTE_DEPLOYMENT_MAX_RETENTION = 100 * 365; // 100 years
|
||||
const APP_SDK_PLATFORM_SERVER = 'server';
|
||||
const APP_SDK_PLATFORM_CLIENT = 'client';
|
||||
@@ -295,6 +296,11 @@ const API_KEY_STANDARD = 'standard';
|
||||
const API_KEY_EPHEMERAL = 'ephemeral';
|
||||
const API_KEY_ORGANIZATION = 'organization';
|
||||
const API_KEY_ACCOUNT = 'account';
|
||||
const API_KEY_OAUTH2 = 'oauth2';
|
||||
|
||||
// Realtime
|
||||
const CONSOLE_TAIL_CHANNEL_PREFIX = 'console.tail';
|
||||
|
||||
// Usage metrics
|
||||
const METRIC_TEAMS = 'teams';
|
||||
const METRIC_USERS = 'users';
|
||||
|
||||
@@ -271,7 +271,7 @@ return function (Container $container): void {
|
||||
$user = new User([]);
|
||||
}
|
||||
|
||||
$authJWT = $request->getHeaderLine('x-appwrite-jwt', '');
|
||||
$authJWT = $request->getHeaderLine('x-appwrite-jwt', (string)($request->getParam('jwt', '')));
|
||||
if (!empty($authJWT) && !$project->isEmpty()) {
|
||||
if (!$user->isEmpty()) {
|
||||
throw new Exception(Exception::USER_JWT_AND_COOKIE_SET);
|
||||
@@ -327,42 +327,76 @@ return function (Container $container): void {
|
||||
}
|
||||
}
|
||||
|
||||
$dbForPlatform->setMetadata('user', $user->getId());
|
||||
$dbForProject->setMetadata('user', $user->getId());
|
||||
|
||||
return $user;
|
||||
}, ['request', 'project', 'console', 'authorization']);
|
||||
|
||||
$container->set('impersonatorUser', function (Request $request, Document $project, Document $user, Authorization $authorization) use ($getMode, $getDbForPlatform, $getDbForProject) {
|
||||
if ($user->isEmpty() || !$user->getAttribute('impersonator', false)) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
// 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->getHeaderLine('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeaderLine('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeaderLine('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
|
||||
if (!$user->isEmpty() && $user->getAttribute('impersonator', false)) {
|
||||
$userDb = ($mode === APP_MODE_ADMIN || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
$targetUser = null;
|
||||
|
||||
if (!empty($impersonateUserId)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->findOne('users', [
|
||||
Query::equal('email', [\strtolower($impersonateEmail)]),
|
||||
]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->findOne('users', [
|
||||
Query::equal('phone', [$impersonatePhone]),
|
||||
]));
|
||||
}
|
||||
|
||||
if ($targetUser !== null && !$targetUser->isEmpty()) {
|
||||
$impersonator = clone $user;
|
||||
$user = clone $targetUser;
|
||||
$user->setAttribute('impersonatorUserId', $impersonator->getId());
|
||||
$user->setAttribute('impersonatorUserInternalId', $impersonator->getSequence());
|
||||
$user->setAttribute('impersonatorUserName', $impersonator->getAttribute('name', ''));
|
||||
$user->setAttribute('impersonatorUserEmail', $impersonator->getAttribute('email', ''));
|
||||
$user->setAttribute('impersonatorAccessedAt', $impersonator->getAttribute('accessedAt', 0));
|
||||
}
|
||||
if (empty($impersonateUserId) && empty($impersonateEmail) && empty($impersonatePhone)) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
$dbForPlatform->setMetadata('user', $user->getId());
|
||||
$dbForProject->setMetadata('user', $user->getId());
|
||||
$mode = $getMode($request, $project);
|
||||
$dbForPlatform = $getDbForPlatform($authorization);
|
||||
$dbForProject = $getDbForProject($project, $authorization);
|
||||
$userDb = ($mode === APP_MODE_ADMIN || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
|
||||
$targetUser = null;
|
||||
if (!empty($impersonateUserId)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->findOne('users', [Query::equal('email', [\strtolower($impersonateEmail)])]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
$targetUser = $authorization->skip(fn () => $userDb->findOne('users', [Query::equal('phone', [$impersonatePhone])]));
|
||||
}
|
||||
|
||||
if ($targetUser === null || $targetUser->isEmpty()) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
return new Document([
|
||||
'$id' => $user->getId(),
|
||||
'$sequence' => $user->getSequence(),
|
||||
'name' => $user->getAttribute('name', ''),
|
||||
'email' => $user->getAttribute('email', ''),
|
||||
'type' => $user->getAttribute('type', $mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER),
|
||||
]);
|
||||
}, ['request', 'project', 'user', 'authorization']);
|
||||
|
||||
$container->set('targetUser', function (Request $request, Document $project, Document $user, Document $impersonatorUser, Authorization $authorization) use ($getMode, $getDbForPlatform, $getDbForProject) {
|
||||
if ($impersonatorUser->isEmpty()) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$impersonateUserId = $request->getHeaderLine('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeaderLine('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeaderLine('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
|
||||
$mode = $getMode($request, $project);
|
||||
$dbForPlatform = $getDbForPlatform($authorization);
|
||||
$dbForProject = $getDbForProject($project, $authorization);
|
||||
$userDb = ($mode === APP_MODE_ADMIN || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
|
||||
if (!empty($impersonateUserId)) {
|
||||
return $authorization->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
return $authorization->skip(fn () => $userDb->findOne('users', [Query::equal('email', [\strtolower($impersonateEmail)])]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
return $authorization->skip(fn () => $userDb->findOne('users', [Query::equal('phone', [$impersonatePhone])]));
|
||||
}
|
||||
|
||||
return $user;
|
||||
}, ['request', 'project', 'console', 'authorization']);
|
||||
}, ['request', 'project', 'user', 'impersonatorUser', 'authorization']);
|
||||
};
|
||||
@@ -110,6 +110,66 @@ return function (Container $context): void {
|
||||
$context->set('queueForRealtime', fn () => new Realtime(), []);
|
||||
$context->set('usage', fn () => new UsageContext(), []);
|
||||
$context->set('auditContext', fn () => new AuditContext(), []);
|
||||
|
||||
$context->set('impersonatorUser', function (string $mode, Document $project, Document $user, Request $request, Database $dbForProject, Database $dbForPlatform) {
|
||||
if ($user->isEmpty() || !$user->getAttribute('impersonator', false)) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
// 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->getHeaderLine('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeaderLine('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeaderLine('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
|
||||
if (empty($impersonateUserId) && empty($impersonateEmail) && empty($impersonatePhone)) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
$userDb = (APP_MODE_ADMIN === $mode || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
$targetUser = null;
|
||||
if (!empty($impersonateUserId)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('email', [\strtolower($impersonateEmail)])]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('phone', [$impersonatePhone])]));
|
||||
}
|
||||
|
||||
if ($targetUser === null || $targetUser->isEmpty()) {
|
||||
return new Document();
|
||||
}
|
||||
|
||||
return new Document([
|
||||
'$id' => $user->getId(),
|
||||
'$sequence' => $user->getSequence(),
|
||||
'name' => $user->getAttribute('name', ''),
|
||||
'email' => $user->getAttribute('email', ''),
|
||||
'type' => $user->getAttribute('type', $mode === APP_MODE_ADMIN ? ACTOR_TYPE_ADMIN : ACTOR_TYPE_USER),
|
||||
]);
|
||||
}, ['mode', 'project', 'user', 'request', 'dbForProject', 'dbForPlatform']);
|
||||
|
||||
$context->set('targetUser', function (Document $user, Document $impersonatorUser, string $mode, Document $project, Request $request, Database $dbForProject, Database $dbForPlatform) {
|
||||
if ($impersonatorUser->isEmpty()) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$impersonateUserId = $request->getHeaderLine('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeaderLine('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeaderLine('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
|
||||
$userDb = (APP_MODE_ADMIN === $mode || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
if (!empty($impersonateUserId)) {
|
||||
return $userDb->getAuthorization()->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
return $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('email', [\strtolower($impersonateEmail)])]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
return $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('phone', [$impersonatePhone])]));
|
||||
}
|
||||
|
||||
return $user;
|
||||
}, ['user', 'impersonatorUser', 'mode', 'project', 'request', 'dbForProject', 'dbForPlatform']);
|
||||
|
||||
$context->set('publisherForFunctions', fn (Publisher $publisher) => new FunctionPublisher(
|
||||
$publisher,
|
||||
new Queue(System::getEnv('_APP_FUNCTIONS_QUEUE_NAME', Event::FUNCTIONS_QUEUE_NAME), 'utopia-queue', Event::FUNCTIONS_QUEUE_TTL)
|
||||
@@ -488,33 +548,6 @@ return function (Container $context): void {
|
||||
}
|
||||
}
|
||||
|
||||
// Impersonation: if current user has impersonator capability and headers/params are set, act as another user
|
||||
// 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->getHeaderLine('x-appwrite-impersonate-user-id', (string)($request->getParam('impersonateuserid', '') ?: $request->getParam('impersonateUserId', '')));
|
||||
$impersonateEmail = $request->getHeaderLine('x-appwrite-impersonate-user-email', (string)($request->getParam('impersonateemail', '') ?: $request->getParam('impersonateEmail', '')));
|
||||
$impersonatePhone = $request->getHeaderLine('x-appwrite-impersonate-user-phone', (string)($request->getParam('impersonatephone', '') ?: $request->getParam('impersonatePhone', '')));
|
||||
if (!$user->isEmpty() && $user->getAttribute('impersonator', false)) {
|
||||
$userDb = (APP_MODE_ADMIN === $mode || $project->getId() === 'console') ? $dbForPlatform : $dbForProject;
|
||||
$targetUser = null;
|
||||
if (!empty($impersonateUserId)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->getDocument('users', $impersonateUserId));
|
||||
} elseif (!empty($impersonateEmail)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('email', [\strtolower($impersonateEmail)])]));
|
||||
} elseif (!empty($impersonatePhone)) {
|
||||
$targetUser = $userDb->getAuthorization()->skip(fn () => $userDb->findOne('users', [Query::equal('phone', [$impersonatePhone])]));
|
||||
}
|
||||
if ($targetUser !== null && !$targetUser->isEmpty()) {
|
||||
$impersonator = clone $user;
|
||||
$user = clone $targetUser;
|
||||
$user->setAttribute('impersonatorUserId', $impersonator->getId());
|
||||
$user->setAttribute('impersonatorUserInternalId', $impersonator->getSequence());
|
||||
$user->setAttribute('impersonatorUserName', $impersonator->getAttribute('name', ''));
|
||||
$user->setAttribute('impersonatorUserEmail', $impersonator->getAttribute('email', ''));
|
||||
$user->setAttribute('impersonatorAccessedAt', $impersonator->getAttribute('accessedAt', 0));
|
||||
}
|
||||
}
|
||||
|
||||
$dbForProject->setMetadata('user', $user->getId());
|
||||
$dbForPlatform->setMetadata('user', $user->getId());
|
||||
|
||||
|
||||
+80
-11
@@ -9,6 +9,7 @@ use Appwrite\Messaging\Adapter\Realtime;
|
||||
use Appwrite\Network\Validator\Origin;
|
||||
use Appwrite\Presences\State as PresenceState;
|
||||
use Appwrite\PubSub\Adapter\Pool as PubSubPool;
|
||||
use Appwrite\Realtime\EventTailRegistry;
|
||||
use Appwrite\Realtime\Message\Dispatcher as MessageDispatcher;
|
||||
use Appwrite\Realtime\Message\Handlers\Authentication as AuthenticationHandler;
|
||||
use Appwrite\Realtime\Message\Handlers\Ping as PingHandler;
|
||||
@@ -336,6 +337,9 @@ if (!function_exists('checkForProjectUsage')) {
|
||||
|
||||
$realtime = getRealtime();
|
||||
$presenceState = new PresenceState();
|
||||
$eventTailRegistry = new EventTailRegistry(
|
||||
rate: (int) System::getEnv('_APP_REALTIME_TAIL_RATE', 50)
|
||||
);
|
||||
|
||||
$messageDispatcher = (new MessageDispatcher())
|
||||
->addHandler(new PingHandler())
|
||||
@@ -496,7 +500,7 @@ $server->onStart(function () use ($stats, $containerId, &$statsDocument) {
|
||||
}
|
||||
});
|
||||
|
||||
$server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, $realtime) {
|
||||
$server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, $realtime, $eventTailRegistry) {
|
||||
Console::success('Worker ' . $workerId . ' started successfully');
|
||||
|
||||
$telemetry = getTelemetry($workerId);
|
||||
@@ -525,6 +529,13 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
$attempts = 0;
|
||||
$start = time();
|
||||
|
||||
// Flush coalesced console live-tail buffers to their connections (~150ms).
|
||||
// Must run per-worker: the registry is mutated by this worker's subscribe handler
|
||||
// and pub/sub ingest, which are not visible to the master process.
|
||||
Timer::tick(150, function () use ($server, $eventTailRegistry) {
|
||||
$eventTailRegistry->flush($server);
|
||||
});
|
||||
|
||||
Timer::tick(5000, function () use ($server, $realtime, $stats) {
|
||||
/**
|
||||
* Sending current connections to project channels on the console project every 5 seconds.
|
||||
@@ -634,7 +645,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
Console::error('Pub/sub failed (worker: ' . $workerId . ')');
|
||||
}
|
||||
|
||||
$pubsub->subscribe(['realtime'], function (mixed $redis, string $channel, string $payload) use ($server, $workerId, $stats, $register, $realtime) {
|
||||
$pubsub->subscribe(['realtime'], function (mixed $redis, string $channel, string $payload) use ($server, $workerId, $stats, $register, $realtime, $eventTailRegistry) {
|
||||
$event = json_decode($payload, true);
|
||||
|
||||
$eventTimestamp = $event['data']['timestamp'] ?? null;
|
||||
@@ -675,6 +686,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
foreach (\array_keys($connections) as $connection) {
|
||||
$subscriptionsBefore = \count($realtime->getSubscriptionMetadata($connection));
|
||||
$authorization = $realtime->connections[$connection]['authorization'] ?? null;
|
||||
$impersonatedUserId = $realtime->connections[$connection]['impersonatedUserId'] ?? null;
|
||||
$previousUserId = $realtime->connections[$connection]['userId'] ?? '';
|
||||
|
||||
$meta = $realtime->getSubscriptionMetadata($connection);
|
||||
@@ -709,6 +721,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
}
|
||||
if ($authorization !== null && isset($realtime->connections[$connection])) {
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
$realtime->connections[$connection]['impersonatedUserId'] = $impersonatedUserId;
|
||||
}
|
||||
|
||||
$subscriptionsAfter = \count($realtime->getSubscriptionMetadata($connection));
|
||||
@@ -716,6 +729,11 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
if ($subscriptionDelta !== 0) {
|
||||
$register->get('telemetry.workerSubscriptionCounter')->add($subscriptionDelta, $register->get('telemetry.workerAttributes'));
|
||||
}
|
||||
|
||||
// Tail entries live outside the subscription tree, so the rebuild
|
||||
// above doesn't touch them. Drop any whose authorizing team role
|
||||
// the connection no longer holds (membership revoked / project moved).
|
||||
$eventTailRegistry->revalidateConnection($connection, $roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -797,6 +815,31 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
|
||||
|
||||
triggerStats($metrics, $projectId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Console live event tail: runs for EVERY firehose event, regardless of
|
||||
// whether it had regular subscribers ($total). The firehose is published
|
||||
// unconditionally, so a project tailed from the console with no other
|
||||
// realtime clients must still be observed here.
|
||||
//
|
||||
// Most events carry the owning project in $event['project']. But some
|
||||
// project-owned events (schema changes, deployments, rules, migrations,
|
||||
// project settings) are rerouted by fromPayload() to project='console';
|
||||
// for those the real project id lives in the `projects.<id>` channel.
|
||||
// Resolve that so the tail still receives them.
|
||||
$tailProjectId = $event['project'] ?? '';
|
||||
if ($tailProjectId === 'console') {
|
||||
$tailProjectId = '';
|
||||
foreach (($event['data']['channels'] ?? []) as $channel) {
|
||||
if (\str_starts_with($channel, 'projects.')) {
|
||||
$tailProjectId = \substr($channel, \strlen('projects.'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($tailProjectId !== '' && $eventTailRegistry->isTailed($tailProjectId)) {
|
||||
$eventTailRegistry->ingest($tailProjectId, Realtime::toTailMetadata($event), \microtime(true));
|
||||
}
|
||||
});
|
||||
} catch (Throwable $th) {
|
||||
@@ -867,14 +910,21 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
|
||||
$timelimit = $connectionContainer->get('timelimit');
|
||||
$user = $connectionContainer->get('user'); /** @var User $user */
|
||||
$impersonatorUser = $connectionContainer->get('impersonatorUser'); /** @var Document $impersonatorUser */
|
||||
$targetUser = $connectionContainer->get('targetUser'); /** @var User $targetUser */
|
||||
if (!$impersonatorUser->isEmpty()) {
|
||||
getConsoleDB()->setMetadata('user', $targetUser->getId());
|
||||
getProjectDB($project)->setMetadata('user', $targetUser->getId());
|
||||
}
|
||||
$logUser = $user;
|
||||
|
||||
$apis = $project->getAttribute('apis', []);
|
||||
// Websocket is what to check, but realtime is checked too for backwards compatibility
|
||||
$websocketEnabled = $apis['websocket'] ?? $apis['realtime'] ?? true;
|
||||
$effectiveUser = $impersonatorUser->isEmpty() ? $user : $targetUser;
|
||||
if (
|
||||
!$websocketEnabled
|
||||
&& !($user->isPrivileged($authorization->getRoles()) || $user->isKey($authorization->getRoles()))
|
||||
&& !($effectiveUser->isPrivileged($authorization->getRoles()) || $effectiveUser->isKey($authorization->getRoles()))
|
||||
) {
|
||||
throw new AppwriteException(AppwriteException::GENERAL_API_DISABLED);
|
||||
}
|
||||
@@ -917,9 +967,9 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
throw new Exception(Exception::REALTIME_POLICY_VIOLATION, $originValidator->getDescription());
|
||||
}
|
||||
|
||||
$roles = $user->getRoles($authorization);
|
||||
$roles = $targetUser->getRoles($authorization);
|
||||
|
||||
$channels = Realtime::convertChannels($request->getQuery('channels', []), $user->getId());
|
||||
$channels = Realtime::convertChannels($request->getQuery('channels', []), $targetUser->getId());
|
||||
$channelCount = \count($channels);
|
||||
|
||||
$updateStats = static function (string $projectId, ?string $teamId) use ($register, $stats): void {
|
||||
@@ -944,7 +994,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
*/
|
||||
if (empty($channels)) {
|
||||
// in case of message based 'subscribe' channels will be empty at first and only projectId and roles will be available
|
||||
$sanitizedUser = empty($user->getId()) ? null : $response->output($user, Response::MODEL_ACCOUNT);
|
||||
$sanitizedUser = empty($targetUser->getId()) ? null : $response->output($targetUser, Response::MODEL_ACCOUNT);
|
||||
$connectedPayloadJson = json_encode([
|
||||
'type' => 'connected',
|
||||
'data' => [
|
||||
@@ -954,8 +1004,9 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
]
|
||||
]);
|
||||
|
||||
$realtime->subscribe($project->getId(), $connection, '', $roles, [], [], $user->getId());
|
||||
$realtime->subscribe($project->getId(), $connection, '', $roles, [], [], $targetUser->getId());
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
$realtime->connections[$connection]['impersonatedUserId'] = $impersonatorUser->isEmpty() ? null : $targetUser->getId();
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'));
|
||||
$server->send([$connection], $connectedPayloadJson);
|
||||
$outboundBytes += \strlen($connectedPayloadJson);
|
||||
@@ -979,7 +1030,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
throw new Exception(Exception::REALTIME_POLICY_VIOLATION, $e->getMessage());
|
||||
}
|
||||
|
||||
$sanitizedUser = empty($user->getId()) ? null : $response->output($user, Response::MODEL_ACCOUNT);
|
||||
$sanitizedUser = empty($targetUser->getId()) ? null : $response->output($targetUser, Response::MODEL_ACCOUNT);
|
||||
|
||||
$mapping = [];
|
||||
foreach ($subscriptions as $index => $subscription) {
|
||||
@@ -992,13 +1043,14 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
$roles,
|
||||
$subscription['channels'],
|
||||
$subscription['queries'],
|
||||
$user->getId()
|
||||
$targetUser->getId()
|
||||
);
|
||||
|
||||
$mapping[$index] = $subscriptionId;
|
||||
}
|
||||
|
||||
$realtime->connections[$connection]['authorization'] = $authorization;
|
||||
$realtime->connections[$connection]['impersonatedUserId'] = $impersonatorUser->isEmpty() ? null : $targetUser->getId();
|
||||
$updateStats($project->getId(), $project->getAttribute('teamId'));
|
||||
|
||||
$subscriptionCount = \count($subscriptions);
|
||||
@@ -1085,7 +1137,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
||||
}
|
||||
});
|
||||
|
||||
$server->onMessage(function (int $connection, string $message) use ($container, $server, $realtime, $containerId, $register, $presenceState, $messageDispatcher) {
|
||||
$server->onMessage(function (int $connection, string $message) use ($container, $server, $realtime, $containerId, $register, $presenceState, $messageDispatcher, $eventTailRegistry) {
|
||||
$project = null;
|
||||
$authorization = null;
|
||||
$projectId = $realtime->connections[$connection]['projectId'] ?? null;
|
||||
@@ -1123,8 +1175,13 @@ $server->onMessage(function (int $connection, string $message) use ($container,
|
||||
$authorization->addRole($role);
|
||||
}
|
||||
|
||||
$impersonatedUserId = $realtime->connections[$connection]['impersonatedUserId'] ?? null;
|
||||
|
||||
$database = getConsoleDB();
|
||||
$database->setAuthorization($authorization);
|
||||
if ($impersonatedUserId !== null) {
|
||||
$database->setMetadata('user', $impersonatedUserId);
|
||||
}
|
||||
|
||||
if (!empty($projectId) && $projectId !== 'console') {
|
||||
// Negative-cache race: if any prior code path queried projects:$projectId
|
||||
@@ -1145,6 +1202,9 @@ $server->onMessage(function (int $connection, string $message) use ($container,
|
||||
|
||||
$database = getProjectDB($project);
|
||||
$database->setAuthorization($authorization);
|
||||
if ($impersonatedUserId !== null) {
|
||||
$database->setMetadata('user', $impersonatedUserId);
|
||||
}
|
||||
} else {
|
||||
$project = null;
|
||||
}
|
||||
@@ -1206,6 +1266,8 @@ $server->onMessage(function (int $connection, string $message) use ($container,
|
||||
$messageContainer->set('projectId', fn () => $projectId);
|
||||
$messageContainer->set('queueForEvents', fn () => getQueueForEvents());
|
||||
$messageContainer->set('queueForRealtime', fn () => getQueueForRealtime());
|
||||
$messageContainer->set('eventTailRegistry', fn () => $eventTailRegistry);
|
||||
$messageContainer->set('dbForConsole', fn () => getConsoleDB());
|
||||
|
||||
$responsePayload = $messageDispatcher->dispatch($messageContainer, $message);
|
||||
|
||||
@@ -1281,7 +1343,7 @@ $server->onMessage(function (int $connection, string $message) use ($container,
|
||||
}
|
||||
});
|
||||
|
||||
$server->onClose(function (int $connection) use ($realtime, $stats, $register, $container, $presenceState) {
|
||||
$server->onClose(function (int $connection) use ($realtime, $stats, $register, $container, $presenceState, $eventTailRegistry) {
|
||||
$projectId = null;
|
||||
$userId = null;
|
||||
$subscriptionsBeforeClose = 0;
|
||||
@@ -1428,6 +1490,13 @@ $server->onClose(function (int $connection) use ($realtime, $stats, $register, $
|
||||
Span::current()?->setError($th);
|
||||
}
|
||||
|
||||
try {
|
||||
$eventTailRegistry->removeConnection($connection);
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Realtime onClose tail cleanup error: ' . $th->getMessage());
|
||||
Span::current()?->setError($th);
|
||||
}
|
||||
|
||||
Span::add('realtime.success', $success);
|
||||
if (!empty($projectId)) {
|
||||
Span::add('project.id', $projectId);
|
||||
|
||||
+2
-2
@@ -58,12 +58,12 @@
|
||||
"utopia-php/analytics": "0.15.*",
|
||||
"utopia-php/audit": "2.6.*",
|
||||
"utopia-php/auth": "^0.7",
|
||||
"utopia-php/cache": "^3.0",
|
||||
"utopia-php/cache": "^3.0.0",
|
||||
"utopia-php/cli": "^0.24",
|
||||
"utopia-php/compression": "0.1.*",
|
||||
"utopia-php/config": "1.*",
|
||||
"utopia-php/console": "0.1.*",
|
||||
"utopia-php/database": "6.0.*",
|
||||
"utopia-php/database": "^6.0.0",
|
||||
"utopia-php/detector": "0.2.*",
|
||||
"utopia-php/domains": "^2.2",
|
||||
"utopia-php/emails": "0.7.*",
|
||||
|
||||
Generated
+20
-20
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "508b3e633843d61eb24f864fd8832db0",
|
||||
"content-hash": "17128527d9ef62968ea12eb43a81fdfb",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -3369,16 +3369,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
"version": "3.0.2",
|
||||
"version": "3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/cache.git",
|
||||
"reference": "086687d7ae23dd1dae67b943161e8cef143539e1"
|
||||
"reference": "d5048409cf3a8db668b00cd2e6c46a627b16d76a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/086687d7ae23dd1dae67b943161e8cef143539e1",
|
||||
"reference": "086687d7ae23dd1dae67b943161e8cef143539e1",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/d5048409cf3a8db668b00cd2e6c46a627b16d76a",
|
||||
"reference": "d5048409cf3a8db668b00cd2e6c46a627b16d76a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3417,9 +3417,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/cache/issues",
|
||||
"source": "https://github.com/utopia-php/cache/tree/3.0.2"
|
||||
"source": "https://github.com/utopia-php/cache/tree/3.1.0"
|
||||
},
|
||||
"time": "2026-05-19T22:38:16+00:00"
|
||||
"time": "2026-06-23T10:59:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/circuit-breaker",
|
||||
@@ -3676,16 +3676,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "6.0.0",
|
||||
"version": "6.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde"
|
||||
"reference": "18120ddf0bc656fc448e6c9407d2f16371d6f0a6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"reference": "fff9f0effbd40359ff925741ff9424856d8b4fde",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/18120ddf0bc656fc448e6c9407d2f16371d6f0a6",
|
||||
"reference": "18120ddf0bc656fc448e6c9407d2f16371d6f0a6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3694,7 +3694,7 @@
|
||||
"ext-pdo": "*",
|
||||
"ext-redis": "*",
|
||||
"php": ">=8.4",
|
||||
"utopia-php/cache": "^3.0",
|
||||
"utopia-php/cache": "3.1.*",
|
||||
"utopia-php/console": "0.1.*",
|
||||
"utopia-php/mongo": "1.*",
|
||||
"utopia-php/pools": "1.*",
|
||||
@@ -3730,9 +3730,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/6.0.0"
|
||||
"source": "https://github.com/utopia-php/database/tree/6.1.0"
|
||||
},
|
||||
"time": "2026-06-18T10:37:40+00:00"
|
||||
"time": "2026-06-23T11:28:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
@@ -5124,16 +5124,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/vcs",
|
||||
"version": "4.2.3",
|
||||
"version": "4.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/vcs.git",
|
||||
"reference": "598cbd2793a5a6394493f1046743e75ec6544a57"
|
||||
"reference": "f19c61daa1e9594734d85ae25b3e90ba2b350d33"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/598cbd2793a5a6394493f1046743e75ec6544a57",
|
||||
"reference": "598cbd2793a5a6394493f1046743e75ec6544a57",
|
||||
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/f19c61daa1e9594734d85ae25b3e90ba2b350d33",
|
||||
"reference": "f19c61daa1e9594734d85ae25b3e90ba2b350d33",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -5167,9 +5167,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/vcs/issues",
|
||||
"source": "https://github.com/utopia-php/vcs/tree/4.2.3"
|
||||
"source": "https://github.com/utopia-php/vcs/tree/4.2.4"
|
||||
},
|
||||
"time": "2026-06-16T12:14:08+00:00"
|
||||
"time": "2026-06-25T13:27:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/websocket",
|
||||
|
||||
@@ -10,7 +10,7 @@ services:
|
||||
networks:
|
||||
- appwrite
|
||||
ports:
|
||||
- "8082:8081"
|
||||
- "9508:8081"
|
||||
environment:
|
||||
ME_CONFIG_MONGODB_URL: "mongodb://root:${_APP_DB_ROOT_PASS}@appwrite-mongodb:27017/?replicaSet=rs0&directConnection=true"
|
||||
ME_CONFIG_BASICAUTH_USERNAME: ${_APP_DB_USER}
|
||||
@@ -76,7 +76,7 @@ services:
|
||||
- "traefik.http.routers.appwrite_redisinsight_https.service=appwrite_redisinsight"
|
||||
- "traefik.http.routers.appwrite_redisinsight_https.tls=true"
|
||||
ports:
|
||||
- "8081:5540"
|
||||
- "9514:5540"
|
||||
|
||||
graphql-explorer:
|
||||
container_name: appwrite-graphql-explorer
|
||||
@@ -87,7 +87,7 @@ services:
|
||||
ports:
|
||||
- "9509:3000"
|
||||
environment:
|
||||
- SERVER_URL=http://localhost/v1/graphql
|
||||
- SERVER_URL=http://localhost:9520/v1/graphql
|
||||
|
||||
configs:
|
||||
redisinsight-connections.json:
|
||||
|
||||
+19
-9
@@ -2,6 +2,15 @@
|
||||
# This is a development version of THE Appwrite docker-compose.yml file.
|
||||
# Avoid using this file in your production environment.
|
||||
# We're exposing here sensitive ports and mounting code volumes for rapid development and debugging of the server stack.
|
||||
#
|
||||
# Development port map (host:container)
|
||||
# -----------------------------------
|
||||
# Entry points: 9520:80 (HTTP), 9521:443 (HTTPS), 9522:80 (HTTP alt)
|
||||
# Reserve 9600-9699 for Appwrite Cloud dev when running both stacks locally.
|
||||
# 9500 Traefik dashboard, 9501 Appwrite API, 9502 Realtime, 9503 Mail catcher
|
||||
# 9504 Request catcher (webhook), 9505 Embedding, 9507 Request catcher (SMS)
|
||||
# 9510 MariaDB, 9511 MongoDB, 9512 PostgreSQL, 9513 Redis
|
||||
# Dev tools in docker-compose.override.yml: 9506 Adminer, 9508 Mongo Express, 9509 GraphQL, 9514 Redis Insight
|
||||
|
||||
x-logging: &x-logging
|
||||
logging:
|
||||
@@ -36,9 +45,9 @@ services:
|
||||
- --entrypoints.appwrite_websecure.address=:443
|
||||
- --accesslog=true
|
||||
ports:
|
||||
- 80:80
|
||||
- 8080:80
|
||||
- 443:443
|
||||
- 9520:80
|
||||
- 9522:80
|
||||
- 9521:443
|
||||
- 9500:8080
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
@@ -282,7 +291,7 @@ services:
|
||||
image: appwrite-dev
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 9505:80
|
||||
- 9502:80
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.constraint-label-stack=appwrite"
|
||||
@@ -311,6 +320,7 @@ services:
|
||||
- _APP_WORKER_PER_CORE
|
||||
- _APP_OPTIONS_ABUSE
|
||||
- _APP_OPTIONS_ROUTER_PROTECTION
|
||||
- _APP_REALTIME_TAIL_RATE
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
- _APP_REDIS_HOST
|
||||
- _APP_REDIS_PORT
|
||||
@@ -1359,7 +1369,7 @@ services:
|
||||
volumes:
|
||||
- appwrite-mariadb:/var/lib/mysql:rw
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "9510:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${_APP_DB_ROOT_PASS}
|
||||
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
||||
@@ -1386,7 +1396,7 @@ services:
|
||||
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||
- ./mongo-entrypoint.sh:/mongo-entrypoint.sh:ro
|
||||
ports:
|
||||
- "27017:27017"
|
||||
- "9511:27017"
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=root
|
||||
- MONGO_INITDB_ROOT_PASSWORD=${_APP_DB_ROOT_PASS}
|
||||
@@ -1426,7 +1436,7 @@ services:
|
||||
volumes:
|
||||
- appwrite-postgresql:/var/lib/postgresql/18/data:rw
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- "9512:5432"
|
||||
environment:
|
||||
- POSTGRES_DB=${_APP_DB_SCHEMA}
|
||||
- POSTGRES_USER=${_APP_DB_USER}
|
||||
@@ -1449,7 +1459,7 @@ services:
|
||||
EMBEDDING_MODELS: ${_APP_EMBEDDING_MODELS:-nomic-embed-text}
|
||||
container_name: appwrite-embedding
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "9505:3000"
|
||||
restart: unless-stopped
|
||||
# persistent for caching models across restarts and preloading
|
||||
volumes:
|
||||
@@ -1467,7 +1477,7 @@ services:
|
||||
--maxmemory-policy allkeys-lru
|
||||
--maxmemory-samples 5
|
||||
ports:
|
||||
- "6379:6379"
|
||||
- "9513:6379"
|
||||
networks:
|
||||
- appwrite
|
||||
volumes:
|
||||
|
||||
@@ -9,7 +9,7 @@ $ appwrite login
|
||||
? Enter your password ********
|
||||
✓ Success
|
||||
```
|
||||
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 )
|
||||
This will also prompt you to enter your Appwrite endpoint ( default: http://localhost:9520/v1 )
|
||||
|
||||
* ### Initialising your project
|
||||
Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command.
|
||||
@@ -139,5 +139,5 @@ $ appwrite client --reset
|
||||
The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using
|
||||
|
||||
```sh
|
||||
appwrite client --endpoint http://localhost/v1 --projectId <PROJECT_ID> --key <API KEY>
|
||||
appwrite client --endpoint http://localhost:9520/v1 --projectId <PROJECT_ID> --key <API KEY>
|
||||
```
|
||||
@@ -6,7 +6,7 @@ Init your Appwrite client:
|
||||
Client client = Client();
|
||||
|
||||
client
|
||||
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
|
||||
.setEndpoint('https://localhost:9521/v1') // Your Appwrite Endpoint
|
||||
.setProject('5e8cf4f46b5e8') // Your project ID
|
||||
.setSelfSigned() // Remove in production
|
||||
;
|
||||
|
||||
@@ -34,7 +34,7 @@ import { Client } from 'react-native-appwrite';
|
||||
const client = new Client();
|
||||
|
||||
client
|
||||
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
|
||||
.setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint
|
||||
.setProject('455x34dfkj') // Your project ID
|
||||
.setPlatform('com.example.myappwriteapp') // Your application ID or bundle ID.
|
||||
;
|
||||
@@ -65,7 +65,7 @@ import { Client, Account } from 'react-native-appwrite';
|
||||
const client = new Client();
|
||||
|
||||
client
|
||||
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
|
||||
.setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint
|
||||
.setProject('455x34dfkj')
|
||||
.setPlatform('com.example.myappwriteapp') // YOUR application ID
|
||||
;
|
||||
|
||||
@@ -15,7 +15,7 @@ Initialize your SDK with your Appwrite server API endpoint and project ID which
|
||||
const client = new Client();
|
||||
|
||||
client
|
||||
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
|
||||
.setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint
|
||||
.setProject('455x34dfkj') // Your project ID
|
||||
;
|
||||
```
|
||||
@@ -44,7 +44,7 @@ account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien")
|
||||
const client = new Client();
|
||||
|
||||
client
|
||||
.setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
|
||||
.setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint
|
||||
.setProject('455x34dfkj')
|
||||
;
|
||||
|
||||
|
||||
@@ -149,13 +149,13 @@ First of all, we need to start a local instance of Appwrite. Thanks to Docker, t
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
If this is your first time running Appwrite, it may take up to a few minutes to download all images and start all containers. Once everything is started, you should see Appwrite running on `http://localhost:80`. When you visit this URL, it will ask you to sign up. After that, it will show you your empty dashboard where you need to create a new project - give it any name you want. Then you need to go to `Settings` of the project and copy `Project-ID`.
|
||||
If this is your first time running Appwrite, it may take up to a few minutes to download all images and start all containers. Once everything is started, you should see Appwrite running on `http://localhost:9520`. When you visit this URL, it will ask you to sign up. After that, it will show you your empty dashboard where you need to create a new project - give it any name you want. Then you need to go to `Settings` of the project and copy `Project-ID`.
|
||||
|
||||
If you are lost in the Appwrite dashboard, check out our [Article about Appwrite's dashboard](https://dev.to/appwrite/30daysofappwrite-appwrite-dashboard-15cc).
|
||||
|
||||
Now, let's send the request. We will be editing headers of the request, so you will need a tool to do that, such as Postman or Insomnia.
|
||||
|
||||
First, let's see English translations. Let's set request type to `GET`, URL to `https://localhost/v1/locale/countries/eu` and add `X-Appwrite-Project` header.
|
||||
First, let's see English translations. Let's set request type to `GET`, URL to `https://localhost:9521/v1/locale/countries/eu` and add `X-Appwrite-Project` header.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ class Audit
|
||||
public function __construct(
|
||||
public ?Document $project = null,
|
||||
public ?Document $user = null,
|
||||
public ?Document $impersonatorUser = null,
|
||||
public string $mode = '',
|
||||
public string $userAgent = '',
|
||||
public string $ip = '',
|
||||
@@ -23,6 +24,7 @@ class Audit
|
||||
{
|
||||
return $this->project === null
|
||||
&& $this->user === null
|
||||
&& $this->impersonatorUser === null
|
||||
&& $this->mode === ''
|
||||
&& $this->userAgent === ''
|
||||
&& $this->ip === ''
|
||||
|
||||
@@ -12,6 +12,7 @@ final class Audit extends Base
|
||||
public readonly array $payload,
|
||||
public readonly Document $project = new Document(),
|
||||
public readonly Document $user = new Document(),
|
||||
public readonly Document $impersonatorUser = new Document(),
|
||||
public readonly string $resource = '',
|
||||
public readonly string $mode = '',
|
||||
public readonly string $ip = '',
|
||||
@@ -29,6 +30,7 @@ final class Audit extends Base
|
||||
'database' => $this->project->getAttribute('database', ''),
|
||||
],
|
||||
'user' => $this->user->getArrayCopy(),
|
||||
'impersonatorUser' => $this->impersonatorUser->getArrayCopy(),
|
||||
'payload' => $this->payload,
|
||||
'resource' => $this->resource,
|
||||
'mode' => $this->mode,
|
||||
@@ -46,6 +48,7 @@ final class Audit extends Base
|
||||
payload: $data['payload'] ?? [],
|
||||
project: new Document($data['project'] ?? []),
|
||||
user: new Document($data['user'] ?? []),
|
||||
impersonatorUser: new Document($data['impersonatorUser'] ?? []),
|
||||
resource: $data['resource'] ?? '',
|
||||
mode: $data['mode'] ?? '',
|
||||
ip: $data['ip'] ?? '',
|
||||
@@ -61,6 +64,7 @@ final class Audit extends Base
|
||||
payload: $context->payload,
|
||||
project: $context->project ?? new Document(),
|
||||
user: $context->user ?? new Document(),
|
||||
impersonatorUser: $context->impersonatorUser ?? new Document(),
|
||||
resource: $context->resource,
|
||||
mode: $context->mode,
|
||||
ip: $context->ip,
|
||||
|
||||
@@ -50,13 +50,17 @@ class Headers extends Validator
|
||||
|
||||
$size = 0;
|
||||
foreach ($value as $key => $val) {
|
||||
$length = \strlen($key);
|
||||
// Reject non-string keys
|
||||
if (!\is_string($key) || $length === 0) {
|
||||
if (!\is_string($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$size += $length + \strlen($val);
|
||||
$length = \strlen($key);
|
||||
if ($length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$size += $length + \strlen($val ?? '');
|
||||
if ($size >= $this->maxSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ class Realtime extends MessagingAdapter
|
||||
{
|
||||
public const SUPPORTED_ACTIONS = ['create', 'update', 'upsert', 'delete'];
|
||||
|
||||
// The database family is published under several event prefixes (legacy `databases`
|
||||
// plus the per-type projections). They share the same `databases.<db>.<collections|tables>.<id>…`
|
||||
// shape, so the tail normalizes them to `databases` for consistent metadata + filtering.
|
||||
public const DATABASE_EVENT_PREFIXES = ['databases', 'tablesdb', 'documentsdb', 'vectorsdb'];
|
||||
|
||||
// Resources whose channels receive an action-suffixed sibling at publish time.
|
||||
// The suffix loop in fromPayload() treats any channel whose last OR second-to-last
|
||||
// segment matches an entry here as a candidate for `.{action}` suffixing.
|
||||
@@ -500,6 +505,90 @@ class Realtime extends MessagingAdapter
|
||||
return $receivers;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array<string,mixed> $event decoded event published to the `realtime` channel
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function toTailMetadata(array $event): array
|
||||
{
|
||||
$events = $event['data']['events'] ?? [];
|
||||
$name = \is_array($events) ? ($events[0] ?? '') : '';
|
||||
$parts = $name === '' ? [] : \explode('.', $name);
|
||||
$count = \count($parts);
|
||||
$type = $parts[0] ?? null;
|
||||
|
||||
// The database family is published under several prefixes (databases/tablesdb/
|
||||
// documentsdb/vectorsdb). `type` keeps the actual prefix (more informative), but
|
||||
// scope ids are extracted for all of them so databaseId/collectionId filters work
|
||||
// across the whole family.
|
||||
$isDatabaseFamily = \in_array($type, self::DATABASE_EVENT_PREFIXES, true);
|
||||
|
||||
$action = null;
|
||||
if ($count >= 1 && \in_array($parts[$count - 1], self::SUPPORTED_ACTIONS, true)) {
|
||||
$action = $parts[$count - 1];
|
||||
} elseif ($count >= 2 && \in_array($parts[$count - 2], self::SUPPORTED_ACTIONS, true)) {
|
||||
$action = $parts[$count - 2];
|
||||
}
|
||||
|
||||
$payload = $event['data']['payload'] ?? [];
|
||||
if (!\is_array($payload)) {
|
||||
$payload = [];
|
||||
}
|
||||
|
||||
$metadata = [
|
||||
'event' => $name,
|
||||
'type' => $type,
|
||||
'action' => $action,
|
||||
'userId' => $event['userId'] ?? null,
|
||||
'timestamp' => $event['data']['timestamp'] ?? null,
|
||||
'resourceId' => $payload['$id'] ?? null,
|
||||
];
|
||||
|
||||
// Attach only the scope ids that belong to this resource type. Derived from the
|
||||
// (concrete) event name rather than the payload: for a top-level resource event
|
||||
// (e.g. `teams.T.create`) the payload's id lives at $id, not at a teamId field,
|
||||
// so a payload lookup would drop the scope and silently break filters. The event
|
||||
// name encodes the id at every level — parts[1] is the top-level resource id and
|
||||
// parts[3] the collection/table id.
|
||||
$scope = [];
|
||||
if ($isDatabaseFamily) {
|
||||
if (isset($parts[1])) {
|
||||
$scope['databaseId'] = $parts[1];
|
||||
}
|
||||
if (isset($parts[2], $parts[3]) && \in_array($parts[2], ['collections', 'tables'], true)) {
|
||||
$scope['collectionId'] = $parts[3];
|
||||
}
|
||||
} else {
|
||||
switch ($type) {
|
||||
case 'buckets':
|
||||
if (isset($parts[1])) {
|
||||
$scope['bucketId'] = $parts[1];
|
||||
}
|
||||
break;
|
||||
case 'functions':
|
||||
if (isset($parts[1])) {
|
||||
$scope['functionId'] = $parts[1];
|
||||
}
|
||||
break;
|
||||
case 'teams':
|
||||
if (isset($parts[1])) {
|
||||
$scope['teamId'] = $parts[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($scope as $key => $value) {
|
||||
// Skip wildcard/empty segments (defensive: events[0] is concrete, but guard anyway).
|
||||
if ($value !== '' && $value !== '*') {
|
||||
$metadata[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the channels from the Query Params into an array.
|
||||
* Also renames the account channel to account.USER_ID, rewrites action-suffixed
|
||||
|
||||
@@ -33,29 +33,38 @@ class Base extends Action
|
||||
* @param array $plan The billing plan configuration
|
||||
* @return string The appropriate default specification
|
||||
*/
|
||||
protected function getDefaultSpecification(array $plan): string
|
||||
protected function getDefaultSpecification(array $plan, string $planKey = 'runtimeSpecifications', string $fallback = APP_COMPUTE_SPECIFICATION_DEFAULT, bool $preferFallback = false): string
|
||||
{
|
||||
$specifications = Config::getParam('specifications', []);
|
||||
|
||||
if (empty($specifications)) {
|
||||
return APP_COMPUTE_SPECIFICATION_DEFAULT;
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
$specificationValidator = new SpecificationValidator(
|
||||
$plan,
|
||||
$specifications,
|
||||
System::getEnv('_APP_COMPUTE_CPUS', 0),
|
||||
System::getEnv('_APP_COMPUTE_MEMORY', 0)
|
||||
System::getEnv('_APP_COMPUTE_MEMORY', 0),
|
||||
$planKey
|
||||
);
|
||||
$allowedSpecifications = $specificationValidator->getAllowedSpecifications();
|
||||
|
||||
if (empty($allowedSpecifications)) {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
if ($preferFallback && !array_key_exists($planKey, $plan) && \in_array($fallback, $allowedSpecifications)) {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
// If there is no plan use the highest specification
|
||||
if (empty($plan)) {
|
||||
return end($allowedSpecifications) ?? APP_COMPUTE_SPECIFICATION_DEFAULT;
|
||||
return end($allowedSpecifications);
|
||||
}
|
||||
|
||||
// Otherwise, use the lowest specification available in the plan
|
||||
return $allowedSpecifications[0] ?? APP_COMPUTE_SPECIFICATION_DEFAULT;
|
||||
return $allowedSpecifications[0];
|
||||
}
|
||||
|
||||
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document
|
||||
|
||||
@@ -14,12 +14,15 @@ class Specification extends Validator
|
||||
|
||||
private int $maxMemory;
|
||||
|
||||
public function __construct(array $plan, array $specifications, float $maxCpus, int $maxMemory)
|
||||
private string $planKey;
|
||||
|
||||
public function __construct(array $plan, array $specifications, float $maxCpus, int $maxMemory, string $planKey = 'runtimeSpecifications')
|
||||
{
|
||||
$this->plan = $plan;
|
||||
$this->specifications = $specifications;
|
||||
$this->maxCpus = $maxCpus;
|
||||
$this->maxMemory = $maxMemory;
|
||||
$this->planKey = $planKey;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,8 +38,8 @@ class Specification extends Validator
|
||||
|
||||
foreach ($this->specifications as $size => $values) {
|
||||
if ((empty($this->maxCpus) || $values['cpus'] <= $this->maxCpus) && (empty($this->maxMemory) || $values['memory'] <= $this->maxMemory)) {
|
||||
if (!empty($this->plan) && array_key_exists('runtimeSpecifications', $this->plan)) {
|
||||
if (!\in_array($size, $this->plan['runtimeSpecifications'])) {
|
||||
if (!empty($this->plan) && array_key_exists($this->planKey, $this->plan)) {
|
||||
if (!\in_array($size, $this->plan[$this->planKey])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -42,6 +42,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Delete extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -45,6 +45,7 @@ class Get extends Action
|
||||
->desc('Get attribute')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ class Create extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].create')
|
||||
->label('audits.event', 'attribute.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].attributes.[attributeId].update')
|
||||
->label('audits.event', 'attribute.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ class XList extends Action
|
||||
->desc('List attributes')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
|
||||
@@ -56,6 +56,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'collection.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{response.$id}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{response.$id}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -41,6 +41,7 @@ class Delete extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].delete')
|
||||
->label('audits.event', 'collection.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ class Decrement extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ class Increment extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ class Delete extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ class Update extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ class Upsert extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'document.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -67,6 +67,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'document.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ class Delete extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].delete')
|
||||
->label('audits.event', 'document.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{request.documentId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{request.documentId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
@@ -43,6 +43,7 @@ class Get extends Action
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'documents.read')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{request.documentId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
+1
@@ -53,6 +53,7 @@ class Update extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'document.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ class Upsert extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'document.upsert')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}/document/{response.$id}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
@@ -51,6 +51,7 @@ class XList extends Action
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'documents.read')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}/documents')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -34,6 +34,7 @@ class Get extends Action
|
||||
->desc('Get collection')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -52,6 +52,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'index.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -47,6 +47,7 @@ class Delete extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].indexes.[indexId].update')
|
||||
->label('audits.event', 'index.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -35,6 +35,7 @@ class Get extends Action
|
||||
->desc('Get index')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
|
||||
@@ -41,6 +41,7 @@ class XList extends Action
|
||||
->desc('List indexes')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: $this->getSDKNamespace(),
|
||||
|
||||
@@ -44,6 +44,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].update')
|
||||
->label('audits.event', 'collection.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collections/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collections/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
group: $this->getSDKGroup(),
|
||||
|
||||
@@ -42,6 +42,7 @@ class XList extends Action
|
||||
->desc('List collections')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -147,6 +147,7 @@ class Create extends Action
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'database.create')
|
||||
->label('audits.resource', 'database/{response.$id}')
|
||||
->label('usage.resource', 'database/{response.$id}')
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -35,6 +35,7 @@ class Delete extends Action
|
||||
->label('event', 'databases.[databaseId].delete')
|
||||
->label('audits.event', 'database.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -28,6 +28,7 @@ class Get extends Action
|
||||
->desc('Get database')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'databases.read')
|
||||
->label('usage.resource', 'database/{request.databaseId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
|
||||
@@ -33,6 +33,7 @@ class Get extends Action
|
||||
->desc('Get transaction')
|
||||
->groups(['api', 'database', 'transactions'])
|
||||
->label('scope', 'rows.read')
|
||||
->label('usage.resource', 'transaction/{request.transactionId}')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -35,6 +35,7 @@ class Update extends Action
|
||||
->label('event', 'databases.[databaseId].update')
|
||||
->label('audits.event', 'database.update')
|
||||
->label('audits.resource', 'database/{response.$id}')
|
||||
->label('usage.resource', 'database/{response.$id}')
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
namespace: 'databases',
|
||||
|
||||
@@ -43,6 +43,7 @@ class Create extends CollectionCreate
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'collections.create')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{response.$id}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{response.$id}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'documentsDB',
|
||||
group: 'collections',
|
||||
|
||||
@@ -35,6 +35,7 @@ class Delete extends CollectionDelete
|
||||
->label('event', 'databases.[databaseId].collections.[collectionId].delete')
|
||||
->label('audits.event', 'collection.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'documentsDB',
|
||||
group: 'collections',
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ class Decrement extends DecrementDocumentAttribute
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ class Increment extends IncrementDocumentAttribute
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -36,6 +36,7 @@ class Delete extends DocumentsDelete
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.delete')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ class Update extends DocumentsUpdate
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'documents.update')
|
||||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('abuse-key', 'ip:{ip},method:{method},url:{url},userId:{userId}')
|
||||
->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT * 2)
|
||||
->label('abuse-time', APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT)
|
||||
|
||||
Loaded 100 of 318 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user