From a29cef233498486216edc923859c45b2e4cf767a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 29 Dec 2023 21:52:50 +0100 Subject: [PATCH 1/2] feat: console hostname env variable --- .env | 3 ++- app/config/variables.php | 17 +++++++++-------- app/init.php | 12 ++++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.env b/.env index fc643e7d9b..f34ce80ce8 100644 --- a/.env +++ b/.env @@ -4,12 +4,13 @@ _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= _APP_CONSOLE_WHITELIST_IPS= +_APP_CONSOLE_HOSTNAMES= _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io _APP_SYSTEM_RESPONSE_FORMAT= _APP_OPTIONS_ABUSE=disabled -_APP_OPTIONS_ROUTER_PROTECTION=disbled +_APP_OPTIONS_ROUTER_PROTECTION=disabled _APP_OPTIONS_FORCE_HTTPS=disabled _APP_OPTIONS_FUNCTIONS_FORCE_HTTPS=disabled _APP_OPENSSL_KEY_V1=your-secret-key diff --git a/app/config/variables.php b/app/config/variables.php index 1c016b84de..7bf41f7967 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -115,14 +115,6 @@ return [ 'question' => '', 'filter' => '' ], - // [ - // 'name' => '_APP_CONSOLE_WHITELIST_DOMAINS', - // 'description' => 'This option allows you to limit creation of users to Appwrite console for users sharing the same email domains. This option is very useful for team working with company emails domain.\n\nTo enable this option, pass a list of allowed email domains separated by a comma.', - // 'introduction' => '', - // 'default' => '', - // 'required' => false, - // 'question' => '', - // ], [ 'name' => '_APP_CONSOLE_WHITELIST_IPS', 'description' => "This last option allows you to limit creation of users in Appwrite console for users sharing the same set of IP addresses. This option is very useful for team working with a VPN service or a company IP.\n\nTo enable/activate this option, pass a list of allowed IP addresses separated by a comma.", @@ -132,6 +124,15 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_CONSOLE_HOSTNAMES', + 'description' => 'This option allows you to add additional hostnames to your Appwrite console. This option is very useful for allowing access to the console project from additional domains. To enable it, pass a list of allowed hostnames separated by a comma.', + 'introduction' => '', + 'default' => '', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_SYSTEM_EMAIL_NAME', 'description' => 'This is the sender name value that will appear on email messages sent to developers from the Appwrite console. The default value is: \'Appwrite\'. You can use url encoded strings for spaces and special chars.', diff --git a/app/init.php b/app/init.php index 869ce9924d..d8accbc55d 100644 --- a/app/init.php +++ b/app/init.php @@ -927,6 +927,18 @@ App::setResource('clients', function ($request, $console, $project) { 'hostname' => $request->getHostname(), ], Document::SET_TYPE_APPEND); + $hostnames = explode(',', App::getEnv('_APP_CONSOLE_HOSTNAMES', '')); + if (is_array($hostnames)) { + foreach ($hostnames as $hostname) { + $console->setAttribute('platforms', [ + '$collection' => ID::custom('platforms'), + 'type' => Origin::CLIENT_TYPE_WEB, + 'name' => $hostname, + 'hostname' => $hostname, + ], Document::SET_TYPE_APPEND); + } + } + /** * Get All verified client URLs for both console and current projects * + Filter for duplicated entries From 0a17e2bce9813ad9c832e830232c4c51edeeadc1 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 29 Dec 2023 22:09:59 +0100 Subject: [PATCH 2/2] feat: add new env variable to compsoe files --- app/views/install/compose.phtml | 5 +++-- docker-compose.yml | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 1544b38e6f..3ae3ca6d6d 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -78,6 +78,7 @@ services: - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS + - _APP_CONSOLE_HOSTNAMES - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS @@ -268,7 +269,7 @@ services: depends_on: - redis - mariadb - volumes: + volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw - appwrite-functions:/storage/functions:rw @@ -415,7 +416,7 @@ services: depends_on: - redis - mariadb - volumes: + volumes: - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw environment: diff --git a/docker-compose.yml b/docker-compose.yml index 7dfc92c2c1..ea9b6897a5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,7 @@ services: DEBUG: false TESTING: true VERSION: dev - ports: + ports: - 9501:80 networks: - appwrite @@ -88,7 +88,7 @@ services: - mariadb - redis # - clamav - entrypoint: + entrypoint: - php - -e - app/http.php @@ -100,6 +100,7 @@ services: - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS - _APP_CONSOLE_WHITELIST_IPS + - _APP_CONSOLE_HOSTNAMES - _APP_SYSTEM_EMAIL_NAME - _APP_SYSTEM_EMAIL_ADDRESS - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS @@ -191,7 +192,7 @@ services: container_name: appwrite-realtime image: appwrite-dev restart: unless-stopped - ports: + ports: - 9505:80 labels: - "traefik.enable=true" @@ -299,7 +300,7 @@ services: depends_on: - redis - mariadb - volumes: + volumes: - appwrite-uploads:/storage/uploads:rw - appwrite-cache:/storage/cache:rw - appwrite-functions:/storage/functions:rw @@ -353,7 +354,7 @@ services: image: appwrite-dev networks: - appwrite - volumes: + volumes: - ./app:/usr/src/code/app - ./src:/usr/src/code/src depends_on: @@ -452,7 +453,7 @@ services: depends_on: - redis - mariadb - volumes: + volumes: - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw - ./app:/usr/src/code/app @@ -737,7 +738,7 @@ services: - _APP_REDIS_USER - _APP_REDIS_PASS - _APP_MIXPANEL_TOKEN - + appwrite-hamster-scheduler: entrypoint: hamster <<: *x-logging @@ -947,7 +948,7 @@ services: # - './debug:/tmp' # ports: # - '3001:80' - + graphql-explorer: container_name: appwrite-graphql-explorer image: appwrite/altair:0.3.0