Auth: hydra deployment + basic integration with kratos/auth-ui flow
diff --git a/core/auth/hydra/Dockerfile b/core/auth/hydra/Dockerfile
new file mode 100644
index 0000000..96ec8fa
--- /dev/null
+++ b/core/auth/hydra/Dockerfile
@@ -0,0 +1,24 @@
+FROM alpine:3.14.2
+
+RUN addgroup -S ory; \
+ adduser -S ory -G ory -D -u 10000 -h /home/ory -s /bin/nologin; \
+ chown -R ory:ory /home/ory
+
+RUN apk add -U --no-cache ca-certificates
+
+WORKDIR /downloads
+RUN wget https://github.com/ory/hydra/releases/download/v1.10.6/hydra_1.10.6_linux_arm64.tar.gz -O hydra.tar.gz
+RUN tar -xvf hydra.tar.gz
+RUN mv hydra /usr/bin
+
+VOLUME /home/ory
+WORKDIR /home/ory
+RUN rm -r /downloads
+
+# Declare the standard ports used by Hydra (4433 for public service endpoint, 4434 for admin service endpoint)
+EXPOSE 4433 4434
+
+USER 10000
+
+ENTRYPOINT ["hydra"]
+CMD ["serve"]
diff --git a/core/auth/hydra/Makefile b/core/auth/hydra/Makefile
new file mode 100644
index 0000000..232a7d7
--- /dev/null
+++ b/core/auth/hydra/Makefile
@@ -0,0 +1,5 @@
+image_arm64:
+ docker build --tag=giolekva/ory-hydra:latest .
+
+push_arm64: image_arm64
+ docker push giolekva/ory-hydra:latest
diff --git a/core/auth/hydra/hydra.yaml b/core/auth/hydra/hydra.yaml
new file mode 100644
index 0000000..a650e39
--- /dev/null
+++ b/core/auth/hydra/hydra.yaml
@@ -0,0 +1,56 @@
+version: v1.10.6
+
+dsn: postgres://postgres:psswd@postgres:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4
+
+serve:
+ cookies:
+ same_site_mode: None
+ public:
+ cors:
+ enabled: true
+ debug: true
+ allow_credentials: true
+ allowed_origins:
+ - https://lekva.me
+ - https://*.lekva.me
+ admin:
+ # host: localhost
+ cors:
+ allowed_origins:
+ - https://hydra.pcloud
+ tls:
+ allow_termination_from:
+ - 0.0.0.0/0
+ - 10.42.0.0/16
+ - 10.43.0.0/16
+ - 111.0.0.1/32
+ tls:
+ allow_termination_from:
+ - 0.0.0.0/0
+ - 10.42.0.0/16
+ - 10.43.0.0/16
+ - 111.0.0.1/32
+
+urls:
+ self:
+ public: https://hydra.lekva.me
+ issuer: https://hydra.lekva.me
+ consent: https://accounts-ui.lekva.me/consent
+ login: https://accounts-ui.lekva.me/login
+ logout: https://accounts-ui.lekva.me/logout
+
+secrets:
+ system:
+ - youReallyNeedToChangeThis
+
+oidc:
+ subject_identifiers:
+ supported_types:
+ - pairwise
+ - public
+ pairwise:
+ salt: youReallyNeedToChangeThis
+
+log:
+ level: trace
+ leak_sensitive_values: true
diff --git a/core/auth/hydra/install.yaml b/core/auth/hydra/install.yaml
new file mode 100644
index 0000000..b9a8d4d
--- /dev/null
+++ b/core/auth/hydra/install.yaml
@@ -0,0 +1,161 @@
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: core-auth
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: hydra
+ namespace: core-auth
+spec:
+ type: ClusterIP
+ selector:
+ app: hydra
+ ports:
+ - name: public
+ port: 80
+ targetPort: public
+ protocol: TCP
+ - name: admin
+ port: 81
+ targetPort: admin
+ protocol: TCP
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: ingress-hydra-public
+ namespace: core-auth
+ annotations:
+ cert-manager.io/cluster-issuer: "letsencrypt-prod"
+ acme.cert-manager.io/http01-edit-in-place: "true"
+spec:
+ ingressClassName: nginx
+ tls:
+ - hosts:
+ - hydra.lekva.me
+ secretName: cert-hydra.lekva.me
+ rules:
+ - host: hydra.lekva.me
+ http:
+ paths:
+ - path: /
+ pathType: Prefix
+ backend:
+ service:
+ name: hydra
+ port:
+ name: public
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: ingress-hydra-private
+ namespace: core-auth
+ annotations:
+ cert-manager.io/cluster-issuer: "selfsigned-ca"
+ acme.cert-manager.io/http01-edit-in-place: "true"
+spec:
+ ingressClassName: nginx-private
+ tls:
+ - hosts:
+ - hydra.pcloud
+ secretName: cert-hydra.pcloud
+ rules:
+ - host: hydra.pcloud
+ http:
+ paths:
+ - path: /
+ pathType: Prefix
+ backend:
+ service:
+ name: hydra
+ port:
+ name: admin
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: hydra
+ namespace: core-auth
+spec:
+ selector:
+ matchLabels:
+ app: hydra
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: hydra
+ spec:
+ volumes:
+ - name: config
+ configMap:
+ name: hydra
+ containers:
+ - name: hydra
+ image: giolekva/ory-hydra:latest
+ imagePullPolicy: IfNotPresent
+ ports:
+ - name: public
+ containerPort: 4444
+ protocol: TCP
+ - name: admin
+ containerPort: 4445
+ protocol: TCP
+ command:
+ - "hydra"
+ - "--config=/etc/hydra/config/hydra.yaml"
+ - "serve"
+ - "all"
+ #command: ["hydra", "serve"]
+ # resources:
+ # requests:
+ # memory: "10Mi"
+ # cpu: "10m"
+ # limits:
+ # memory: "20Mi"
+ # cpu: "100m"
+ volumeMounts:
+ - name: config
+ mountPath: /etc/hydra/config
+---
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: hydra-migrate
+ namespace: core-auth
+spec:
+ template:
+ metadata:
+ labels:
+ app: hydra-migrate
+ spec:
+ restartPolicy: OnFailure
+ volumes:
+ - name: config
+ configMap:
+ name: hydra
+ containers:
+ - name: hydra
+ image: giolekva/ory-hydra:latest
+ imagePullPolicy: IfNotPresent
+ command:
+ - "hydra"
+ - "migrate"
+ - "sql"
+ - "-y"
+ - "postgres://postgres:psswd@postgres:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4"
+ #command: ["hydra", "serve"]
+ # resources:
+ # requests:
+ # memory: "10Mi"
+ # cpu: "10m"
+ # limits:
+ # memory: "20Mi"
+ # cpu: "100m"
+ volumeMounts:
+ - name: config
+ mountPath: /etc/hydra/config