Skip to content

Draft: Add API endpoint to retrieve an `id_token`

Brian Williams requested to merge bwill/add-id-tokens-endpoint into master

What does this MR do and why?

Describe in detail what your merge request does and why.

Allows programs running in CI to receive OIDC tokens automatically using CI_JOB_TOKEN.

Relates to: #388514 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Screenshot_2023-05-01_at_2.39.09_PM

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure your GDK with GitLab Runner

  2. Create a new project

  3. Add a .gitlab-ci.yml with the following content:

    get_jwt:
      image: alpine:latest
      script:
        - apk add --update jq curl
        - |
          curl -v -H "JOB-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/job/id_token" -d aud=my-aud | jq '.id_token | split(".") | .[0],.[1] | @base64d | fromjson'
  4. Check the CI job log. The token data will be printed there.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Brian Williams

Merge request reports