keycloak-proxy

by joaquinito2051

Helm chartv0.0.1App 3.4.2.Final

Keycloak Proxy supports Single Sign-On with Keycloak

About this chart

Keycloak Proxy

Keycloak has an HTTP(S) proxy that you can put in front of web applications and services where it is not possible to install the Keycloak adapter. You can set up URL filters so that certain URLs are secured either by browser login and/or bearer token authentication. You can also define role constraints for URL patterns within your applications.

TL;DR;

$ helm install <helm-repo>/keycloak-proxy

$ helm install incubator/keycloak-proxy

Introduction

This chart bootstraps a Keycloak Proxy Deployment on a Kubernetes cluster using the Helm package manager. It provisions a fully featured Keycloak Proxy installation. For more information on Keycloak and its capabilities, see its documentation and Docker Hub repository.

Prerequisites Details

Keycloak Proxy is designed primarily for Keycloak, an OpenID Connect identity provider. But it also works with other OpenID Connect identity providers.

Installing the Chart

To install the chart with the release name keycloak-proxy:

$ helm install --name keycloak-proxy <helm-repo>/keycloak-proxy

$ helm install --name keycloak-proxy incubator/keycloak-proxy

Uninstalling the Chart

To uninstall/delete the keycloak-proxy deployment:

$ helm delete keycloak-proxy

Configuration

The following table lists the configurable parameters of the Keycloak chart and their default values.

ParameterDescriptionDefault
image.repositoryKeycloak Proxy image repositoryjboss/keycloak-proxy
image.tagKeycloak Proxy image version3.4.2.Final
image.pullPolicyKeycloak Proxy image pull policyIfNotPresent
service.typeThe service typeClusterIP
service.portThe service port80
service.nodePortThe service nodePort""
ingress.enabledIf true, an ingress is be createdfalse
ingress.annotationsAnnotations for the ingress{}
ingress.pathPath for backend/
ingress.hostsA list of hosts for the ingresss[keycloak-proxy.example.com]
ingress.tls.secretNameIf tls is enabled, uses an existing secret with this name""
ingress.tls.hostsA list of hosts for""
resourcesCPU/Memory resource requests/limits{}
nodeSelectorNode labels for pod assignment{}
tolerationsTolerations for pod assignment[]
affinityNode/Pod affinities{}
configmap.targetUrlThe URL this server is proxyinghttp://url-to-the-target-server.example.com
configmap.realmName of the realmREALM_NAME
configmap.realmPublicKeyPEM format of the realm public key. You can obtain this from the administration console. This is OPTIONAL and it’s not recommended to set it. If not set, the adapter will download this from Keycloak and it will always re-download it when needed (eg. Keycloak rotate it’s keys). However if realm-public-key is set, then adapter will never download new keys from Keycloak, so when Keycloak rotate it’s keys, adapter will break""
configmap.authServerUrlThe base URL of the Keycloak server. All other Keycloak pages and REST service endpoints are derived from this. It is usually of the form https://host:port/authhttp://url-to-keycloak.example.com/auth
configmap.resourceThe client-id of the application. Each application has a client-id that is used to identify the applicationCLIENT_ID
configmap.secretSpecify the credentials of the application. This is an object notation where the key is the credential type and the value is the value of the credential type. Currently password and jwt is supported. This is REQUIRED only for clients with 'Confidential' access typeCLIENT_SECRET
configmap.patternURL pattern to match relative to the base-path of the application. Must start with '/' REQUIRED. You may only have one wildcard and it must come at the end of the pattern/admin
configmap.rolesAllowedArray of strings of roles allowed to access this url patternadmin

Specify each parameter using the --set key=value[,key=value] argument to helm install.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, Specify each parameter using the --set key=value[,key=value] argument to helm install.

$ helm install --name keycloak-proxy -f values.yaml <helm-repo>/keycloak-proxy

$ helm install --name keycloak-proxy -f values.yaml incubator/keycloak-proxy

Proxy Configuration

The following configurations which are located in a configmap are required to request authentication and authorization. Please refer to Keycloak Proxy and Adapter Config for more information.

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "fullname" . }}-configmap
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
data:
  proxy.json: |
    {
       "target-url":"{{ .Values.configmap.targetUrl }}",
       "bind-address":"0.0.0.0",
       "http-port":"8080",
       "applications":[
          {
             "base-path":"/",
             "adapter-config":{
                "realm":"{{ .Values.configmap.realm }}",
                "realm-public-key": "{{ .Values.configmap.realmPublicKey }}",
                "auth-server-url":"{{ .Values.configmap.authServerUrl }}",
                "ssl-required":"external",
                "resource":"{{ .Values.configmap.resource }}",
                "credentials": {
                  "secret": "{{ .Values.configmap.secret }}"
                }
             },
             "constraints":[
               {
                  "pattern":"{{ .Values.configmap.pattern }}",
                  "roles-allowed":[
                    "{{ .Values.configmap.rolesAllowed }}"
                  ]
               }
             ],
             "proxy-address-forwarding": true
          }
       ]
    }

Demo

Keycloak Proxy Demo will help you understand the concept and behavior of this Proxy.

Deploy keycloak-proxy with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has keycloak-proxy on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkeycloak-proxy is pinned at v0.0.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply