Skip to content

Commit

Permalink
Bump ckanext-auth; Add JWT token generation back in (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolidori authored Nov 3, 2023
1 parent 902204f commit 4db372f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ckan-backend-dev/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ CKAN___SCHEMING__DATASET_SCHEMAS=ckanext.wri.schema:ckan_dataset.yaml
CKAN___SCHEMING__ORGANIZATION_SCHEMAS=ckanext.scheming:custom_org_with_address.json
CKAN___SCHEMING__GROUP_SCHEMAS=ckanext.scheming:custom_group_with_status.json
CKAN___SCHEMING__PRESETS=ckanext.wri.schema:presets.json

# auth
CKANEXT__AUTH__INCLUDE_FRONTEND_LOGIN_TOKEN=True
18 changes: 16 additions & 2 deletions ckan-backend-dev/ckan/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ RUN pip3 install -e 'git+https://github.com/datopian/ckanext-scheming.git@ckan-2
pip3 install -e 'git+https://github.com/datopian/ckanext-s3filestore.git@wri/cost-splitting-orgs#egg=ckanext-s3filestore' && \
pip3 install -r 'https://raw.githubusercontent.com/datopian/ckanext-s3filestore/wri/cost-splitting-orgs/requirements.txt' && \
pip3 install -r 'https://raw.githubusercontent.com/datopian/ckanext-s3filestore/wri/cost-splitting-orgs/dev-requirements.txt' && \
# We're using the v2.10 branch of ckanext-auth, but I'm adding a commit to force a rebuild of the image. This can be removed once ckanext-auth is approved
pip3 install -e 'git+https://github.com/datopian/ckanext-auth.git@e45cccf43abbdf9d9069047e646b3e42307e81e1#egg=ckanext-auth'
pip3 install -e 'git+https://github.com/datopian/ckanext-auth.git@auth-object-return-token#egg=ckanext-auth'

# Update ckanext-s3filestore test.ini with minio credentials
RUN sed -i "s|ckanext.s3filestore.aws_access_key_id = test-access-key|ckanext.s3filestore.aws_access_key_id = ${AWS_ACCESS_KEY_ID}|g" src/ckanext-s3filestore/test.ini && \
Expand Down Expand Up @@ -62,4 +61,19 @@ COPY setup/start_ckan_development.sh.override ${APP_DIR}/start_ckan_development.
RUN chmod +x ${APP_DIR}/start_ckan_development.sh
RUN chown ckan:ckan ${APP_DIR}/start_ckan_development.sh

USER root

RUN apk --no-cache add openssl

USER ckan

RUN openssl genpkey -algorithm RSA -out ${APP_DIR}/jwtRS256.key && \
openssl rsa -in ${APP_DIR}/jwtRS256.key -pubout -outform PEM -out ${APP_DIR}/jwtRS256.key.pub && \
chown ckan:ckan ${APP_DIR}/jwtRS256.key && \
chown ckan:ckan ${APP_DIR}/jwtRS256.key.pub

RUN ckan config-tool ${CKAN_INI} "api_token.jwt.algorithm = RS256" && \
ckan config-tool ${CKAN_INI} "api_token.jwt.encode.secret = file:${APP_DIR}/jwtRS256.key" && \
ckan config-tool ${CKAN_INI} "api_token.jwt.decode.secret = file:${APP_DIR}/jwtRS256.key.pub"

CMD ["sh", "-c", "${APP_DIR}/start_ckan_development.sh"]
15 changes: 13 additions & 2 deletions deployment/ckan/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ RUN pip3 install -e 'git+https://github.com/datopian/ckanext-scheming.git@ckan-2
pip3 install -e 'git+https://github.com/datopian/ckanext-s3filestore.git@wri/cost-splitting-orgs#egg=ckanext-s3filestore' && \
pip3 install -r 'https://raw.githubusercontent.com/datopian/ckanext-s3filestore/wri/cost-splitting-orgs/requirements.txt' && \
pip3 install -r 'https://raw.githubusercontent.com/datopian/ckanext-s3filestore/wri/cost-splitting-orgs/dev-requirements.txt' && \
# We're using the v2.10 branch of ckanext-auth, but I'm adding a commit to force a rebuild of the image. This can be removed once ckanext-auth is approved
pip3 install -e 'git+https://github.com/datopian/ckanext-auth.git@e45cccf43abbdf9d9069047e646b3e42307e81e1#egg=ckanext-auth'
pip3 install -e 'git+https://github.com/datopian/ckanext-auth.git@auth-object-return-token#egg=ckanext-auth'

COPY ckanext-wri ${APP_DIR}/src/ckanext-wri
USER root
Expand All @@ -34,4 +33,16 @@ RUN ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}"
COPY setup/prerun.py.override ${APP_DIR}/prerun.py
USER root
RUN chmod +x ${APP_DIR}/prerun.py

RUN apk --no-cache add openssl

USER ckan

RUN openssl genpkey -algorithm RSA -out ${APP_DIR}/jwtRS256.key && \
openssl rsa -in ${APP_DIR}/jwtRS256.key -pubout -outform PEM -out ${APP_DIR}/jwtRS256.key.pub && \
chown ckan:ckan ${APP_DIR}/jwtRS256.key && \
chown ckan:ckan ${APP_DIR}/jwtRS256.key.pub

RUN ckan config-tool ${CKAN_INI} "api_token.jwt.algorithm = RS256" && \
ckan config-tool ${CKAN_INI} "api_token.jwt.encode.secret = file:${APP_DIR}/jwtRS256.key" && \
ckan config-tool ${CKAN_INI} "api_token.jwt.decode.secret = file:${APP_DIR}/jwtRS256.key.pub"
1 change: 1 addition & 0 deletions deployment/helm-templates/values.yaml.dev.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ckan:
CKAN___SCHEMING__ORGANIZATION_SCHEMAS: ckanext.scheming:custom_org_with_address.json
CKAN___SCHEMING__GROUP_SCHEMAS: ckanext.scheming:custom_group_with_status.json
CKAN___SCHEMING__PRESETS: ckanext.wri.schema:presets.json
CKANEXT__AUTH__INCLUDE_FRONTEND_LOGIN_TOKEN: "True"
hpa:
enable: true
minReplicas: 2
Expand Down

0 comments on commit 4db372f

Please sign in to comment.