diff --git a/.env b/.env index 30bacb2a83..9f6050fe50 100644 --- a/.env +++ b/.env @@ -1,5 +1,9 @@ _APP_ENV=production _APP_ENV=development +_APP_LOCALE=en +_APP_CONSOLE_WHITELIST_ROOT=disabled +_APP_CONSOLE_WHITELIST_EMAILS= +_APP_CONSOLE_WHITELIST_IPS= _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io @@ -24,7 +28,7 @@ _APP_INFLUXDB_PORT=8086 _APP_STATSD_HOST=telegraf _APP_STATSD_PORT=8125 _APP_SMTP_HOST=maildev -_APP_SMTP_PORT=25 +_APP_SMTP_PORT=1025 _APP_SMTP_SECURE= _APP_SMTP_USERNAME= _APP_SMTP_PASSWORD= diff --git a/.travis-ci/build.sh b/.travis-ci/build.sh index 27b598fd4b..050168289a 100644 --- a/.travis-ci/build.sh +++ b/.travis-ci/build.sh @@ -15,7 +15,7 @@ then exit 1 fi -if test $(find "./app/db/DBIP/dbip-country-lite-2021-02.mmdb" -mmin +259200) +if test $(find "./app/db/DBIP/dbip-country-lite-2021-06.mmdb" -mmin +259200) then printf "${RED}GEO country DB has not been updated for more than 6 months. Go to https://db-ip.com/db/download/ip-to-country-lite to download a newer version${NC}\n" fi diff --git a/.travis.yml b/.travis.yml index 92baeb0fb5..af63bd6030 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ dist: xenial arch: - amd64 + - arm64 os: linux @@ -10,9 +11,6 @@ language: shell notifications: email: - team@appwrite.io - -services: -- docker before_install: - curl -fsSL https://get.docker.com | sh @@ -27,6 +25,9 @@ before_install: - docker --version - docker buildx create --use - chmod -R u+x ./.travis-ci +- export COMPOSE_INTERACTIVE_NO_CLI=1 +# Only pass a single runtime for CI stability +- echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env install: - docker-compose up -d @@ -38,7 +39,7 @@ script: - docker-compose logs appwrite-worker-functions - docker-compose exec appwrite doctor - docker-compose exec appwrite vars -- docker-compose exec appwrite test +- docker-compose exec appwrite test --debug deploy: - provider: script diff --git a/CHANGES.md b/CHANGES.md index d0cd072bc4..0dd92eeff6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,97 @@ -# Version 0.8.0 (Not Released Yet) +# NOT PUBLISHED YET -- Anonymous login +## Features + +- Added file created date to file info on the console +- Added file size to file info on the console +- Refactored Devices page in Console: + - Renamed *Devices* to *Sessions* + - Add Provider Icon to each Session + - Add Anonymous Account Placeholder +- Upgraded telegraf docker image version to v1.1.0 + +## Bugs + +- Fixed bug when removing a project member on the Appwrite console (#1214) +- Fixed Swoole buffer output size to allow downloading files bigger than allowed size (#1189) +- Fixed ClamAV status when anti virus is not running (#1188) +- Fixed deleteSession which was removing cookieFallback from the localstorage on any logout instead of current session (#1206) +- Fixed Nepal flag (#1173) +- Fixed a bug in the Twitch OAuth adapter (#1209) +- Fixed missing session object when OAuth session creation event is triggered (#1208) + +# Version 0.8.0 + +## Features +- Refactoring SSL generation to work on every request so no domain environment variable is required for SSL generation (#1133) +- Added Anonymous Login ([RFC-010](https://github.com/appwrite/rfc/blob/main/010-anonymous-login.md), #914) +- Added events for functions and executions (#971) +- Added JWT support (#784) +- Added ARM support (#726) +- New awesome image preview features, supports borderRadius, borderColor, borderWidth +- Split token & session models to become 2 different internal entities (#922) +- Added Dart 2.12 as a new Cloud Functions runtime (#989) +- Added option to disable email/password (#947) +- Added option to disable anonymous login (need to merge and apply changed) (#947) +- Added option to disable JWT auth (#947) +- Added option to disable team invites (#947) +- Option to limit number of users (good for app launches + root account PR) (#947) +- Added 2 new endpoints to the projects API to allow new settings +- Enabled 501 errors (Not Implemented) from the error handler +- Added Python 3.9 as a new Cloud Functions runtime (#1044) +- Added Deno 1.8 as a new Cloud Functions runtime (#989) +- Upgraded to PHP 8.0 (#713) +- ClamAV is now disabled by default to allow lower min requirements for Appwrite (#1064) +- Added a new env var named `_APP_LOCALE` that allow to change the default `en` locale value (#1056) +- Updated all the console bottom control to be consistent. Dropped the `+` icon (#1062) +- Added Response Models for Documents and Preferences (#1075, #1102) +- Added new endpoint to update team membership roles (#1142) +- Removed DB connection from webhooks worker for improved performance (#1150) + +## Bugs + +- Fixed default value for HTTPS force option +- Fixed form array casting in dashboard (#1070) +- Fixed collection document rule form in dashboard (#1069) +- Bugs in the Teams API: + - Fixed incorrect audit worker event names (#1143) + - Increased limit of memberships fetched in `createTeamMembership` to 2000 (#1143) + - Fixed exception thrown when SSL certificate is already stored in the database (#1151) +- Fixed user delete button in the Appwrite console (#1216) +- Fixed missing placeholder for user name when empty (#1220) + +## Breaking Changes (Read before upgrading!) + +- Rename `deleteuser` to `delete` on Users Api (#1089) +- Environment variable `_APP_FUNCTIONS_ENVS` renamed to `_APP_FUNCTIONS_RUNTIMES` (#1101) +- Only logged in users can execute functions (for guests, use anonymous login) (#976) +- Only the user who has triggered the execution get access to the relevant execution logs (#1045) +- Function execution environment variable `APPWRITE_FUNCTION_EVENT_PAYLOAD` renamed to `APPWRITE_FUNCTION_EVENT_DATA` (#1045) +- Function execution environment variable `APPWRITE_FUNCTION_ENV_NAME` renamed to `APPWRITE_FUNCTION_RUNTIME_NAME` (#1101) +- Function execution environment variable `APPWRITE_FUNCTION_ENV_VERSION` renamed to `APPWRITE_FUNCTION_RUNTIME_VERSION` (#1101) +- Introduces rate limits for: + - Team invite (10 requests in every 60 minutes per IP address) (#1088) +- Rename param `inviteId` to the more accurate `membershipId` in the Teams API (#1129) + +# Version 0.7.2 + +## Features + +- When creating new resources from the client API, the current user gets both read & write permissions by default. (#1007) +- Added timestamp to errors logs on the HTTP API container (#1002) +- Added verbose tests output on the terminal and CI (#1006) + +## Upgrades + +- Upgraded utopia-php/abuse to version 0.4.0 +- Upgraded utopia-php/analytics to version 0.2.0 + +## Bugs + +- Fixed certificates worker error on successful operations (#1010) +- Fixed head requests not responding (#998) +- Fixed bug when using auth credential for the Redis container (#993) +- Fixed server warning logs on 3** redirect endpoints (#1013) # Version 0.7.1 @@ -11,6 +102,7 @@ - Force adding a security email on setup - SMTP is now disabled by default, no dummy SMTP is included in setup - Added a new endpoint that returns the server and SDKs latest versions numbers #941 +- Custom data strings, userId, and JWT available for cloud functions #967 ## Upgrades @@ -27,8 +119,11 @@ ## Bug Fixes - Updated missing storage env vars +- Fixed a bug, that added a wrong timzone offset to user log timestamps - Fixed a bug, that Response format header was not added in the access-control-allow-header list. - Fixed a bug where countryName is unknown on sessions (#933) +- Added missing event users.update.prefs (#952) +- Fixed bug not allowing to reset document permissions (#977) ## Security diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dd7217a9af..69d26d0aa4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,7 +92,7 @@ After finishing the installation process, you can start writing and editing code #### Advanced Topics -We love to create issues that are good for begginers and label them as `good for begginers` or `hacktoberfest`, but some more advanced topics might require extra knowledge. Below is a list of links you can use to learn more about some of the more advance topics that will help you master the Appwrite codebase. +We love to create issues that are good for beginners and label them as `good first issue` or `hacktoberfest`, but some more advanced topics might require extra knowledge. Below is a list of links you can use to learn more about some of the more advance topics that will help you master the Appwrite codebase. ##### Tools and Libs - [Docker](https://www.docker.com/get-started) @@ -278,13 +278,9 @@ Before running the command, make sure you have proper write permissions to the A ```bash docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x -t appwrite/appwrite:dev --push . ``` -**Build Functions Envs** +**Build Functions Runtimes** -Build envs for all supported cloud functions (multicore builds) - -```bash -bash ./docker/environments/build.sh -``` +The Runtimes for all supported cloud functions (multicore builds) can be found at the [appwrite/php-runtimes](https://github.com/appwrite/php-runtimes) repository. ## Tests @@ -365,7 +361,7 @@ From time to time, our team will add tutorials that will help contributors find * [Adding Support for a New OAuth2 Provider](./docs/tutorials/add-oauth2-provider.md) * [Appwrite Environment Variables](./docs/tutorials/environment-variables.md) * [Running in Production](./docs/tutorials/running-in-production.md) - +* [Adding Storage Adapter](./docs/tutorials/add-storage-adapter.md) ## Other Ways to Help diff --git a/Dockerfile b/Dockerfile index 7cd404b7ae..00958f3f14 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,12 +12,13 @@ RUN composer update --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM php:7.4-cli-alpine as step1 +FROM php:8.0-cli-alpine as step1 -ENV PHP_REDIS_VERSION=5.3.3 \ - PHP_SWOOLE_VERSION=v4.5.8 \ - PHP_MAXMINDDB_VERSION=v1.10.0 \ - PHP_XDEBUG_VERSION=sdebug_2_9-beta +ENV PHP_REDIS_VERSION=5.3.4 \ + PHP_SWOOLE_VERSION=v4.6.6 \ + PHP_IMAGICK_VERSION=master \ + PHP_YAML_VERSION=2.2.1 \ + PHP_MAXMINDDB_VERSION=v1.10.1 RUN \ apk add --no-cache --virtual .deps \ @@ -29,38 +30,54 @@ RUN \ git \ zlib-dev \ brotli-dev \ + yaml-dev \ + imagemagick \ + imagemagick-dev \ libmaxminddb-dev RUN docker-php-ext-install sockets RUN \ # Redis Extension - git clone https://github.com/phpredis/phpredis.git && \ + git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git && \ cd phpredis && \ - git checkout $PHP_REDIS_VERSION && \ phpize && \ ./configure && \ make && make install && \ cd .. && \ ## Swoole Extension - git clone https://github.com/swoole/swoole-src.git && \ + git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git && \ cd swoole-src && \ - git checkout $PHP_SWOOLE_VERSION && \ phpize && \ - ./configure --enable-sockets --enable-http2 && \ + ./configure --enable-http2 && \ + make && make install && \ + cd .. && \ + ## Imagick Extension + ## Last working commit https://github.com/Imagick/imagick/commit/35741750aa1cda2b7ac354bfa6128fa037e9cf32 + git clone --branch $PHP_IMAGICK_VERSION https://github.com/Imagick/imagick && \ + cd imagick && \ + git checkout 35741750aa1cda2b7ac354bfa6128fa037e9cf32 && \ + phpize && \ + ./configure && \ + make && make install && \ + cd .. && \ + ## YAML Extension + git clone --depth 1 --branch $PHP_YAML_VERSION https://github.com/php/pecl-file_formats-yaml && \ + cd pecl-file_formats-yaml && \ + phpize && \ + ./configure && \ make && make install && \ cd .. && \ ## Maxminddb extension - git clone https://github.com/maxmind/MaxMind-DB-Reader-php.git && \ + git clone --depth 1 --branch $PHP_MAXMINDDB_VERSION https://github.com/maxmind/MaxMind-DB-Reader-php.git && \ cd MaxMind-DB-Reader-php && \ - git checkout $PHP_MAXMINDDB_VERSION && \ cd ext && \ phpize && \ ./configure && \ make && make install && \ cd ../.. -FROM php:7.4-cli-alpine as final +FROM php:8.0-cli-alpine as final LABEL maintainer="team@appwrite.io" @@ -68,10 +85,18 @@ ARG VERSION=dev ENV _APP_SERVER=swoole \ _APP_ENV=production \ + _APP_LOCALE=en \ _APP_DOMAIN=localhost \ _APP_DOMAIN_TARGET=localhost \ _APP_HOME=https://appwrite.io \ _APP_EDITION=community \ + _APP_CONSOLE_WHITELIST_ROOT=enabled \ + _APP_CONSOLE_WHITELIST_EMAILS= \ + _APP_CONSOLE_WHITELIST_IPS= \ + _APP_SYSTEM_EMAIL_NAME= \ + _APP_SYSTEM_EMAIL_ADDRESS= \ + _APP_SYSTEM_RESPONSE_FORMAT= \ + _APP_SYSTEM_SECURITY_EMAIL_ADDRESS= \ _APP_OPTIONS_ABUSE=enabled \ _APP_OPTIONS_FORCE_HTTPS=disabled \ _APP_OPENSSL_KEY_V1=your-secret-key \ @@ -123,16 +148,14 @@ RUN \ curl-dev \ && apk add --no-cache \ libstdc++ \ + certbot \ + brotli-dev \ yaml-dev \ imagemagick \ - imagemagick-dev \ + libmaxminddb-dev \ certbot \ docker-cli \ docker-compose \ - libmaxminddb \ - libmaxminddb-dev \ - && pecl install imagick yaml \ - && docker-php-ext-enable imagick yaml \ && docker-php-ext-install sockets opcache pdo_mysql \ && apk del .deps \ && rm -rf /var/cache/apk/* @@ -140,9 +163,11 @@ RUN \ WORKDIR /usr/src/code COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor -COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ -COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ -COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20190902/maxminddb.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/yaml.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ +COPY --from=step1 /usr/local/lib/php/extensions/no-debug-non-zts-20200930/maxminddb.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/ # Add Source Code COPY ./app /usr/src/code/app @@ -190,11 +215,15 @@ RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ # Enable Extensions RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini +RUN echo extension=imagick.so >> /usr/local/etc/php/conf.d/imagick.ini +RUN echo extension=yaml.so >> /usr/local/etc/php/conf.d/yaml.ini RUN echo extension=maxminddb.so >> /usr/local/etc/php/conf.d/maxminddb.ini RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini RUN echo "opcache.preload=/usr/src/code/app/preload.php" >> /usr/local/etc/php/conf.d/appwrite.ini RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/appwrite.ini +RUN echo "opcache.jit_buffer_size=100M" >> /usr/local/etc/php/conf.d/appwrite.ini +RUN echo "opcache.jit=1235" >> /usr/local/etc/php/conf.d/appwrite.ini EXPOSE 80 diff --git a/README.md b/README.md index 3d4bd75733..0596bee316 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +

