diff --git a/configs/boop/keys/cookies.json b/configs/boop/keys/cookies.json new file mode 100644 index 0000000..5b4a9a0 --- /dev/null +++ b/configs/boop/keys/cookies.json @@ -0,0 +1 @@ +["Key1", "Key2", "Key3"] \ No newline at end of file diff --git a/configs/boop/keys/jwks.json b/configs/boop/keys/jwks.json new file mode 100644 index 0000000..bc225ca --- /dev/null +++ b/configs/boop/keys/jwks.json @@ -0,0 +1,18 @@ +{ + "keys": [ + { + "p": "1tjiJq3IAck-vXEEJi4TIJenO3VfpgspfFqpyaj_MRlX4hf94jCTgFutjhiIsIAYUKNN-Ducwsmv1pWgFF9-b0bX8yyhW-C0R1_cIIINwGdctgDlNLzzdCbGi_rA_9e2m1GfuvCQ_ws70p7vbjgl9UcE3FPqZa8nG3hVr2nosE0", + "kty": "RSA", + "q": "uvKDdy8vWLXRsrkVeVm4tKUZGPm7D_IYGkfYuryN_r7xtb7KhJtbD_R0al6TwqQDUQgrn05qmFRo-kRqW9TtpJ-OiwSdmrj-tQTujOubNCHr5tsaSeupbxljXopYkcss5_MOBo9lNlZSxTG28RFNISsojncsFFyzeoobfPFLSMc", + "d": "gjTtaj1N1jMLnIdQjLZTrePb3TNUzoIXCAtM6bldoGuk-euEbI8CaDtcX5OiaJmHCSlyAi6i15tejCiA30mBGj0nBHnOnmG6aMmhSVBF3DSPWkzSMbrS8hw_jgvH_smseVxQdiRz7KyHA5YR65aMDfyb-CWTCvekp-HJjH2A2STyl_jBcn_iO1vbaXUpcl2Bde9mWY6YOzjB2zIFZOUdzmApOzuwf9bhBWt9nfq_vge3IDaA_NJHOVoucDJ4T39VO-R6yljpM18XhGC_OEXkscVojmW-bRiLgRC-kM55bfm0fsZajZ3A-EqzoBBD-9Xb0uIulOED_LFzl7Abgh79aQ", + "e": "AQAB", + "use": "sig", + "kid": "sig-2022-08-02T19:52:54Z", + "qi": "FjI55Lr7tQlk4kc14i13VkmAQO7UBxVKA8Vdtu9ReOhcqAk27nGR5r-6GEgAenvdGalo3IM9elEX7bnHfIN53Hb6dVMfKejb7Q7hEZiZfkKHk2-rpm1VvI9fXT_gXI-Q-6ciaO2qTL3mXGC2jLF1gPNenDFhtWHJf7OAkYa1-nw", + "dp": "iifXbWXsqnFdvfZR47dXJ2s957c3dY_R8pxeeEYLK-iPId2prezsvOq3NRvDsjP87sXEmq7CxGNrhkKbON6bcDUPItl9PZbGdutGo0TeUO5mqMb0nTAwIW3Z2SO7PgnZ7BDV9SFDLC5uHqeDcc37Yrlzf7cakJ7MOBbuiqlBLzU", + "alg": "RS256", + "dq": "cCXZrd71hT8VfCTB-BlVz7CXHL97c3Zk9ScSoftJJ4A-mivJa8GS4EBisgjolUQ05SCEor20_orsqu3t7AcRRMefCFCNh2rhCZDa1ljks2KCFOxtmdiwvQA691UBCv0ahE7vpAnTysQARWGsgHNDlNlCLCzbmZ9-380H7m0GH7M", + "n": "nOUbquT4EQ_MyaK-beFl483LtkmFUgCBlGwSy2SdbHwA35iEZOlvbkQStZlfQ0FyYk8n13LufKz1QvDaglMYpgLgiHbj7x0PG031qxFcEC8fbBMOOznm5ezQOOlzIvTC5WL12XlihigEGtpWmqjLeDOYmpRnFQwn7jg8DRSeFjivcBJm3DvHup7Fj-DwNUQwysF9MepM1A1yTD4N6UF-sP1uE72bhmnqQd-XG0vwvx_9pBox3RnUmWYpiPN1DEaiM-lBt9iLjxPEboIC7swWPYXed447vttxwL8G4GE0DDbUpaEfz3_QyW46e2w4MUKpg7hFXWcNankCi4qU6QWz2w" + } + ] +} \ No newline at end of file diff --git a/docker-images/backend-php.Dockerfile b/docker-images/backend-php.Dockerfile index b7cf3cc..e938c3e 100644 --- a/docker-images/backend-php.Dockerfile +++ b/docker-images/backend-php.Dockerfile @@ -58,8 +58,13 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y nginx # Setup Nginx config RUN rm /etc/nginx/sites-enabled/default -#Download nginx config from git -RUN wget https://raw.githubusercontent.com/kakious/coder/main/nginx.conf -O /etc/nginx/sites-enabled/default +#Download the nginx script and run it (Bootstraps the NGINX config) +RUN wget https://git.kakio.us/kakious/coder/raw/branch/main/docker-images/nginx.conf -O /home/coder/nginx.sh +RUN chmod +x /home/coder/nginx.sh +RUN /home/coder/nginx.sh +RUN rm /home/coder/nginx.sh + + # Make sure the services are started on the start of the container diff --git a/scripts/boop/bootstrap.sh b/scripts/boop/bootstrap.sh new file mode 100644 index 0000000..fe4917e --- /dev/null +++ b/scripts/boop/bootstrap.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +echo "[BOOTSTRAP] Running initial setup for BOOP..." + +mysql -u root -e "CREATE DATABASE IF NOT EXISTS oauth_provider;" +password=$(openssl rand -base64 32) +password=$(echo $password | sed 's/[^a-zA-Z0-9]//g') +echo $password > /home/coder/oauth-provider/.dbpass +mysqladmin -u root password $password 2>&1 | grep -v "Warning" +mysql -u root -p$password -e "CREATE USER 'oauth_provider'@'%' IDENTIFIED BY '$password';" 2>&1 | grep -v "Warning" +mysql -u root -p$password -e "GRANT ALL PRIVILEGES ON oauth_provider.* TO 'oauth_provider'@'%';" 2>&1 | grep -v "Warning" +mysql -u root -p$password -e "FLUSH PRIVILEGES;" 2>&1 | grep -v "Warning" +chown coder:coder /home/coder/oauth-provider/.dbpass + +echo "[BOOTSTRAP] DB Configured, setting up .env file..." + +# read /home/coder/.coder-env as they contain the workspace name and username + +echo "[BOOTSTRAP] Generating Encryption Secret" + +encryption_secret=$(openssl rand -base64 64) +encryption_secret=$(echo $encryption_secret | sed 's/[^a-zA-Z0-9]//g') + +while [ ${#encryption_secret} -lt 64 ] +do + encryption_secret_2=$(openssl rand -base64 64) + encryption_secret_2=$(echo $encryption_secret_2 | sed 's/[^a-zA-Z0-9]//g') + encryption_secret=$encryption_secret$encryption_secret_2 +done +encryption_secret=${encryption_secret:0:64} + + +WORKSPACE_ENV=$(cat /home/coder/.coder-env | grep WORKSPACE_ENV | cut -d '=' -f2) +USERNAME_ENV=$(cat /home/coder/.coder-env | grep USERNAME_ENV | cut -d '=' -f2) + +sed -i "s/DATABASE_HOST=/DATABASE_HOST=localhost/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_PORT=/DATABASE_PORT=3306/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_USER=/DATABASE_USER=oauth_provider/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_PASSWORD=/DATABASE_PASSWORD=$password/g" /home/coder/oauth-provider/.env +sed -i "s/DATABASE_NAME=/DATABASE_NAME=oauth_provider/g" /home/coder/oauth-provider/.env +sed -i "s/REDIS_HOST=/REDIS_HOST=localhost/g" /home/coder/oauth-provider/.env +sed -i "s/REDIS_PORT=/REDIS_PORT=6379/g" /home/coder/oauth-provider/.env +sed -i "s/BASE_LOCAL_URL=/BASE_LOCAL_URL=https:\/\/boop--main--$WORKSPACE_ENV--$USERNAME_ENV.coder.kakio.us/g" /home/coder/oauth-provider/.env +echo "" >> /home/coder/oauth-provider/.env +echo "ENCRYPTION_SECRET=$encryption_secret" >> /home/coder/oauth-provider/.env + +echo "[BOOTSTRAP] Done!" \ No newline at end of file diff --git a/scripts/fox-api/bootstrap-node.sh b/scripts/fox-api/bootstrap-node.sh new file mode 100644 index 0000000..e69de29 diff --git a/scripts/fox-api/bootstrap-php.sh b/scripts/fox-api/bootstrap-php.sh new file mode 100644 index 0000000..e69de29 diff --git a/scripts/fox-api/nginx-php.sh b/scripts/fox-api/nginx-php.sh new file mode 100644 index 0000000..5fc0a66 --- /dev/null +++ b/scripts/fox-api/nginx-php.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "[BOOTSTRAP] Running initial nginx setup for FOX-API..." + +# Download the nginx config files +curl -s https://raw.githubusercontent.com/fox-api/fox-api/master/scripts/fox-api/nginx.conf > /etc/nginx/nginx.conf +curl -s https://raw.githubusercontent.com/fox-api/fox-api/master/scripts/fox-api/default.conf > /etc/nginx/conf.d/default.conf \ No newline at end of file