Skip to content

Commit

Permalink
feat(config): Make JWT token expiry time and issuer configurable in `…
Browse files Browse the repository at this point in the history
…config.sh`
  • Loading branch information
evansdianga committed Sep 27, 2021
1 parent 8270b1e commit 50a53c5
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ T_ARCHIVE_APKS_TO_DISK="true"
# Set to false if you would not want to archive PWAs to Disk when creating a release
T_ARCHIVE_PWAS_TO_DISK="true"

# The value to use for issuer parameter when signing JWTs.
T_JWT_ISSUER="Tangerine"
# The validity period for a signed JWT Token - determines how long before a token is conidered invalid. Expressed in seconds or a string describing a time span as defined in https://github.com/zeit/ms
T_JWT_EXPIRES_IN="1h"
#
# Development
#
Expand Down
2 changes: 2 additions & 0 deletions develop-tangy-form-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ CMD="docker run -it --name $T_CONTAINER_NAME \
--env \"T_ARCHIVE_PWAS_TO_DISK=$T_ARCHIVE_PWAS_TO_DISK\" \
--env \"T_PASSWORD_POLICY=$T_PASSWORD_POLICY\" \
--env \"T_PASSWORD_RECIPE=$T_PASSWORD_RECIPE\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
$T_PORT_MAPPING \
-p 9229:9229 \
-p 9228:9228 \
Expand Down
2 changes: 2 additions & 0 deletions develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ OPTIONS="--link $T_COUCHDB_CONTAINER_NAME:couchdb \
--env \"T_ARCHIVE_PWAS_TO_DISK=$T_ARCHIVE_PWAS_TO_DISK\" \
--env \"T_PASSWORD_POLICY=$T_PASSWORD_POLICY\" \
--env \"T_PASSWORD_RECIPE=$T_PASSWORD_RECIPE\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
$T_PORT_MAPPING \
-p 9229:9229 \
-p 9228:9228 \
Expand Down
2 changes: 2 additions & 0 deletions editor-develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ CMD="docker run -it --name $T_CONTAINER_NAME \
--env \"T_CENTRALLY_MANAGED_USER_PROFILE=$T_CENTRALLY_MANAGED_USER_PROFILE\" \
--env \"T_CATEGORIES=$T_CATEGORIES\" \
--env \"T_ORIENTATION=$T_ORIENTATION\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
$T_PORT_MAPPING \
-p 9229:9229 \
Expand Down
4 changes: 2 additions & 2 deletions server/src/auth-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const jwt = require('jsonwebtoken');
const expiresIn ='1h';
const issuer = 'Tangerine';
const issuer = process.env.T_JWT_ISSUER || 'Tangerine';
const expiresIn = process.env.T_JWT_EXPIRES_IN || '1h';
const jwtTokenSecret = require('crypto').randomBytes(256).toString('base64');

const createLoginJWT = ({ username, permissions }) => {
Expand Down
2 changes: 2 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ RUN_OPTIONS="
--env \"T_ARCHIVE_PWAS_TO_DISK=$T_ARCHIVE_PWAS_TO_DISK\" \
--env \"T_PASSWORD_POLICY=$T_PASSWORD_POLICY\" \
--env \"T_PASSWORD_RECIPE=$T_PASSWORD_RECIPE\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
$T_PORT_MAPPING \
--volume $(pwd)/content-sets:/tangerine/content-sets:delegated \
--volume $(pwd)/data/dat-output:/dat-output/ \
Expand Down
2 changes: 2 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ CMD="docker run -it --name $T_CONTAINER_NAME \
--env \"T_CENTRALLY_MANAGED_USER_PROFILE=$T_CENTRALLY_MANAGED_USER_PROFILE\" \
--env \"T_CATEGORIES=$T_CATEGORIES\" \
--env \"T_ORIENTATION=$T_ORIENTATION\" \
--env \"T_JWT_ISSUER=$T_JWT_ISSUER\" \
--env \"T_JWT_EXPIRES_IN=$T_JWT_EXPIRES_IN\" \
$T_PORT_MAPPING \
-p 9229:9229 \
Expand Down

0 comments on commit 50a53c5

Please sign in to comment.