Appwrite Logo
@@ -9,14 +10,16 @@ [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) +[![Swag Store](https://img.shields.io/badge/swag%20store-f02e65?style=flat-square)](https://store.appwrite.io) [![Docker Pulls](https://img.shields.io/docker/pulls/appwrite/appwrite?color=f02e65&style=flat-square)](https://hub.docker.com/r/appwrite/appwrite) [![Build Status](https://img.shields.io/travis/com/appwrite/appwrite?style=flat-square)](https://travis-ci.com/appwrite/appwrite) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) -[![Follow Appwrite on StackShare](https://img.shields.io/badge/follow%20on-stackshare-blue?style=flat-square)](https://stackshare.io/appwrite) + +[**Appwrite 0.8 has been released! Learn what's new!**](https://dev.to/appwrite/announcing-appwrite-0-8-an-open-source-self-hosted-baas-kda) Appwrite is an end-to-end backend server for Web, Mobile, Native, or Backend apps packaged as a set of Docker microservices. Appwrite abstracts the complexity and repetitiveness required to build a modern backend API from scratch and allows you to build secure apps faster. -Using Appwrite, you can easily integrate your app with user authentication & multiple sign-in methods, a database for storing and querying users and team data, storage and file management, image manipulation, schedule CRON tasks, and [more services](https://appwrite.io/docs). +Using Appwrite, you can easily integrate your app with user authentication & multiple sign-in methods, a database for storing and querying users and team data, storage and file management, image manipulation, Cloud Functions, and [more services](https://appwrite.io/docs). ![Appwrite](public/images/github.png) @@ -53,7 +56,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.8.0 ``` ### Windows @@ -65,7 +68,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.8.0 ``` #### PowerShell @@ -75,13 +78,13 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.8.0 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. -For advanced production and custom installation, check out our Docker [environment variables](docs/tutorials/environment-variables.md) docs. You can also use our public [docker-compose.yml](https://appwrite.io/docker-compose.yml) file to manually set up an environment. +For advanced production and custom installation, check out our Docker [environment variables](https://appwrite.io/docs/environment-variables) docs. You can also use our public [docker-compose.yml](https://gist.github.com/eldadfux/977869ff6bdd7312adfd4e629ee15cc5#file-docker-compose-yml) file to manually set up an environment. ### Upgrade from an Older Version @@ -122,12 +125,11 @@ Below is a list of currently supported platforms and languages. If you wish to h #### Server * ✅   [NodeJS](https://github.com/appwrite/sdk-for-node) (Maintained by the Appwrite Team) * ✅   [PHP](https://github.com/appwrite/sdk-for-php) (Maintained by the Appwrite Team) +* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) **Beta** (Maintained by the Appwrite Team) * ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **Beta** (Maintained by the Appwrite Team) * ✅   [Ruby](https://github.com/appwrite/sdk-for-ruby) - **Beta** (Maintained by the Appwrite Team) * ✅   [Python](https://github.com/appwrite/sdk-for-python) - **Beta** (Maintained by the Appwrite Team) * ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **Experimental** (Maintained by the Appwrite Team) -* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) **Experimental** (Maintained by the Appwrite Team) -* ✅   [Go](https://github.com/appwrite/sdk-for-go) **Work in progress** (Maintained by the Appwrite Team) Looking for more SDKs? - Help us by contributing a pull request to our [SDK Generator](https://github.com/appwrite/sdk-generator)! diff --git a/app/config/auth.php b/app/config/auth.php new file mode 100644 index 0000000000..11b89dd9ec --- /dev/null +++ b/app/config/auth.php @@ -0,0 +1,42 @@ + [ + 'name' => 'Email/Password', + 'key' => 'usersAuthEmailPassword', + 'icon' => '/images/users/email.png', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateSession', + 'enabled' => true, + ], + 'anonymous' => [ + 'name' => 'Anonymous', + 'key' => 'usersAuthAnonymous', + 'icon' => '/images/users/anonymous.png', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateAnonymousSession', + 'enabled' => true, + ], + 'invites' => [ + 'name' => 'Invites', + 'key' => 'usersAuthInvites', + 'icon' => '/images/users/invites.png', + 'docs' => 'https://appwrite.io/docs/client/teams?sdk=web#teamsCreateMembership', + 'enabled' => true, + ], + 'jwt' => [ + 'name' => 'JWT', + 'key' => 'usersAuthJWT', + 'icon' => '/images/users/jwt.png', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateJWT', + 'enabled' => true, + ], + 'phone' => [ + 'name' => 'Phone', + 'key' => 'usersAuthPhone', + 'icon' => '/images/users/phone.png', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreatePhoneSession', + 'docs' => '', + 'enabled' => false, + ], +]; \ No newline at end of file diff --git a/app/config/avatars/flags/np.png b/app/config/avatars/flags/np.png index 09b2a4c228..4c0c2d7e5f 100644 Binary files a/app/config/avatars/flags/np.png and b/app/config/avatars/flags/np.png differ diff --git a/app/config/collections.php b/app/config/collections.php index 9170b07573..6789237c9c 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -5,6 +5,7 @@ use Utopia\Config\Config; use Appwrite\Database\Database; $providers = Config::getParam('providers', []); +$auth = Config::getParam('auth', []); $collections = [ 'console' => [ @@ -45,7 +46,7 @@ $collections = [ 'legalTaxId' => '', 'authWhitelistEmails' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], 'authWhitelistIPs' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], - 'authWhitelistDomains' => (!empty(App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null))) ? \explode(',', App::getEnv('_APP_CONSOLE_WHITELIST_DOMAINS', null)) : [], + 'usersAuthLimit' => (App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user ], Database::SYSTEM_COLLECTION_COLLECTIONS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, @@ -204,7 +205,7 @@ $collections = [ 'key' => 'email', 'type' => Database::SYSTEM_VAR_TYPE_EMAIL, 'default' => '', - 'required' => true, + 'required' => false, 'array' => false, ], [ @@ -222,7 +223,7 @@ $collections = [ 'key' => 'password', 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => '', - 'required' => true, + 'required' => false, 'array' => false, ], [ @@ -271,6 +272,16 @@ $collections = [ 'required' => true, 'array' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Sessions', + 'key' => 'sessions', + 'type' => Database::SYSTEM_VAR_TYPE_DOCUMENT, + 'default' => [], + 'required' => false, + 'array' => true, + 'list' => [Database::SYSTEM_COLLECTION_SESSIONS], + ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Tokens', @@ -293,11 +304,11 @@ $collections = [ ], ], ], - Database::SYSTEM_COLLECTION_TOKENS => [ + Database::SYSTEM_COLLECTION_SESSIONS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, - '$id' => Database::SYSTEM_COLLECTION_TOKENS, + '$id' => Database::SYSTEM_COLLECTION_SESSIONS, '$permissions' => ['read' => ['*']], - 'name' => 'Token', + 'name' => 'Session', 'structure' => true, 'rules' => [ [ @@ -306,16 +317,34 @@ $collections = [ 'key' => 'userId', 'type' => Database::SYSTEM_VAR_TYPE_TEXT, 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Provider', + 'key' => 'provider', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Provider User Identifier', + 'key' => 'providerUid', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', 'required' => false, 'array' => false, ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'Type', - 'key' => 'type', - 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, - 'default' => null, - 'required' => true, + 'label' => 'Provider Token', + 'key' => 'providerToken', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => false, 'array' => false, ], [ @@ -473,6 +502,69 @@ $collections = [ ], ], ], + Database::SYSTEM_COLLECTION_TOKENS => [ + '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, + '$id' => Database::SYSTEM_COLLECTION_TOKENS, + '$permissions' => ['read' => ['*']], + 'name' => 'Token', + 'structure' => true, + 'rules' => [ + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User ID', + 'key' => 'userId', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => null, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Type', + 'key' => 'type', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => null, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Secret', + 'key' => 'secret', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Expire', + 'key' => 'expire', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'User Agent', + 'key' => 'userAgent', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'IP', + 'key' => 'ip', + 'type' => Database::SYSTEM_VAR_TYPE_IP, + 'default' => '', + 'required' => true, + 'array' => false, + ], + ], + ], Database::SYSTEM_COLLECTION_MEMBERSHIPS => [ '$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS, '$id' => Database::SYSTEM_COLLECTION_MEMBERSHIPS, @@ -679,6 +771,14 @@ $collections = [ 'default' => '', 'required' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Max users allowed', + 'key' => 'usersAuthLimit', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Webhooks', @@ -1172,6 +1272,24 @@ $collections = [ 'required' => false, 'array' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Updated Date', + 'key' => 'updated', + 'type' => Database::SYSTEM_VAR_TYPE_NUMERIC, + 'default' => 0, + 'required' => false, + 'array' => false, + ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Certificate ID', + 'key' => 'certificateId', + 'type' => Database::SYSTEM_VAR_TYPE_KEY, + 'default' => '', + 'required' => false, + 'array' => false, + ], ], ], Database::SYSTEM_COLLECTION_FILES => [ @@ -1617,25 +1735,16 @@ foreach ($providers as $index => $provider) { 'array' => false, 'filter' => ['encrypt'], ]; +} - $collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [ +foreach ($auth as $index => $method) { + $collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [ '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth2 '.\ucfirst($index).' ID', - 'key' => 'oauth2'.\ucfirst($index), - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', + 'label' => $method['name'] || '', + 'key' => $method['key'] || '', + 'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN, + 'default' => true, 'required' => false, - 'array' => false, - ]; - - $collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [ - '$collection' => Database::SYSTEM_COLLECTION_RULES, - 'label' => 'OAuth2 '.\ucfirst($index).' Access Token', - 'key' => 'oauth2'.\ucfirst($index).'AccessToken', - 'type' => Database::SYSTEM_VAR_TYPE_TEXT, - 'default' => '', - 'required' => false, - 'array' => false, ]; } diff --git a/app/config/environments.php b/app/config/environments.php deleted file mode 100644 index 9f1c5638e1..0000000000 --- a/app/config/environments.php +++ /dev/null @@ -1,138 +0,0 @@ - [ - 'name' => 'Node.js', - 'version' => '14.5', - 'base' => 'node:14.5-alpine', - 'image' => 'appwrite/env-node-14.5:1.0.0', - 'build' => '/usr/src/code/docker/environments/node-14.5', - 'logo' => 'node.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'node-15.5' => [ - 'name' => 'Node.js', - 'version' => '15.5', - 'base' => 'node:15.5-alpine', - 'image' => 'appwrite/env-node-15.5:1.0.0', - 'build' => '/usr/src/code/docker/environments/node-15.5', - 'logo' => 'node.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'php-7.4' => [ - 'name' => 'PHP', - 'version' => '7.4', - 'base' => 'php:7.4-cli-alpine', - 'image' => 'appwrite/env-php-7.4:1.0.0', - 'build' => '/usr/src/code/docker/environments/php-7.4', - 'logo' => 'php.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'php-8.0' => [ - 'name' => 'PHP', - 'version' => '8.0', - 'base' => 'php:8.0-cli-alpine', - 'image' => 'appwrite/env-php-8.0:1.0.0', - 'build' => '/usr/src/code/docker/environments/php-8.0', - 'logo' => 'php.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'ruby-2.7' => [ - 'name' => 'Ruby', - 'version' => '2.7', - 'base' => 'ruby:2.7-alpine', - 'image' => 'appwrite/env-ruby-2.7:1.0.2', - 'build' => '/usr/src/code/docker/environments/ruby-2.7', - 'logo' => 'ruby.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'ruby-3.0' => [ - 'name' => 'Ruby', - 'version' => '3.0', - 'base' => 'ruby:3.0-alpine', - 'image' => 'appwrite/env-ruby-3.0:1.0.0', - 'build' => '/usr/src/code/docker/environments/ruby-3.0', - 'logo' => 'ruby.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'python-3.8' => [ - 'name' => 'Python', - 'version' => '3.8', - 'base' => 'python:3.8-alpine', - 'image' => 'appwrite/env-python-3.8:1.0.0', - 'build' => '/usr/src/code/docker/environments/python-3.8', - 'logo' => 'python.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'deno-1.2' => [ - 'name' => 'Deno', - 'version' => '1.2', - 'base' => 'hayd/deno:alpine-1.2.0', - 'image' => 'appwrite/env-deno-1.2:1.0.0', - 'build' => '/usr/src/code/docker/environments/deno-1.2', - 'logo' => 'deno.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'deno-1.5' => [ - 'name' => 'Deno', - 'version' => '1.5', - 'base' => 'hayd/deno:alpine-1.5.0', - 'image' => 'appwrite/env-deno-1.5:1.0.0', - 'build' => '/usr/src/code/docker/environments/deno-1.5', - 'logo' => 'deno.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'deno-1.6' => [ - 'name' => 'Deno', - 'version' => '1.6', - 'base' => 'hayd/deno:alpine-1.6.0', - 'image' => 'appwrite/env-deno-1.6:1.0.0', - 'build' => '/usr/src/code/docker/environments/deno-1.6', - 'logo' => 'deno.png', - 'supports' => [System::X86, System::PPC, System::ARM], - ], - 'dart-2.10' => [ - 'name' => 'Dart', - 'version' => '2.10', - 'base' => 'google/dart:2.10', - 'image' => 'appwrite/env-dart-2.10:1.0.0', - 'build' => '/usr/src/code/docker/environments/dart-2.10', - 'logo' => 'dart.png', - 'supports' => [System::X86], - ], - 'dotnet-3.1' => [ - 'name' => '.NET', - 'version' => '3.1', - 'base' => 'mcr.microsoft.com/dotnet/runtime:3.1-alpine', - 'image' => 'appwrite/env-dotnet-3.1:1.0.0', - 'build' => '/usr/src/code/docker/environments/dotnet-3.1', - 'logo' => 'dotnet.png', - 'supports' => [System::X86, System::ARM], - ], - 'dotnet-5.0' => [ - 'name' => '.NET', - 'version' => '5.0', - 'base' => 'mcr.microsoft.com/dotnet/runtime:5.0-alpine', - 'image' => 'appwrite/env-dotnet-5.0:1.0.0', - 'build' => '/usr/src/code/docker/environments/dotnet-5.0', - 'logo' => 'dotnet.png', - 'supports' => [System::X86, System::ARM], - ], -]; - -$allowList = empty(App::getEnv('_APP_FUNCTIONS_ENVS', null)) ? false : \explode(',', App::getEnv('_APP_FUNCTIONS_ENVS', null)); - -$environments = array_filter($environments, function ($environment, $key) use ($allowList) { - $isAllowed = $allowList && in_array($key, $allowList); - $isSupported = in_array(System::getArchEnum(), $environment["supports"]); - - return $allowList ? ($isAllowed && $isSupported) : $isSupported; -}, ARRAY_FILTER_USE_BOTH); - -return $environments; \ No newline at end of file diff --git a/app/config/events.php b/app/config/events.php index 2bb3862fdf..b27a5eafb9 100644 --- a/app/config/events.php +++ b/app/config/events.php @@ -84,19 +84,59 @@ return [ ], 'database.documents.create' => [ 'description' => 'This event triggers when a database document is created.', - 'model' => Response::MODEL_ANY, + 'model' => Response::MODEL_DOCUMENT, 'note' => '', ], 'database.documents.update' => [ 'description' => 'This event triggers when a database document is updated.', - 'model' => Response::MODEL_ANY, + 'model' => Response::MODEL_DOCUMENT, 'note' => '', ], 'database.documents.delete' => [ 'description' => 'This event triggers when a database document is deleted.', - 'model' => Response::MODEL_ANY, + 'model' => Response::MODEL_DOCUMENT, 'note' => '', ], + 'functions.create' => [ + 'description' => 'This event triggers when a function is created.', + 'model' => Response::MODEL_FUNCTION, + 'note' => 'version >= 0.7', + ], + 'functions.update' => [ + 'description' => 'This event triggers when a function is updated.', + 'model' => Response::MODEL_FUNCTION, + 'note' => 'version >= 0.7', + ], + 'functions.delete' => [ + 'description' => 'This event triggers when a function is deleted.', + 'model' => Response::MODEL_ANY, + 'note' => 'version >= 0.7', + ], + 'functions.tags.create' => [ + 'description' => 'This event triggers when a function tag is created.', + 'model' => Response::MODEL_TAG, + 'note' => 'version >= 0.7', + ], + 'functions.tags.update' => [ + 'description' => 'This event triggers when a function tag is updated.', + 'model' => Response::MODEL_FUNCTION, + 'note' => 'version >= 0.7', + ], + 'functions.tags.delete' => [ + 'description' => 'This event triggers when a function tag is deleted.', + 'model' => Response::MODEL_ANY, + 'note' => 'version >= 0.7', + ], + 'functions.executions.create' => [ + 'description' => 'This event triggers when a function execution is created.', + 'model' => Response::MODEL_EXECUTION, + 'note' => 'version >= 0.7', + ], + 'functions.executions.update' => [ + 'description' => 'This event triggers when a function execution is updated.', + 'model' => Response::MODEL_EXECUTION, + 'note' => 'version >= 0.7', + ], 'storage.files.create' => [ 'description' => 'This event triggers when a storage file is created.', 'model' => Response::MODEL_FILE, @@ -117,6 +157,11 @@ return [ 'model' => Response::MODEL_USER, 'note' => 'version >= 0.7', ], + 'users.update.prefs' => [ + 'description' => 'This event triggers when a user preference is updated from the users API.', + 'model' => Response::MODEL_ANY, + 'note' => 'version >= 0.7', + ], 'users.update.status' => [ 'description' => 'This event triggers when a user status is updated from the users API.', 'model' => Response::MODEL_USER, @@ -152,6 +197,11 @@ return [ 'model' => Response::MODEL_MEMBERSHIP, 'note' => 'version >= 0.7', ], + 'teams.memberships.update' => [ + 'description' => 'This event triggers when a team membership is updated.', + 'model' => Response::MODEL_MEMBERSHIP, + 'note' => 'version >= 0.8', + ], 'teams.memberships.update.status' => [ 'description' => 'This event triggers when a team memberships status is updated.', 'model' => Response::MODEL_MEMBERSHIP, @@ -162,4 +212,4 @@ return [ 'model' => Response::MODEL_MEMBERSHIP, 'note' => 'version >= 0.7', ], -]; \ No newline at end of file +]; diff --git a/app/config/locale/templates/email-cta.tpl b/app/config/locale/templates/email-cta.tpl index 634609a09e..97103f610e 100644 --- a/app/config/locale/templates/email-cta.tpl +++ b/app/config/locale/templates/email-cta.tpl @@ -1,7 +1,7 @@ -