diff --git a/api.sh b/api.sh deleted file mode 100644 index 2229271..0000000 --- a/api.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -gradle clean bootRun -p api diff --git a/api/Dockerfile b/api/Dockerfile index 31ef002..bf96a73 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,14 +1,15 @@ # Stage 1 - Create a builder container -FROM gradle:jdk11 as builder +FROM gradle:jdk11 as dev ENV APP_HOME=/home/app/ WORKDIR $APP_HOME COPY build.gradle settings.gradle gradlew $APP_HOME COPY gradle $APP_HOME/gradle COPY . . -RUN gradle build -x test - +CMD ["gradle", "clean", "bootRun"] +FROM dev as builder +RUN gradle build -x test # Stage 2 - Create a downsized production container FROM openjdk:11 as deploy @@ -20,3 +21,30 @@ WORKDIR /home/app/ COPY --from=builder /home/app/build/libs/api-*.jar /home/app/api.jar CMD ["java", "-Djava.security.egd=file:/dev/./urandom","-jar", "/home/app/api.jar"] + + +# +# +# +# +## Stage 1 - Create a builder container +#FROM gradle:jdk11 as builder +# +#ENV APP_HOME=/home/app/ +#WORKDIR $APP_HOME +#COPY build.gradle settings.gradle gradlew $APP_HOME +#COPY gradle $APP_HOME/gradle +#COPY . . +#RUN gradle build -x test +# +## Stage 2 - Create a downsized production container +#FROM openjdk:11 as deploy +# +#RUN groupadd --system --gid 1000 deploy +#RUN useradd --system --gid deploy --uid 1000 --shell /bin/bash --create-home deploy +#USER deploy +#WORKDIR /home/app/ +#COPY --from=builder /home/app/build/libs/api-*.jar /home/app/api.jar +# +#CMD ["java", "-Djava.security.egd=file:/dev/./urandom","-jar", "/home/app/api.jar"] + diff --git a/api/src/main/resources/config/application-dev.yml b/api/src/main/resources/config/application-dev.yml index 027a816..12bce22 100644 --- a/api/src/main/resources/config/application-dev.yml +++ b/api/src/main/resources/config/application-dev.yml @@ -14,9 +14,9 @@ datasources: database: username: admin password: zaqwsx - port: 5444 + port: 5432 schema: app - host: localhost + host: database migration: locations: ["classpath:/db/migration", "classpath:/db/mock"] cleanOnValidationError: true diff --git a/api/src/main/resources/config/application-prod.yml b/api/src/main/resources/config/application-prod.yml index 4608e8f..4fce2d6 100644 --- a/api/src/main/resources/config/application-prod.yml +++ b/api/src/main/resources/config/application-prod.yml @@ -1,13 +1,15 @@ # =================================================================== # Spring Boot configuration for the "prod" profile. # =================================================================== +#TODO - set prod logging logging: level: - ROOT: WARN - pbs.api: DEBUG - pbs.api.mappers: + ROOT: INFO + web: DEBUG + base.api: DEBUG + base.api.mappers: AuthMapper: INFO - pbs.api.domain.diaries.DiaryDao.selectUser: INFO + base.api.domain.diaries.DiaryDao.selectUser: INFO datasources: database: @@ -15,9 +17,8 @@ datasources: password: cderfv port: 5432 schema: app - - -spring: - flyway: - locations: "classpath:/db/migration, classpath:/db/prod" - clean-disabled: true + host: database + migration: + locations: ["classpath:/db/migration"] + cleanOnValidationError: false + cleanOnStart: false diff --git a/api/src/main/resources/config/application-test.yml b/api/src/main/resources/config/application-test.yml index c78219b..5e02299 100644 --- a/api/src/main/resources/config/application-test.yml +++ b/api/src/main/resources/config/application-test.yml @@ -3,19 +3,20 @@ # =================================================================== logging: level: - ROOT: WARN + ROOT: INFO + web: DEBUG base.api: DEBUG base.api.mappers: AuthMapper: INFO + base.api.domain.diaries.DiaryDao.selectUser: INFO datasources: database: username: admin - password: xswedc + password: cderfv port: 5432 schema: app - host: database - -spring: - flyway: - locations: "classpath:/db/migration, classpath:/db/test" + migration: + locations: ["classpath:/db/migration", "classpath:/db/mock"] + cleanOnValidationError: false + cleanOnStart: false diff --git a/api/src/main/resources/config/application.yml b/api/src/main/resources/config/application.yml index 4b97d3d..4e5af48 100644 --- a/api/src/main/resources/config/application.yml +++ b/api/src/main/resources/config/application.yml @@ -1,3 +1,6 @@ +# =================================================================== +# Main Spring Boot configuration +# =================================================================== server: port: 9000 @@ -22,6 +25,8 @@ spring: mail: host: smtp.gmail.com port: 587 + username: "piorowskiapp@gmail.com" + password: "matpioapp" from: "Aplikacja Codeito" debug: false diff --git a/db.sh b/db.sh deleted file mode 100644 index fdc7864..0000000 --- a/db.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -docker-compose -f ./docker/docker-compose.dev.yml up diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index d64bf12..0000000 --- a/deploy.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -mkdir -p ./files ./logs -sudo chmod -R 777 ./files ./logs -docker-compose -f ./docker/docker-compose.$1.yml up -d --build diff --git a/dev.sh b/dev.sh new file mode 100644 index 0000000..c63096a --- /dev/null +++ b/dev.sh @@ -0,0 +1,2 @@ +docker-compose -f ./docker/docker-compose.dev.yml up -d --build +docker-compose -f ./docker/docker-compose.dev.yml logs -f --tail 100 diff --git a/docker/docker-compose.db.yml b/docker/docker-compose.db.yml new file mode 100644 index 0000000..b6a22f6 --- /dev/null +++ b/docker/docker-compose.db.yml @@ -0,0 +1,16 @@ +version: '3' +services: + database: + build: ../database + command: postgres -c shared_preload_libraries=pgaudit -c config_file=/etc/postgresql.conf + container_name: dev-database-app + environment: + POSTGRES_USER: admin + POSTGRES_PASSWORD: zaqwsx + POSTGRES_DB: app + PGDATA: /var/lib/postgresql/data/pgdata + volumes: + - ../database/pgdata:/var/lib/postgresql/data/pgdata + - ../database/postgresql.conf:/etc/postgresql.conf + ports: + - "5444:5432" diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index b6a22f6..0f1032f 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -1,16 +1,41 @@ -version: '3' +version: '3.4' services: + database: + container_name: dev-database-app build: ../database command: postgres -c shared_preload_libraries=pgaudit -c config_file=/etc/postgresql.conf - container_name: dev-database-app environment: POSTGRES_USER: admin POSTGRES_PASSWORD: zaqwsx POSTGRES_DB: app - PGDATA: /var/lib/postgresql/data/pgdata + PGDATA: /var/lib/postgresql/pgdata volumes: - - ../database/pgdata:/var/lib/postgresql/data/pgdata + - ../database/pgdata:/var/lib/postgresql/pgdata - ../database/postgresql.conf:/etc/postgresql.conf ports: - "5444:5432" + + api: + container_name: dev-api-app + build: + context: ../api + dockerfile: ./Dockerfile + target: dev + volumes: + - ../files:/home/app/files + environment: + - "SPRING_PROFILES_ACTIVE=dev, swagger" + depends_on: + - database + + ui: + container_name: dev-ui-app + build: + context: ../ui + dockerfile: ./Dockerfile + target: dev + environment: + - "APIPROXY=api" + ports: + - "3000:3000" diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 7248752..056956d 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -25,8 +25,9 @@ services: - ../files:/home/app/files environment: - "SPRING_PROFILES_ACTIVE=prod" - - "DATASOURCES_DATABASE_HOST=database" restart: on-failure + depends_on: + - database ui: container_name: prod-ui-app @@ -36,18 +37,8 @@ services: target: deploy volumes: - ./nginx-prod.conf:/etc/nginx/conf.d/default.conf -# - /etc/letsencrypt:/etc/letsencrypt - - ./certbot/conf:/etc/letsencrypt - - ./certbot/www:/var/www/certbot + - /etc/letsencrypt:/etc/letsencrypt ports: - "80:80" - "443:443" restart: on-failure - command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" - - certbot: - image: certbot/certbot - volumes: - - ./certbot/conf:/etc/letsencrypt - - ./certbot/www:/var/www/certbot - entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" diff --git a/docker/docker-compose.test.yml b/docker/docker-compose.test.yml deleted file mode 100644 index 9e87ace..0000000 --- a/docker/docker-compose.test.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '3.4' -services: - - database: - container_name: test-database-app - build: ../database - command: postgres -c shared_preload_libraries=pgaudit -c config_file=/etc/postgresql.conf - environment: - POSTGRES_USER: admin - POSTGRES_PASSWORD: xswedc - POSTGRES_DB: app - PGDATA: /var/lib/postgresql/pgdata - volumes: - - ../database/pgdata:/var/lib/postgresql/pgdata - - ../database/postgresql.conf:/etc/postgresql.conf - restart: on-failure - - api: - container_name: test-api-app - build: - context: ../api - dockerfile: ./Dockerfile - target: deploy - volumes: - - ../files:/home/app/files - environment: - - "SPRING_PROFILES_ACTIVE=test" - - "DATASOURCES_DATABASE_HOST=database" - restart: on-failure - - ui: - container_name: test-ui-app - build: - context: ../ui - dockerfile: ./Dockerfile - target: deploy - volumes: - - ./nginx-test.conf:/etc/nginx/conf.d/default.conf - ports: - - "80:80" - restart: on-failure diff --git a/docker/nginx-prod.conf b/docker/nginx-prod.conf index 5130920..711184a 100644 --- a/docker/nginx-prod.conf +++ b/docker/nginx-prod.conf @@ -1,6 +1,6 @@ server { - server_name pbs.codeito.pl www.pbs.codeito.pl; + server_name test.codeito.pl www.test.codeito.pl; location / { root /usr/share/nginx/html; @@ -12,23 +12,42 @@ server { proxy_pass http://api:9000/api/; } -; test location /.well-known/acme-challenge/ { root /var/www/certbot; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot - ssl_certificate /etc/letsencrypt/live/pbs.codeito.pl/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/pbs.codeito.pl/privkey.pem; # managed by Certbot - include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot - ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + + ssl_certificate /etc/letsencrypt/live/test.codeito.pl/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/test.codeito.pl/privkey.pem; # managed by Certbot + + ssl_trusted_certificate /etc/letsencrypt/live/test.codeito.pl/chain.pem; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + + ssl_session_cache shared:le_nginx_SSL:1m; + ssl_session_timeout 1d; + ssl_session_tickets off; + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; + ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; + ssl_ecdh_curve secp384r1; + + ssl_stapling on; + ssl_stapling_verify on; + + add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload;"; + add_header Referrer-Policy "no-referrer, strict-origin-when-cross-origin"; + add_header X-Frame-Options SAMEORIGIN; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; } server { listen 80; - server_name localhost pbs.codeito.pl www.pbs.codeito.pl; + server_name localhost test.codeito.pl www.test.codeito.pl; location / { return 301 https://$host$request_uri; diff --git a/docker/nginx-test.conf b/docker/nginx-test.conf deleted file mode 100644 index d08b9d3..0000000 --- a/docker/nginx-test.conf +++ /dev/null @@ -1,15 +0,0 @@ -server { - listen 80; - server_name localhost test.codeito.pl www.test.codeito.pl; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; - } - - location /api/ { - proxy_pass http://api:9000/api/; - } - -} diff --git a/docker/scripts/cert.txt b/docker/scripts/cert.txt new file mode 100644 index 0000000..cbe9e1a --- /dev/null +++ b/docker/scripts/cert.txt @@ -0,0 +1,7 @@ +sudo certbot-auto certonly --standalone -d test.codeito.pl -d www.test.codeito.pl +sudo openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048 + +sudo /usr/sbin/certbot-auto renew --dry-run + +crontab -e +0 2 * * * sudo /usr/sbin/certbot-auto -q renew diff --git a/docker/connect.sh b/docker/scripts/connect.sh similarity index 100% rename from docker/connect.sh rename to docker/scripts/connect.sh diff --git a/docker/cron.sh b/docker/scripts/cron.sh similarity index 100% rename from docker/cron.sh rename to docker/scripts/cron.sh diff --git a/docker/dump.sh b/docker/scripts/dump.sh similarity index 100% rename from docker/dump.sh rename to docker/scripts/dump.sh diff --git a/docker/scripts/nginx-csp-header.txt b/docker/scripts/nginx-csp-header.txt new file mode 100644 index 0000000..0263508 --- /dev/null +++ b/docker/scripts/nginx-csp-header.txt @@ -0,0 +1 @@ +add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; script-src 'unsafe-eval'; img-src 'self' data:image:; style-src 'self' 'unsafe-inline'; base-uri 'self'; form-action 'self'; object-src: 'none'"; diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh deleted file mode 100644 index 95daadb..0000000 --- a/init-letsencrypt.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -if ! [ -x "$(command -v docker-compose)" ]; then - echo 'Error: docker-compose is not installed.' >&2 - exit 1 -fi - -domains=(example.org www.example.org) -rsa_key_size=4096 -data_path="./data/certbot" -email="" # Adding a valid address is strongly recommended -staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits - -if [ -d "$data_path" ]; then - read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision - if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then - exit - fi -fi - - -if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ssl-dhparams.pem" ]; then - echo "### Downloading recommended TLS parameters ..." - mkdir -p "$data_path/conf" - curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf" - curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem" - echo -fi - -echo "### Creating dummy certificate for $domains ..." -path="/etc/letsencrypt/live/$domains" -mkdir -p "$data_path/conf/live/$domains" -docker-compose run --rm --entrypoint "\ - openssl req -x509 -nodes -newkey rsa:1024 -days 1\ - -keyout '$path/privkey.pem' \ - -out '$path/fullchain.pem' \ - -subj '/CN=localhost'" certbot -echo - - -echo "### Starting nginx ..." -docker-compose up --force-recreate -d nginx -echo - -echo "### Deleting dummy certificate for $domains ..." -docker-compose run --rm --entrypoint "\ - rm -Rf /etc/letsencrypt/live/$domains && \ - rm -Rf /etc/letsencrypt/archive/$domains && \ - rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot -echo - - -echo "### Requesting Let's Encrypt certificate for $domains ..." -#Join $domains to -d args -domain_args="" -for domain in "${domains[@]}"; do - domain_args="$domain_args -d $domain" -done - -# Select appropriate email arg -case "$email" in - "") email_arg="--register-unsafely-without-email" ;; - *) email_arg="--email $email" ;; -esac - -# Enable staging mode if needed -if [ $staging != "0" ]; then staging_arg="--staging"; fi - -docker-compose run --rm --entrypoint "\ - certbot certonly --webroot -w /var/www/certbot \ - $staging_arg \ - $email_arg \ - $domain_args \ - --rsa-key-size $rsa_key_size \ - --agree-tos \ - --force-renewal" certbot -echo - -echo "### Reloading nginx ..." -docker-compose exec nginx nginx -s reload diff --git a/prod.sh b/prod.sh new file mode 100644 index 0000000..a093096 --- /dev/null +++ b/prod.sh @@ -0,0 +1,6 @@ +#!/bin/sh +mkdir -p ./files +sudo chmod -R 777 ./files +sudo chmod -R 777 ./database/pgdata/ + +docker-compose -f ./docker/docker-compose.prod.yml up -d --build diff --git a/ui.sh b/ui.sh deleted file mode 100644 index 322e667..0000000 --- a/ui.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -npm start --prefix ui diff --git a/ui/.dockerignore b/ui/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/ui/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/ui/Dockerfile b/ui/Dockerfile index 2e16b35..0494675 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -1,17 +1,21 @@ # Stage 1 - Create a builder container -FROM node:12.8-buster-slim as builder +FROM node:12.8-buster-slim as dev -WORKDIR /usr/src/app -COPY src /usr/src/app/src -COPY public /usr/src/app/public -COPY craco.config.js /usr/src/app/craco.config.js.js -COPY package.json /usr/src/app/package.json -COPY package-lock.json /usr/src/app/package-lock.json +ENV APP_HOME=/usr/src/app/ +WORKDIR $APP_HOME +COPY src $APP_HOME/src +COPY public $APP_HOME/public +COPY craco.config.js $APP_HOME/craco.config.js.js +COPY package.json $APP_HOME/package.json +COPY package-lock.json $APP_HOME/package-lock.json RUN npm install +CMD ["npm", "start"] + +FROM dev as builder RUN npm run build # Stage 2 - Create a downsized production container -FROM nginx:1.12-alpine as deploy +FROM nginx:1.17-alpine as deploy COPY --from=builder /usr/src/app/build /usr/share/nginx/html EXPOSE 80 diff --git a/ui/craco.config.js b/ui/craco.config.js index 3ec03db..66ffbe7 100644 --- a/ui/craco.config.js +++ b/ui/craco.config.js @@ -2,10 +2,35 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const WebpackBar = require("webpackbar"); const CracoAntDesignPlugin = require("craco-antd"); const path = require("path"); +const cspHtmlWebpackPlugin = require("csp-html-webpack-plugin"); // Don't open the browser during development process.env.BROWSER = "none"; +const cspConfigPolicy = { + 'default-src': "'self'", + 'base-uri': "'self'", + 'object-src': "'self'", + 'form-action': "'self'", + 'img-src': ["'self'", "data:"], + 'script-src': ["'self'", "'unsafe-eval'"], + 'style-src': ["'unsafe-inline'", "'self'", "'unsafe-eval'"] +}; + +const cspConfigHash = { + enabled: true, + hashingMethod: 'sha256', + hashEnabled: { + 'script-src': true, + 'style-src': true + }, + nonceEnabled: { + 'script-src': true, + 'style-src': false + } +}; + + module.exports = { webpack: { // alias: { react: 'preact-compat', 'react-dom': 'preact-compat' }, @@ -13,7 +38,7 @@ module.exports = { new WebpackBar({ profile: true }), ...(process.env.NODE_ENV === "development" ? [new BundleAnalyzerPlugin({ openAnalyzer: false })] - : []) + : [new cspHtmlWebpackPlugin(cspConfigPolicy, cspConfigHash)]) ] }, diff --git a/ui/package-lock.json b/ui/package-lock.json index 326f941..deb0240 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -3060,6 +3060,69 @@ "integrity": "sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ==", "dev": true }, + "cheerio": { + "version": "1.0.0-rc.3", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz", + "integrity": "sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==", + "dev": true, + "requires": { + "css-select": "~1.2.0", + "dom-serializer": "~0.1.1", + "entities": "~1.1.1", + "htmlparser2": "^3.9.1", + "lodash": "^4.15.0", + "parse5": "^3.0.1" + }, + "dependencies": { + "css-select": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", + "dev": true, + "requires": { + "boolbase": "~1.0.0", + "css-what": "2.1", + "domutils": "1.5.1", + "nth-check": "~1.0.1" + } + }, + "dom-serializer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", + "dev": true, + "requires": { + "domelementtype": "^1.3.0", + "entities": "^1.1.1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", + "dev": true + }, + "parse5": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", + "dev": true, + "requires": { + "@types/node": "*" + } + } + } + }, "chokidar": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", @@ -4218,6 +4281,53 @@ "randomfill": "^1.0.3" } }, + "csp-html-webpack-plugin": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/csp-html-webpack-plugin/-/csp-html-webpack-plugin-3.0.4.tgz", + "integrity": "sha512-K0+PgO2QNHt77Nrj0P96fq2draYKrpWoWjdcEswAOtNeVK5UziraqP3FShsc6BAKjlUutaM5fO0TNvUARQ9x3A==", + "dev": true, + "requires": { + "cheerio": "^1.0.0-rc.2", + "lodash": "^4.17.15", + "memory-fs": "^0.5.0" + }, + "dependencies": { + "memory-fs": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", + "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "css": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz", @@ -6456,9 +6566,9 @@ "integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ==" }, "handlebars": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.3.tgz", - "integrity": "sha512-B0W4A2U1ww3q7VVthTKfh+epHx+q4mCt6iK+zEAzbMBpWQAwxCeKxEGpj/1oQTpzPXDNSOG7hmG14TsISH50yw==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", "requires": { "neo-async": "^2.6.0", "optimist": "^0.6.1", diff --git a/ui/package.json b/ui/package.json index fc497a3..95fbda5 100644 --- a/ui/package.json +++ b/ui/package.json @@ -20,7 +20,8 @@ "react-html-parser": "^2.0.2", "react-quill": "^1.3.3", "react-scripts": "^3.2.0", - "typescript": "^3.6.3" + "typescript": "^3.6.3", + "csp-html-webpack-plugin": "^3.0.4" }, "scripts": { "start": "craco start", @@ -44,9 +45,9 @@ ] }, "devDependencies": { + "http-proxy-middleware": "latest", "react-router-dom": "^5.1.2", "webpack-bundle-analyzer": "^3.5.2", - "webpackbar": "^4.0.0", - "http-proxy-middleware": "latest" + "webpackbar": "^4.0.0" } } diff --git a/ui/public/index.html b/ui/public/index.html index a146b6f..34189d5 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -1,6 +1,7 @@ + diff --git a/ui/public/logo192.png b/ui/public/logo192.png deleted file mode 100644 index fa313ab..0000000 Binary files a/ui/public/logo192.png and /dev/null differ diff --git a/ui/public/logo512.png b/ui/public/logo512.png deleted file mode 100644 index bd5d4b5..0000000 Binary files a/ui/public/logo512.png and /dev/null differ diff --git a/ui/src/auth/LoginComponent.js b/ui/src/auth/LoginComponent.js index 2bc0426..4eb7ccd 100644 --- a/ui/src/auth/LoginComponent.js +++ b/ui/src/auth/LoginComponent.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import {Button, Form, Icon, Input} from "antd"; import './LoginComponent.less'; import {serviceLogIn} from "../services/auth/AuthService"; -import {ACCESS_TOKEN} from "../config/AppConfig"; +import {ACCESS_TOKEN, devUser} from "../config/AppConfig"; import {openNotification} from "../common/Notifications"; import {NavLink} from "react-router-dom"; import {WelcomeMessages} from "../common/RandomMessages"; @@ -52,7 +52,7 @@ class LoginForm extends Component { {getFieldDecorator('userNameOrEmail', { rules: [{required: true, message: 'Podaj nazwę użytkownika lub email.'}], - initialValue: 'admin' + initialValue: process.env.NODE_ENV === "development" ? devUser.username : '' })( } className={'login-input'} placeholder={"Nazwa użytkownika lub email"} onFocus={this.handleFocus}/> @@ -61,7 +61,7 @@ class LoginForm extends Component { {getFieldDecorator('userPassword', { rules: [{required: true, message: 'Podaj hasło.'}], - initialValue: 'pass' + initialValue: process.env.NODE_ENV === "development" ? devUser.password : '' })( } className={"login-input"} type={"password"} placeholder={"Hasło"} onFocus={this.handleFocus}/> diff --git a/ui/src/config/AppConfig.js b/ui/src/config/AppConfig.js index 654db3f..49f2c0f 100644 --- a/ui/src/config/AppConfig.js +++ b/ui/src/config/AppConfig.js @@ -1,7 +1,7 @@ export const PROFILE = process.env.REACT_APP_STAGE === 'prod' ? 'prod' : 'dev'; export const devUser = { - user: 'admin', - pass: 'pass' + username: 'admin', + password: 'pass' }; export const ACCESS_TOKEN = 'authToken';