mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-09-21 17:53:32 +08:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9125e76596 | ||
|
|
653b747829 | ||
|
|
ba79a30f2e | ||
|
|
8c5094bbcd |
@@ -81,7 +81,6 @@ A huge thank you to [selfh.st](https://selfh.st) for their generous donation to
|
||||
|
||||
- [JetBrains for Open-Source](https://jb.gg/OpenSource)
|
||||
- [CodeRabbit AI](https://www.coderabbit.ai)
|
||||
- [InstaPods](https://instapods.com) - [Deploy Tinyauth from 3$/month](https://app.instapods.com/dashboard/pods/create?app=tinyauth&ref=tinyauth)
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
"axios": "^1.20.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"i18next": "^26.4.1",
|
||||
"i18next": "^26.4.2",
|
||||
"i18next-browser-languagedetector": "^8.2.1",
|
||||
"i18next-resources-to-backend": "^1.2.3",
|
||||
"lucide-react": "^1.38.0",
|
||||
"lucide-react": "^1.40.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"radix-ui": "^1.6.7",
|
||||
"react": "^19.2.8",
|
||||
@@ -43,14 +43,14 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@tanstack/eslint-plugin-query": "^5.102.8",
|
||||
"@types/node": "^26.4.0",
|
||||
"@types/node": "^26.4.1",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.5",
|
||||
"@types/react-dom": "^19.2.7",
|
||||
"@vitejs/plugin-react": "^6.1.1",
|
||||
"eslint": "^10.9.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.5",
|
||||
"globals": "^17.11.0",
|
||||
"eslint-plugin-react-refresh": "^0.5.6",
|
||||
"globals": "^17.12.0",
|
||||
"rollup-plugin-visualizer": "^7.1.1",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"typescript": "~6.0.2",
|
||||
|
||||
Generated
+282
-282
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ require (
|
||||
github.com/cenkalti/backoff/v5 v5.0.3
|
||||
github.com/docker/docker v28.5.2+incompatible
|
||||
github.com/gin-gonic/gin v1.12.0
|
||||
github.com/go-jose/go-jose/v4 v4.1.4
|
||||
github.com/go-jose/go-jose/v4 v4.1.5
|
||||
github.com/go-ldap/ldap/v3 v3.4.14
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/golang-migrate/migrate/v4 v4.19.1
|
||||
@@ -23,14 +23,14 @@ require (
|
||||
github.com/tinyauthapp/paerser v0.0.0-20260410140347-85c3740d6298
|
||||
github.com/weppos/publicsuffix-go v0.50.3
|
||||
go.uber.org/dig v1.19.0
|
||||
golang.org/x/crypto v0.55.0
|
||||
golang.org/x/crypto v0.56.0
|
||||
golang.org/x/net v0.58.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/tools v0.49.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/apimachinery v0.37.0
|
||||
k8s.io/client-go v0.37.0
|
||||
modernc.org/sqlite v1.57.0
|
||||
modernc.org/sqlite v1.58.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -145,9 +145,9 @@ require (
|
||||
k8s.io/klog/v2 v2.140.0 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad // indirect
|
||||
k8s.io/utils v0.0.0-20260626114624-be93311217bd // indirect
|
||||
modernc.org/libc v1.74.4 // indirect
|
||||
modernc.org/libc v1.75.6 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
modernc.org/memory v1.12.1 // indirect
|
||||
rsc.io/qr v0.2.0 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
|
||||
sigs.k8s.io/randfill v1.0.0 // indirect
|
||||
|
||||
@@ -115,8 +115,8 @@ github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 h1:H9AZkK22UOmfX8J84ubyaZxKJZ3FMHVwn8swoMML7iQ=
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
|
||||
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-jose/go-jose/v4 v4.1.5 h1:RjgjO2LOtWOJKUC5wpwY9LR3B3vwVAz6JS2YHfYU6eA=
|
||||
github.com/go-jose/go-jose/v4 v4.1.5/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14 h1:D6PYdEgsaVzsXyr6w/yDC06Ria4uUhWm+Rb+er8lfAs=
|
||||
github.com/go-ldap/ldap/v3 v3.4.14/go.mod h1:S4eJUMUNjDkE0ZJtIZdybwyb03sGGLW6gxXT1Hs8VKA=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
@@ -355,8 +355,8 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
|
||||
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
|
||||
golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
|
||||
golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I=
|
||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
|
||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
||||
golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
|
||||
@@ -410,30 +410,30 @@ k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad h1:oXImqH8mQNk7PmvzKhmN3d
|
||||
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad/go.mod h1:0/mqHCVhlumdJ3BhCfnjSZQE037nAhNodh1/hK0T8/I=
|
||||
k8s.io/utils v0.0.0-20260626114624-be93311217bd h1:Ea7fgQ5we8Y9T0OX5o0dAHzQOBRI07D/dEYRaB9ZZEs=
|
||||
k8s.io/utils v0.0.0-20260626114624-be93311217bd/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
|
||||
modernc.org/cc/v4 v4.29.1 h1:MKgdCV3WykTSPqpVrnxdEDS0HEd2FHpKZDzxzU5LyeI=
|
||||
modernc.org/cc/v4 v4.29.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
|
||||
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
|
||||
modernc.org/cc/v4 v4.29.2 h1:h6+9ciCnPKutf4I03CvheAvDLX7+IHlqR6Iy6J+cgd8=
|
||||
modernc.org/cc/v4 v4.29.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.35.0 h1:F+TUsmw09QxLzmi3aeYYGxjAXarmZaKgj3mKQHNaA8w=
|
||||
modernc.org/ccgo/v4 v4.35.0/go.mod h1:qrVGs9S3Sr2Ztcg9ve+kTAYMp5a3YvWjo+SoN06kJ5I=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
|
||||
modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/gc/v3 v3.1.5 h1:21ldfPfRYE31Tb7B3mwAK8gy1AxP4+dKjrOQPfqakoc=
|
||||
modernc.org/gc/v3 v3.1.5/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.74.4 h1:fX1Omw4o2/1C2iRkkIsrQTasJQldLhRmuPreXLoWs9k=
|
||||
modernc.org/libc v1.74.4/go.mod h1:eeQAS9W3sZeKYMFubydxJpII9ybHWshk+7or7bLG9co=
|
||||
modernc.org/libc v1.75.6 h1:yKk8qo+Di4gkmvRboK8ocCqH22FiUCR6jRy2OwtCRus=
|
||||
modernc.org/libc v1.75.6/go.mod h1:bO5o2ztHxBb2rjz0PgdHN0sSMw57CgxGFLZ3Qd/QpVQ=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.57.0 h1:qNQP6xnx5M0ISNtlnxoOX0+cD5bJ0/gr9aMmndFczzg=
|
||||
modernc.org/sqlite v1.57.0/go.mod h1:yCJ2cmAaIkHQ25oXWrF8H4O1lIfPYPR26yCEDj2P3pQ=
|
||||
modernc.org/sqlite v1.58.0 h1:38u40/bwkfM7f0Myhosl+SEMltSDxnGdQf8o6Kjmys0=
|
||||
modernc.org/sqlite v1.58.0/go.mod h1:rsD2CckafgObKC4DhBlGBf+RiHxkc3hINGt1Xw32tVY=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
services:
|
||||
{{ if eq .Proxy "caddy" }}
|
||||
{{ template "caddy" . }}
|
||||
{{ else if eq .Proxy "traefik" }}
|
||||
{{ template "traefik" . }}
|
||||
{{ else if eq .Proxy "nginx" }}
|
||||
{{ template "nginx" . }}
|
||||
{{ else if eq .Proxy "envoy" }}
|
||||
{{ template "envoy" . }}
|
||||
{{ else }}
|
||||
{{ template "traefik" . }}
|
||||
{{ end }}
|
||||
|
||||
whoami:
|
||||
image: traefik/whoami:v1.12.0
|
||||
pull_policy: missing
|
||||
|
||||
tinyauth:
|
||||
{{ if .Build }}
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- VERSION=e2e
|
||||
- BUILD_TAGS=nomsgpack
|
||||
- LDFLAGS=-s -w
|
||||
{{ else }}
|
||||
image: ghcr.io/tinyauthapp/tinyauth:{{ .Version }}
|
||||
{{ end }}
|
||||
pull_policy: missing
|
||||
command: ["--configfile", "/config.yaml"]
|
||||
volumes:
|
||||
- ./tinyauth.config.yaml:/config.yaml:ro
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{{ define "caddy" }}
|
||||
caddy:
|
||||
image: caddy:2.11.4
|
||||
pull_policy: missing
|
||||
ports:
|
||||
- {{ .Proxy.Port }}:80
|
||||
configs:
|
||||
- source: caddy_caddyfile
|
||||
target: /etc/caddy/Caddyfile
|
||||
mode: 0664
|
||||
{{ end }}
|
||||
|
||||
{{ define "caddy_config" }}
|
||||
caddy_caddyfile:
|
||||
content: |
|
||||
{
|
||||
auto_https off
|
||||
}
|
||||
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
http://{{ .Domains.Whoami }} {
|
||||
forward_auth tinyauth:3000 {
|
||||
uri /api/auth/caddy
|
||||
copy_headers Remote-User Remote-Name Remote-Email Remote-Groups
|
||||
}
|
||||
reverse_proxy whoami:80
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
http://{{ .Domains.Tinyauth }} {
|
||||
reverse_proxy tinyauth:3000
|
||||
}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,137 @@
|
||||
{{ define "envoy" }}
|
||||
envoy:
|
||||
image: envoyproxy/envoy:v1.33-latest
|
||||
pull_policy: missing
|
||||
ports:
|
||||
- {{ .Proxy.Port }}:80
|
||||
configs:
|
||||
- source: envoy_config
|
||||
target: /etc/envoy/envoy.yaml
|
||||
mode: 0664
|
||||
{{ end }}
|
||||
|
||||
{{ define "envoy_config" }}
|
||||
envoy_config:
|
||||
content: |
|
||||
static_resources:
|
||||
listeners:
|
||||
- name: http
|
||||
address:
|
||||
socket_address:
|
||||
address: 0.0.0.0
|
||||
port_value: 80
|
||||
|
||||
filter_chains:
|
||||
- filters:
|
||||
- name: envoy.filters.network.http_connection_manager
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
|
||||
stat_prefix: ingress_http
|
||||
use_remote_address: true
|
||||
|
||||
route_config:
|
||||
name: routes
|
||||
|
||||
virtual_hosts:
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
- name: whoami
|
||||
domains:
|
||||
- {{ .Domains.Whoami }}
|
||||
|
||||
request_headers_to_add:
|
||||
- header:
|
||||
key: x-real-ip
|
||||
value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
|
||||
append_action: OVERWRITE_IF_EXISTS_OR_ADD
|
||||
|
||||
routes:
|
||||
- match:
|
||||
prefix: /
|
||||
route:
|
||||
cluster: whoami
|
||||
{{ end }}
|
||||
|
||||
- name: tinyauth
|
||||
domains:
|
||||
- {{ .Domains.Tinyauth }}
|
||||
|
||||
typed_per_filter_config:
|
||||
envoy.filters.http.ext_authz:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
|
||||
disabled: true
|
||||
|
||||
routes:
|
||||
- match:
|
||||
prefix: /
|
||||
route:
|
||||
cluster: tinyauth
|
||||
|
||||
http_filters:
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
failure_mode_allow: false
|
||||
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: http://tinyauth:3000
|
||||
cluster: tinyauth
|
||||
timeout: 5s
|
||||
|
||||
path_prefix: "/api/auth/envoy?path="
|
||||
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- exact: cookie
|
||||
- exact: x-forwarded-for
|
||||
- exact: x-forwarded-proto
|
||||
- exact: x-real-ip
|
||||
- exact: user-agent
|
||||
|
||||
authorization_response:
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- exact: remote-user
|
||||
- exact: remote-name
|
||||
- exact: remote-email
|
||||
- exact: remote-groups
|
||||
- exact: remote-sub
|
||||
- exact: authorization
|
||||
|
||||
allowed_client_headers:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
- exact: content-type
|
||||
|
||||
- name: envoy.filters.http.router
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
|
||||
|
||||
clusters:
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
- name: whoami
|
||||
type: LOGICAL_DNS
|
||||
load_assignment:
|
||||
cluster_name: whoami
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: whoami
|
||||
port_value: 80
|
||||
{{ end }}
|
||||
|
||||
- name: tinyauth
|
||||
type: LOGICAL_DNS
|
||||
load_assignment:
|
||||
cluster_name: tinyauth
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: tinyauth
|
||||
port_value: 3000
|
||||
{{ end }}
|
||||
@@ -0,0 +1,79 @@
|
||||
{{ define "nginx" }}
|
||||
nginx:
|
||||
image: nginx:1.31.6
|
||||
pull_policy: missing
|
||||
ports:
|
||||
- {{ .Proxy.Port }}:80
|
||||
configs:
|
||||
- source: nginx_default
|
||||
target: /etc/nginx/conf.d/default.conf
|
||||
mode: 0664
|
||||
- source: nginx_tinyauth
|
||||
target: /etc/nginx/conf.d/tinyauth.conf
|
||||
mode: 0664
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
- source: nginx_whoami
|
||||
target: /etc/nginx/conf.d/whoami.conf
|
||||
mode: 0664
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "nginx_config" }}
|
||||
nginx_default:
|
||||
content: {}
|
||||
nginx_tinyauth:
|
||||
content: |
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ .Domains.Tinyauth }};
|
||||
|
||||
location / {
|
||||
proxy_pass http://tinyauth:3000;
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $http_host;
|
||||
}
|
||||
}
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
nginx_whoami:
|
||||
content: |
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ .Domains.Whoami }};
|
||||
|
||||
location / {
|
||||
proxy_pass http://whoami:80;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
|
||||
auth_request /tinyauth;
|
||||
auth_request_set $redirection_url $upstream_http_x_tinyauth_location;
|
||||
error_page 401 403 =302 $redirection_url;
|
||||
}
|
||||
|
||||
location = /tinyauth {
|
||||
internal;
|
||||
|
||||
proxy_pass http://tinyauth:3000/api/auth/nginx;
|
||||
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
|
||||
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
|
||||
proxy_set_header X-Original-Method $request_method;
|
||||
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $http_host;
|
||||
}
|
||||
}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,27 @@
|
||||
package proxies
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"html/template"
|
||||
)
|
||||
|
||||
// Bundle the templates
|
||||
|
||||
//go:embed caddy.yaml.tmpl
|
||||
var caddyTemplateSource string
|
||||
|
||||
//go:embed envoy.yaml.tmpl
|
||||
var envoyTemplateSource string
|
||||
|
||||
//go:embed nginx.yaml.tmpl
|
||||
var nginxTemplateSource string
|
||||
|
||||
//go:embed traefik.yaml.tmpl
|
||||
var traefikTemplateSource string
|
||||
|
||||
// Compile them and export them
|
||||
|
||||
var CaddyTemplate = template.Must(template.New("caddy").Parse(caddyTemplateSource))
|
||||
var EnvoyTemplate = template.Must(template.New("envoy").Parse(envoyTemplateSource))
|
||||
var NginxTemplate = template.Must(template.New("nginx").Parse(nginxTemplateSource))
|
||||
var TraefikTemplate = template.Must(template.New("traefik").Parse(traefikTemplateSource))
|
||||
@@ -0,0 +1,68 @@
|
||||
{{ define "traefik" }}
|
||||
traefik:
|
||||
image: traefik:v3.7.13
|
||||
pull_policy: missing
|
||||
ports:
|
||||
- {{ .Proxy.Port }}:80
|
||||
configs:
|
||||
- source: traefik_static
|
||||
target: /etc/traefik/traefik.yml
|
||||
mode: 0664
|
||||
- source: traefik_dynamic
|
||||
target: /etc/traefik/dynamic.yml
|
||||
mode: 0664
|
||||
{{ end }}
|
||||
|
||||
{{ define "traefik_config" }}
|
||||
traefik_static:
|
||||
content: |
|
||||
entryPoints:
|
||||
web:
|
||||
address: ":80"
|
||||
|
||||
providers:
|
||||
file:
|
||||
filename: /etc/traefik/dynamic.yml
|
||||
traefik_dynamic:
|
||||
content: |
|
||||
http:
|
||||
routers:
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
whoami:
|
||||
rule: Host(`{{ .Domains.Whoami }}`)
|
||||
entryPoints:
|
||||
- web
|
||||
service: whoami
|
||||
middlewares:
|
||||
- tinyauth
|
||||
{{ end }}
|
||||
|
||||
tinyauth:
|
||||
rule: Host(`{{ .Domains.Tinyauth }}`)
|
||||
entryPoints:
|
||||
- web
|
||||
service: tinyauth
|
||||
|
||||
middlewares:
|
||||
tinyauth:
|
||||
forwardAuth:
|
||||
address: http://tinyauth:3000/api/auth/traefik
|
||||
authResponseHeaders:
|
||||
- Remote-User
|
||||
- Remote-Name
|
||||
- Remote-Email
|
||||
- Remote-Groups
|
||||
|
||||
services:
|
||||
{{ if .Services.Whoami.Enabled }}
|
||||
whoami:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: http://whoami:80
|
||||
{{ end }}
|
||||
|
||||
tinyauth:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: http://tinyauth:3000
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user