Skip to content

Commit

Permalink
Merge pull request #103 from keitaroinc/session-from-chart
Browse files Browse the repository at this point in the history
Session secrets
  • Loading branch information
Filip3mac committed Jun 27, 2023
2 parents 5f4d842 + db21755 commit 96e9c65
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions images/ckan/2.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ RUN pip install -e /srv/app/src/ckan && \
# Remove wheels
RUN rm -rf /srv/app/wheels /srv/app/ext_wheels

# Install python2 secrets for generating sessions
RUN pip install python2-secrets

# Copy necessary scripts
COPY setup/app ${APP_DIR}

Expand Down
8 changes: 8 additions & 0 deletions images/ckan/2.7/setup/app/start_ckan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ then
done
fi

# Add session secret from chart
if [[ -z $BEAKER_SESSION_SECRET || -v $BEAKER_SESSION_SECRET ]];then
echo "Not all environment variables are set. Generating sessions..."
else
echo "Setting session secrets from environment variables"
paster --plugin=ckan config-tool $APP_DIR/production.ini "beaker.session.secret=$BEAKER_SESSION_SECRET"
fi

if grep -E "beaker.session.secret ?= ?$" $APP_DIR/production.ini
then
echo "Setting beaker.session.secret in ini file"
Expand Down
3 changes: 3 additions & 0 deletions images/ckan/2.8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ RUN pip install -e /srv/app/src/ckan && \
# Remove wheels
RUN rm -rf /srv/app/wheels /srv/app/ext_wheels

# Install python2 secrets for generating sessions
RUN pip install python2-secrets

# Copy necessary scripts
COPY setup/app ${APP_DIR}

Expand Down
8 changes: 8 additions & 0 deletions images/ckan/2.8/setup/app/start_ckan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ then
done
fi

# Add session secret from chart
if [[ -z $BEAKER_SESSION_SECRET || -v $BEAKER_SESSION_SECRET ]];then
echo "Not all environment variables are set. Generating sessions..."
else
echo "Setting session secrets from environment variables"
paster --plugin=ckan config-tool $APP_DIR/production.ini "beaker.session.secret=$BEAKER_SESSION_SECRET"
fi

if grep -E "beaker.session.secret ?= ?$" $APP_DIR/production.ini
then
echo "Setting beaker.session.secret in ini file"
Expand Down
10 changes: 10 additions & 0 deletions images/ckan/2.9/setup/app/start_ckan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ then
done
fi

# Add session secret from chart
if [[ -z $BEAKER_SESSION_SECRET || -v $BEAKER_SESSION_SECRET || -z $JWT_ENCODE_SECRET || -v $JWT_ENCODE_SECRET || -z $JWT_DECODE_SECRET || -v $JWT_DECODE_SECRET ]];then
echo "Not all environment variables are set. Generating sessions..."
else
echo "Setting session secrets from environment variables"
ckan config-tool $APP_DIR/production.ini "beaker.session.secret=$BEAKER_SESSION_SECRET"
ckan config-tool $APP_DIR/production.ini "api_token.jwt.encode.secret=$JWT_ENCODE_SECRET"
ckan config-tool $APP_DIR/production.ini "api_token.jwt.decode.secret=$JWT_DECODE_SECRET"
fi

if grep -E "beaker.session.secret ?= ?$" $APP_DIR/production.ini
then
echo "Setting secrets in ini file"
Expand Down

0 comments on commit 96e9c65

Please sign in to comment.