Skip to content

Commit 9cddff0

Browse files
authored
Merge pull request #111 from teohhanhui/feat/add-jwt-auth
Add JWT authentication
2 parents 49f867a + 4f69989 commit 9cddff0

31 files changed

+823
-169
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ indent_size = 4
3838
indent_style = tab
3939
indent_size = 4
4040

41+
[*.vcl]
42+
indent_style = space
43+
indent_size = 2
44+
4145
[*.xml]
4246
indent_style = space
4347
indent_size = 4

api/.dockerignore

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
**/*.log
2+
**/*.md
3+
**/*.php~
24
**/._*
5+
**/.dockerignore
36
**/.DS_Store
4-
**/.gitignore
7+
**/.git/
58
**/.gitattributes
9+
**/.gitignore
10+
**/.gitmodules
11+
**/Dockerfile
612
**/Thumbs.db
7-
**/*.md
8-
**/.dockerignore
9-
Dockerfile*
13+
.editorconfig
1014
.env*
11-
!var/.gitignore
12-
var/*
13-
helm/*
15+
.php_cs.cache
16+
bin/*
17+
!bin/console
18+
config/jwt/
19+
docker/db/data/
20+
helm/
21+
public/bundles/
22+
var/
23+
vendor/

api/.env

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
1414
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
1515

16+
MERCURE_SUBSCRIBE_URL=https://localhost:1338/hub
17+
VARNISH_URL=http://cache-proxy
18+
1619
###> symfony/framework-bundle ###
1720
APP_ENV=dev
1821
APP_SECRET=!ChangeMe!
@@ -36,5 +39,8 @@ MERCURE_PUBLISH_URL=http://mercure/hub
3639
MERCURE_JWT_SECRET=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJmb28iLCJiYXIiXSwicHVibGlzaCI6WyJmb28iXX19.qOwClmp3euDLhEQ2lOB0TLUHsobaAoe-nZ1iU3h_Eas
3740
###< symfony/mercure-bundle ###
3841

39-
MERCURE_SUBSCRIBE_URL=https://localhost:1338/hub
40-
VARNISH_URL=http://cache-proxy
42+
###> lexik/jwt-authentication-bundle ###
43+
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
44+
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
45+
JWT_PASSPHRASE=7bda7ed689c1b2ed0ebd5c43d6914e47
46+
###< lexik/jwt-authentication-bundle ###

api/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ behat.yml
1414
/helm/api/charts
1515
/helm/api/requirements.lock
1616
/coverage
17+
18+
###> lexik/jwt-authentication-bundle ###
19+
/config/jwt/*.pem
20+
###< lexik/jwt-authentication-bundle ###

api/Dockerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# the different stages of this Dockerfile are meant to be built into separate images
2+
# https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
23
# https://docs.docker.com/compose/compose-file/#target
34

4-
ARG PHP_VERSION=7.2
5+
ARG PHP_VERSION=7.3
56
ARG NGINX_VERSION=1.15
6-
ARG VARNISH_VERSION=6.0
7+
ARG VARNISH_VERSION=6.2
78

9+
10+
# "php" stage
811
FROM php:${PHP_VERSION}-fpm-alpine AS api_platform_php
912

1013
# persistent / runtime deps
@@ -13,10 +16,10 @@ RUN apk add --no-cache \
1316
file \
1417
gettext \
1518
git \
16-
postgresql-client \
19+
openssl \
1720
;
1821

19-
ARG APCU_VERSION=5.1.11
22+
ARG APCU_VERSION=5.1.17
2023
RUN set -eux; \
2124
apk add --no-cache --virtual .build-deps \
2225
$PHPIZE_DEPS \
@@ -64,8 +67,9 @@ COPY docker/php/php.ini /usr/local/etc/php/php.ini
6467

6568
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
6669
ENV COMPOSER_ALLOW_SUPERUSER=1
70+
# install Symfony Flex globally to speed up download of Composer packages (parallelized prefetching)
6771
RUN set -eux; \
68-
composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
72+
composer global require "symfony/flex" --prefer-dist --no-progress --no-suggest --classmap-authoritative; \
6973
composer clear-cache
7074
ENV PATH="${PATH}:/root/.composer/vendor/bin"
7175

@@ -82,7 +86,11 @@ RUN set -eux; \
8286
composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress --no-suggest; \
8387
composer clear-cache
8488

85-
COPY . ./
89+
# copy only specifically what we need
90+
COPY bin bin/
91+
COPY config config/
92+
COPY public public/
93+
COPY src src/
8694

8795
RUN set -eux; \
8896
mkdir -p var/cache var/log; \
@@ -97,6 +105,9 @@ RUN chmod +x /usr/local/bin/docker-entrypoint
97105
ENTRYPOINT ["docker-entrypoint"]
98106
CMD ["php-fpm"]
99107

108+
109+
# "nginx" stage
110+
# depends on the "php" stage above
100111
FROM nginx:${NGINX_VERSION}-alpine AS api_platform_nginx
101112

102113
COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
@@ -105,6 +116,9 @@ WORKDIR /srv/api
105116

106117
COPY --from=api_platform_php /srv/api/public public/
107118

119+
120+
# "varnish" stage
121+
# does not depend on any of the above stages, but placed here to keep everything in one Dockerfile
108122
FROM cooptilleuls/varnish:${VARNISH_VERSION} AS api_platform_varnish
109123

110124
COPY docker/varnish/conf/default.vcl /usr/local/etc/varnish/default.vcl

api/composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
"type": "project",
33
"license": "MIT",
44
"require": {
5-
"php": "^7.1.3",
5+
"php": "^7.2",
6+
"ext-ctype": "*",
67
"ext-iconv": "*",
78
"api-platform/api-pack": "^1.1",
8-
"api-platform/core": "^2.4@dev",
9+
"api-platform/core": "2.4.x-dev",
910
"doctrine/doctrine-migrations-bundle": "^2.0",
1011
"guzzlehttp/guzzle": "^6.3",
12+
"lexik/jwt-authentication-bundle": "^2.6",
1113
"ramsey/uuid-doctrine": "^1.5",
1214
"sensiolabs/security-checker": "^5.0",
1315
"symfony/console": "4.2.*",
1416
"symfony/dotenv": "4.2.*",
1517
"symfony/flex": "^1.1",
1618
"symfony/framework-bundle": "4.2.*",
17-
"symfony/mercure-bundle": "*",
19+
"symfony/mercure-bundle": "^0.1.1",
1820
"symfony/yaml": "4.2.*",
1921
"webonyx/graphql-php": "^0.13"
2022
},
@@ -27,6 +29,7 @@
2729
"behatch/contexts": "^3.0",
2830
"hautelook/alice-bundle": "^2.3",
2931
"symfony/dotenv": "4.2.*",
32+
"symfony/maker-bundle": "^1.11",
3033
"symfony/profiler-pack": "^1.0",
3134
"symfony/var-dumper": "4.2.*"
3235
},
@@ -50,9 +53,10 @@
5053
"paragonie/random_compat": "2.*",
5154
"symfony/polyfill-ctype": "*",
5255
"symfony/polyfill-iconv": "*",
53-
"symfony/polyfill-php71": "*",
56+
"symfony/polyfill-php56": "*",
5457
"symfony/polyfill-php70": "*",
55-
"symfony/polyfill-php56": "*"
58+
"symfony/polyfill-php71": "*",
59+
"symfony/polyfill-php72": "*"
5660
},
5761
"scripts": {
5862
"auto-scripts": {

0 commit comments

Comments
 (0)