vmware-tanzu-labs / educates-training-platform

A platform for hosting interactive workshop environments in Kubernetes, or on top of a local container runtime.
https://docs.educates.dev
Apache License 2.0
63 stars 14 forks source link

Supply variables for base64 encode auth credentials. #444

Closed GrahamDumpleton closed 1 week ago

GrahamDumpleton commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Image registry and git server credentials in simple cases need to be supplied in base64 encoded form as username:password.

For docker this is needed in dockerconfigjson file format, as well as HTTP Authenticate header for Basic auth.

For git this is needed for HTTP Authenticate header for Basic auth.

At the moment the credentials for these are only supplied as separate raw username and password making it impossible to easily use them in cases above where need to do it in the work shop definition.

Describe the solution you'd like

Would like to see the following variables:

where the value of these is equivalent to:

echo -n $username:$password | base64

This would then allow for example:

    ingresses:
    - name: public-registry
      host: $(session_name)-registry
      port: 5000
      protocol: http
      headers:
      - name: Authorization
        value: "Basic $(registry_auth_token)"
      authentication:
        type: none
      changeOrigin: false

which in this case allows the normally authenticated session image registry to be made public readable/writable.

Describe alternatives you've considered

No response

Additional information

A way to hack up this particular example at the moment is to use:

    ingresses:
    - name: public-registry
      host: $(session_name)-registry
      port: 5000
      protocol: http
      headers:
      - name: Authorization
        value: "Basic REGISTRY_AUTH_TOKEN"
      authentication:
        type: none
    changeOrigin: false

and use a setup.d script which does:

#!/bin/bash

sed -i -e "s/REGISTRY_AUTH_TOKEN/$(echo -n $REGISTRY_USERNAME:$REGISTRY_PASSWORD | base64)/" $HOME/.local/share/workshop/workshop-definition.json