chartmuseum icon indicating copy to clipboard operation
chartmuseum copied to clipboard

Use keycloak for chartmuseum auth

Open abinch opened this issue 7 years ago • 5 comments

I am trying to use keycloak to do the authentication and authorization of chartmuseum,but it failed. I want to know whether chartmuseum can auth by keycloak?

abinch avatar Jun 21 '19 04:06 abinch

Keycloak can be used for chartmuseum auth. We tried Keycloak with another service before. What kind of issue did you meet?

hzpfly avatar Jun 24 '19 02:06 hzpfly

I want to know which protocol shall I use. openid-connect,saml or docker-v2? I have try curl -H "Content-Type: application/x-www-form-urlencoded" -i -k https://mykeycloak.com:8443/auth/realms/chart/protocol/openid-connect/token -X POST -d "grant_type=password&username=admin&password=admin&client_id=helmchart&scope =artifact-repository:mychart:push"

then I get the access token.

curl http://mychartmuseum.com/api/mychart/charts --data-binary "chart-registry-1.1.0+666.tgz" -v -H "Authorization: Bearer $TOKEN"

It's tell me 401 Unauthorized

abinch avatar Jun 24 '19 03:06 abinch

  containers:
  - args:
    - --port=8080
    - --storage-local-rootdir=/storage
    env:
    - name: AUTH_ANONYMOUS_GET
      value: "true"
    - name: AUTH_REALM
      value: https://mykeycloak.com:8443/auth/realms/chart/protocol/openid-connect/token
    - name: AUTH_SERVICE
      value: helmchart
    - name: BEARER_AUTH
      value: "true"
    - name: AUTH_CERT_PATH
      value: /var/keys/ca.pem
    - name: CHART_POST_FORM_FIELD_NAME
      value: chart
    - name: DEPTH
      value: "1"
    - name: DISABLE_METRICS
      value: "true"
    - name: LOG_JSON
      value: "true"
    - name: PROV_POST_FORM_FIELD_NAME
      value: prov
    - name: STORAGE
      value: local
    image: mychartmuseum:1.1.0-111
    imagePullPolicy: IfNotPresent

Here is a part of my deployment.yaml

abinch avatar Jun 24 '19 04:06 abinch

@jdolitsky I notice you have some commits on bear auth in https://github.com/helm/chartmuseum/pull/190. Would you please give us some comments on this issue?

hzpfly avatar Jun 25 '19 03:06 hzpfly

I hava solved the problem.I used docker-v2 protocol,and get token by

curl -H "Authorization Basic $AUTH_HEADER" "https://mykeycloak.com:8443/auth/realms/chart/protocol/docker-v2/auth?service=helmchart&scope=$SCOPE"

Then you can use the token like this guide chartmuseum/auth-server-example

abinch avatar Jun 26 '19 09:06 abinch