Skip to content
Snippets Groups Projects
Commit 7de3428f authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

move authentication to initial stage, store cookie as an artifact for short time

parent 79d6afaf
No related branches found
No related tags found
No related merge requests found
...@@ -10,14 +10,23 @@ stages: ...@@ -10,14 +10,23 @@ stages:
variables: variables:
SECURE_FILES_DOWNLOAD_PATH: '.secure' SECURE_FILES_DOWNLOAD_PATH: '.secure'
get-credentials: get-cookie:
stage: pre-build stage: pre-build
image: ubuntu:jammy image: ubuntu:jammy
before_script: before_script:
- apt-get update && apt-get upgrade -y && apt-get install curl -y - apt-get update && apt-get upgrade -y && apt-get install curl jq -y
script: script:
- echo "Copying secure file with FeBio login ..." - echo "Copying secure file with FeBio login ..."
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
- export USERNAME=$(grep 'username:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ')
- export PASSWORD=$(grep 'password:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ')
- export ENCODED_USERNAME=$(printf '%s' "${USERNAME}" | jq -sRr @uri)
- export ENCODED_PASSWORD=$(printf '%s' "${PASSWORD}" | jq -sRr @uri)
- curl -c cookies.txt -X POST -d "log=${ENCODED_USERNAME}&pwd=${ENCODED_PASSWORD}&wp-submit=1" "https://febio.org/wp-login.php" -v
artifacts:
paths:
- cookies.txt
expire_in: 5 minutes
docker-build: docker-build:
stage: build stage: build
...@@ -25,10 +34,8 @@ docker-build: ...@@ -25,10 +34,8 @@ docker-build:
services: services:
- docker:dind - docker:dind
dependencies: dependencies:
- get-credentials - get-cookie
script: script:
- export USERNAME=$(grep 'username:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ')
- export PASSWORD=$(grep 'password:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ')
- docker pull $CI_REGISTRY_IMAGE:latest || true - docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg USERNAME=${USERNAME} --build-arg PASSWORD=${PASSWORD} --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest . - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg USERNAME=${USERNAME} --build-arg PASSWORD=${PASSWORD} --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment