mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-09-24 11:43:32 +08:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcc9125279 | ||
|
|
fb86f443a1 | ||
|
|
314758bf68 | ||
|
|
b29e1bddc5 | ||
|
|
f98c844f28 | ||
|
|
a62ef392e2 | ||
|
|
261d882af3 | ||
|
|
996316b524 | ||
|
|
90e898abbf | ||
|
|
34456b94b1 | ||
|
|
45e165f742 | ||
|
|
b43cf76d9b | ||
|
|
5a685c4a6b | ||
|
|
e1b1e722e7 | ||
|
|
3a216e95e2 | ||
|
|
2769725775 | ||
|
|
419da20681 |
@@ -33,6 +33,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
sqlc-version: "1.31.1"
|
sqlc-version: "1.31.1"
|
||||||
|
|
||||||
|
- name: Setup controller-gen
|
||||||
|
run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.22.0
|
||||||
|
|
||||||
- name: Check codegen is up to date
|
- name: Check codegen is up to date
|
||||||
run: |
|
run: |
|
||||||
sqlc generate
|
sqlc generate
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ PROD_COMPOSE := $(shell test -f "docker-compose.test.prod.yml" && echo "docker-c
|
|||||||
|
|
||||||
.DEFAULT_GOAL := binary
|
.DEFAULT_GOAL := binary
|
||||||
|
|
||||||
.PHONY: deps clean-data clean-webui webui binary binary-linux-amd64 binary-linux-arm64 test vet test-race dev dev-infisical prod prod-infisical sql generate docker docker-distroless
|
.PHONY: deps clean-data clean-webui webui binary binary-linux-amd64 binary-linux-arm64 test vet test-race dev dev-infisical prod prod-infisical sql generate docker docker-distroless tools
|
||||||
|
|
||||||
|
# Tools
|
||||||
|
tools:
|
||||||
|
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.22.0
|
||||||
|
go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1
|
||||||
|
|
||||||
# Deps
|
# Deps
|
||||||
deps:
|
deps:
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ require (
|
|||||||
github.com/go-jose/go-jose/v4 v4.1.5
|
github.com/go-jose/go-jose/v4 v4.1.5
|
||||||
github.com/go-ldap/ldap/v3 v3.4.14
|
github.com/go-ldap/ldap/v3 v3.4.14
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||||
github.com/golang-migrate/migrate/v4 v4.20.1
|
github.com/golang-migrate/migrate/v4 v4.19.1
|
||||||
github.com/google/go-querystring v1.2.0
|
github.com/google/go-querystring v1.2.0
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/jackc/pgx/v5 v5.11.0
|
github.com/jackc/pgx/v5 v5.10.0
|
||||||
github.com/mdp/qrterminal/v3 v3.2.1
|
github.com/mdp/qrterminal/v3 v3.2.1
|
||||||
github.com/pquerna/otp v1.5.0
|
github.com/pquerna/otp v1.5.0
|
||||||
github.com/rs/zerolog v1.35.1
|
github.com/rs/zerolog v1.35.1
|
||||||
@@ -23,14 +23,15 @@ require (
|
|||||||
github.com/tinyauthapp/paerser v0.0.0-20260410140347-85c3740d6298
|
github.com/tinyauthapp/paerser v0.0.0-20260410140347-85c3740d6298
|
||||||
github.com/weppos/publicsuffix-go v0.50.3
|
github.com/weppos/publicsuffix-go v0.50.3
|
||||||
go.uber.org/dig v1.19.0
|
go.uber.org/dig v1.19.0
|
||||||
golang.org/x/crypto v0.57.0
|
golang.org/x/crypto v0.56.0
|
||||||
golang.org/x/net v0.59.0
|
golang.org/x/net v0.58.0
|
||||||
golang.org/x/oauth2 v0.37.0
|
golang.org/x/oauth2 v0.36.0
|
||||||
golang.org/x/tools v0.50.0
|
golang.org/x/tools v0.49.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
k8s.io/api v0.37.0
|
||||||
k8s.io/apimachinery v0.37.0
|
k8s.io/apimachinery v0.37.0
|
||||||
k8s.io/client-go v0.37.0
|
k8s.io/client-go v0.37.0
|
||||||
modernc.org/sqlite v1.59.0
|
modernc.org/sqlite v1.58.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -66,21 +67,37 @@ require (
|
|||||||
github.com/containerd/log v0.1.0 // indirect
|
github.com/containerd/log v0.1.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/distribution/reference v0.6.0 // indirect
|
github.com/distribution/reference v0.6.0 // indirect
|
||||||
github.com/docker/go-connections v0.7.0 // indirect
|
github.com/docker/go-connections v0.6.0 // indirect
|
||||||
github.com/docker/go-units v0.5.0 // indirect
|
github.com/docker/go-units v0.5.0 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/felixge/httpsnoop v1.1.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
|
||||||
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.9.1 // indirect
|
github.com/fxamacker/cbor/v2 v2.9.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
||||||
github.com/go-logr/logr v1.4.4 // indirect
|
github.com/go-logr/logr v1.4.4 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
|
github.com/go-openapi/jsonpointer v1.0.0 // indirect
|
||||||
|
github.com/go-openapi/jsonreference v1.0.0 // indirect
|
||||||
|
github.com/go-openapi/swag v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/cmdutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/conv v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/fileutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/jsonutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/loading v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/mangling v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/netutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/pools v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/stringutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/typeutils v0.27.1 // indirect
|
||||||
|
github.com/go-openapi/swag/yamlutils v0.27.1 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||||
|
github.com/google/gnostic-models v0.7.1 // indirect
|
||||||
github.com/huandu/xstrings v1.5.0 // indirect
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect
|
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
@@ -99,6 +116,7 @@ require (
|
|||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||||
github.com/moby/sys/atomicwriter v0.1.0 // indirect
|
github.com/moby/sys/atomicwriter v0.1.0 // indirect
|
||||||
|
github.com/moby/term v0.5.2 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
|
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
@@ -121,7 +139,7 @@ require (
|
|||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.45.0 // indirect
|
go.opentelemetry.io/otel v1.45.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.45.0 // indirect
|
go.opentelemetry.io/otel/metric v1.45.0 // indirect
|
||||||
@@ -132,19 +150,20 @@ require (
|
|||||||
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
||||||
golang.org/x/arch v0.22.0 // indirect
|
golang.org/x/arch v0.22.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
|
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
|
||||||
golang.org/x/mod v0.41.0 // indirect
|
golang.org/x/mod v0.39.0 // indirect
|
||||||
golang.org/x/sync v0.23.0 // indirect
|
golang.org/x/sync v0.22.0 // indirect
|
||||||
golang.org/x/sys v0.48.0 // indirect
|
golang.org/x/sys v0.47.0 // indirect
|
||||||
golang.org/x/term v0.46.0 // indirect
|
golang.org/x/term v0.45.0 // indirect
|
||||||
golang.org/x/text v0.42.0 // indirect
|
golang.org/x/text v0.41.0 // indirect
|
||||||
golang.org/x/time v0.15.0 // indirect
|
golang.org/x/time v0.15.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
|
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
|
||||||
|
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gotest.tools/v3 v3.5.2 // indirect
|
gotest.tools/v3 v3.5.2 // indirect
|
||||||
k8s.io/klog/v2 v2.140.0 // indirect
|
k8s.io/klog/v2 v2.140.0 // indirect
|
||||||
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad // indirect
|
k8s.io/kube-openapi v0.0.0-20260721132016-d427ff9ee9ad // indirect
|
||||||
k8s.io/utils v0.0.0-20260626114624-be93311217bd // indirect
|
k8s.io/utils v0.0.0-20260626114624-be93311217bd // indirect
|
||||||
modernc.org/libc v1.75.7 // indirect
|
modernc.org/libc v1.75.6 // indirect
|
||||||
modernc.org/mathutil v1.7.1 // indirect
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
modernc.org/memory v1.12.1 // indirect
|
modernc.org/memory v1.12.1 // indirect
|
||||||
rsc.io/qr v0.2.0 // indirect
|
rsc.io/qr v0.2.0 // indirect
|
||||||
|
|||||||
@@ -93,16 +93,16 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
|
|||||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||||
github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM=
|
github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM=
|
||||||
github.com/docker/docker v28.5.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v28.5.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
github.com/docker/go-connections v0.7.0 h1:6SsRfJddP22WMrCkj19x9WKjEDTB+ahsdiGYf0mN39c=
|
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
|
||||||
github.com/docker/go-connections v0.7.0/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q=
|
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
|
||||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
|
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
|
||||||
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||||
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ=
|
github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ=
|
||||||
@@ -138,6 +138,8 @@ github.com/go-openapi/swag/fileutils v0.27.1 h1:QQqBSoi5mW4XpU85nS0mLcA+zAE6vLzr
|
|||||||
github.com/go-openapi/swag/fileutils v0.27.1/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8=
|
github.com/go-openapi/swag/fileutils v0.27.1/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8=
|
||||||
github.com/go-openapi/swag/jsonutils v0.27.1 h1:SVgK3i4USzCU5mibOOS/l4ea2h9UQXy7J7RNLTjuXjU=
|
github.com/go-openapi/swag/jsonutils v0.27.1 h1:SVgK3i4USzCU5mibOOS/l4ea2h9UQXy7J7RNLTjuXjU=
|
||||||
github.com/go-openapi/swag/jsonutils v0.27.1/go.mod h1:tdlEpZqdcQ17uj6J4YdK9vd8It5qWMwjWXOs0tjpRlk=
|
github.com/go-openapi/swag/jsonutils v0.27.1/go.mod h1:tdlEpZqdcQ17uj6J4YdK9vd8It5qWMwjWXOs0tjpRlk=
|
||||||
|
github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.1 h1:mJu3COL9WEaZVp/Kf2PRMi7tPszPEJfSr/OO75ynCs8=
|
||||||
|
github.com/go-openapi/swag/jsonutils/fixtures_test v0.27.1/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY=
|
||||||
github.com/go-openapi/swag/loading v0.27.1 h1:/DxUgDXKbBX4bcn7r9uEXfJyzN5XpiJmZplzQTjrRCY=
|
github.com/go-openapi/swag/loading v0.27.1 h1:/DxUgDXKbBX4bcn7r9uEXfJyzN5XpiJmZplzQTjrRCY=
|
||||||
github.com/go-openapi/swag/loading v0.27.1/go.mod h1:jvGh3iA2+zyUUycB5fgJWzeHnhrpvGnJJM0RVE9ZShE=
|
github.com/go-openapi/swag/loading v0.27.1/go.mod h1:jvGh3iA2+zyUUycB5fgJWzeHnhrpvGnJJM0RVE9ZShE=
|
||||||
github.com/go-openapi/swag/mangling v0.27.1 h1:yC9D0HyUE8gbP+BfmGx9+AA89ikwZTMjESK3OnnoaqA=
|
github.com/go-openapi/swag/mangling v0.27.1 h1:yC9D0HyUE8gbP+BfmGx9+AA89ikwZTMjESK3OnnoaqA=
|
||||||
@@ -152,6 +154,10 @@ github.com/go-openapi/swag/typeutils v0.27.1 h1:KSTdFlfnse4r6dP9IrEnwMldjE+zs71U
|
|||||||
github.com/go-openapi/swag/typeutils v0.27.1/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ=
|
github.com/go-openapi/swag/typeutils v0.27.1/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ=
|
||||||
github.com/go-openapi/swag/yamlutils v0.27.1 h1:ftxv6xvXb1E3zohUc+okZ9nSqNb9StQX/FXnKZ98sQA=
|
github.com/go-openapi/swag/yamlutils v0.27.1 h1:ftxv6xvXb1E3zohUc+okZ9nSqNb9StQX/FXnKZ98sQA=
|
||||||
github.com/go-openapi/swag/yamlutils v0.27.1/go.mod h1:bnxFIB1qewGRiZHypXGZ3fNgf13/0HfRgnS/iZBDrOo=
|
github.com/go-openapi/swag/yamlutils v0.27.1/go.mod h1:bnxFIB1qewGRiZHypXGZ3fNgf13/0HfRgnS/iZBDrOo=
|
||||||
|
github.com/go-openapi/testify/enable/yaml/v2 v2.6.0 h1:gGHwAJ0R/5jU8BEGDbfRNR3hL68dAVi84WuOApp29B0=
|
||||||
|
github.com/go-openapi/testify/enable/yaml/v2 v2.6.0/go.mod h1:tY+St1SGq4NFl0QIqdTY4aEdbChAHxhyB77XQi9iJCo=
|
||||||
|
github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug=
|
||||||
|
github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
@@ -166,10 +172,10 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
|||||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
|
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/golang-migrate/migrate/v4 v4.20.1 h1:2N/ToVTKrKl58ynBpgeVJ4In7VcLCjWTZtm4eP1LxhU=
|
github.com/golang-migrate/migrate/v4 v4.19.1 h1:OCyb44lFuQfYXYLx1SCxPZQGU7mcaZ7gH9yH4jSFbBA=
|
||||||
github.com/golang-migrate/migrate/v4 v4.20.1/go.mod h1:DDPgKVb4ovSWc4FwSPfV2Uz1160f4XBiTHTrAJtljmM=
|
github.com/golang-migrate/migrate/v4 v4.19.1/go.mod h1:CTcgfjxhaUtsLipnLoQRWCrjYXycRz/g5+RWDuYgPrE=
|
||||||
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
|
github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c=
|
||||||
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
|
github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
@@ -194,8 +200,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
|||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.11.0 h1:IzBBtyK9AHqf98cctWFifYSci2hgQR/cd56wB4p+ogg=
|
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
|
||||||
github.com/jackc/pgx/v5 v5.11.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
|
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
|
||||||
@@ -242,10 +248,6 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
|
|||||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||||
github.com/moby/moby/api v1.54.2 h1:wiat9QAhnDQjA7wk1kh/TqHz2I1uUA7M7t9SAl/JNXg=
|
|
||||||
github.com/moby/moby/api v1.54.2/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
|
|
||||||
github.com/moby/moby/client v0.4.1 h1:DMQgisVoMkmMs7fp3ROSdiBnoAu8+vo3GggFl06M/wY=
|
|
||||||
github.com/moby/moby/client v0.4.1/go.mod h1:z52C9O2POPOsnxZAy//WtKcQ32P+jT/NGeXu/7nfjGQ=
|
|
||||||
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
|
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
|
||||||
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
|
github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs=
|
||||||
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
|
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
|
||||||
@@ -331,8 +333,8 @@ go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF
|
|||||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 h1:ssfIgGNANqpVFCndZvcuyKbl0g+UAVcbBcqGkG28H0Y=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0/go.mod h1:GQ/474YrbE4Jx8gZ4q5I4hrhUzM6UPzyrqJYV2AqPoQ=
|
||||||
go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU=
|
go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU=
|
||||||
go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ=
|
go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=
|
||||||
@@ -359,35 +361,35 @@ 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=
|
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 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y=
|
||||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
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 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
|
||||||
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
|
||||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
|
||||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
|
||||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||||
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
|
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||||
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
|
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
||||||
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
|
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
||||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
|
||||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
|
||||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||||
golang.org/x/tools v0.50.0 h1:c2ifzfcuY7L90lZ2aKd8S4K2NpASF08SZx9ZuJkHmSU=
|
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
|
||||||
golang.org/x/tools v0.50.0/go.mod h1:7ulVMw3831Mwi5EZD6RomGyffr4VFjuNYXf2BbCEAV0=
|
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
|
||||||
google.golang.org/genproto v0.0.0-20260630182238-925bb5da69e7 h1:lQG76ePMKmtujel4VIVMiFoHVWVNtJdawbCZJtWlVXU=
|
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7 h1:jQ9p21COKWjP3VwuFrNRiiOTMh3mPpN45R7SLrH/HUU=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7/go.mod h1:KqHwBx2upmfa1XSi1WuRvC+2VGCLtooKkfmyvRbUmqA=
|
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7 h1:eM/YSd5bBFagF51o1E745Ta7RwzpW0h+z+QDNZOgmQ8=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||||
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
|
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
|
||||||
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
|
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
|
||||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI=
|
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI=
|
||||||
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -426,8 +428,8 @@ 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/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 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||||
modernc.org/libc v1.75.7 h1:o3DTP9/0p9pKmY2WCKQaySW6wIiZhNM7wc2lUoyhfew=
|
modernc.org/libc v1.75.6 h1:yKk8qo+Di4gkmvRboK8ocCqH22FiUCR6jRy2OwtCRus=
|
||||||
modernc.org/libc v1.75.7/go.mod h1:bO5o2ztHxBb2rjz0PgdHN0sSMw57CgxGFLZ3Qd/QpVQ=
|
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 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||||
@@ -436,8 +438,8 @@ modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
|||||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
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 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||||
modernc.org/sqlite v1.59.0 h1:X1es1GpqBlS/5T+vbM4HLUdaa8OtQx468DF2vrx+38A=
|
modernc.org/sqlite v1.58.0 h1:38u40/bwkfM7f0Myhosl+SEMltSDxnGdQf8o6Kjmys0=
|
||||||
modernc.org/sqlite v1.59.0/go.mod h1:+paeT2A3iPRHkQDwG7oA6Tk0zQd5woMEI8q7orfry8k=
|
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 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func NewAccessControlsService(i AccessControlServiceInput) *AccessControlsServic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (service *AccessControlsService) ensureAscii(str string) bool {
|
func ensureAscii(str string) bool {
|
||||||
for i := 0; i < len(str); i++ {
|
for i := 0; i < len(str); i++ {
|
||||||
if str[i] > unicode.MaxASCII {
|
if str[i] > unicode.MaxASCII {
|
||||||
return false
|
return false
|
||||||
@@ -51,7 +51,7 @@ func (service *AccessControlsService) ensureAscii(str string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (service *AccessControlsService) normalizeDomain(domain string) string {
|
func normalizeDomain(domain string) string {
|
||||||
if host, _, err := net.SplitHostPort(domain); err == nil {
|
if host, _, err := net.SplitHostPort(domain); err == nil {
|
||||||
domain = host
|
domain = host
|
||||||
}
|
}
|
||||||
@@ -60,11 +60,11 @@ func (service *AccessControlsService) normalizeDomain(domain string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (service *AccessControlsService) getACLs(domain string, lookup func(locator func(name string, app *model.App) bool) error) (*model.App, error) {
|
func (service *AccessControlsService) getACLs(domain string, lookup func(locator func(name string, app *model.App) bool) error) (*model.App, error) {
|
||||||
if !service.ensureAscii(domain) {
|
if !ensureAscii(domain) {
|
||||||
return nil, errors.New("domain contains non-ascii characters")
|
return nil, errors.New("domain contains non-ascii characters")
|
||||||
}
|
}
|
||||||
|
|
||||||
normalizedDomain := service.normalizeDomain(domain)
|
normalizedDomain := normalizeDomain(domain)
|
||||||
|
|
||||||
if !strings.HasSuffix(normalizedDomain, "."+service.runtime.CookieDomain) && normalizedDomain != service.runtime.CookieDomain {
|
if !strings.HasSuffix(normalizedDomain, "."+service.runtime.CookieDomain) && normalizedDomain != service.runtime.CookieDomain {
|
||||||
return nil, fmt.Errorf("domain does not match cookie domain, expected %s (or a subdomain), got %s", service.runtime.CookieDomain, domain)
|
return nil, fmt.Errorf("domain does not match cookie domain, expected %s (or a subdomain), got %s", service.runtime.CookieDomain, domain)
|
||||||
@@ -76,11 +76,11 @@ func (service *AccessControlsService) getACLs(domain string, lookup func(locator
|
|||||||
|
|
||||||
locatorFunc := func(name string, app *model.App) bool {
|
locatorFunc := func(name string, app *model.App) bool {
|
||||||
if app.Config.Domain != "" {
|
if app.Config.Domain != "" {
|
||||||
if !service.ensureAscii(app.Config.Domain) {
|
if !ensureAscii(app.Config.Domain) {
|
||||||
service.log.App.Warn().Str("name", name).Str("domain", app.Config.Domain).Msg("Domain contains non-ascii characters, skipping")
|
service.log.App.Warn().Str("name", name).Str("domain", app.Config.Domain).Msg("Domain contains non-ascii characters, skipping")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if normalizedDomain == service.normalizeDomain(app.Config.Domain) {
|
if normalizedDomain == normalizeDomain(app.Config.Domain) {
|
||||||
service.log.App.Debug().Str("name", name).Msg("Found matching container by domain")
|
service.log.App.Debug().Str("name", name).Msg("Found matching container by domain")
|
||||||
domainMatch = app
|
domainMatch = app
|
||||||
return true
|
return true
|
||||||
@@ -145,7 +145,9 @@ func (service *AccessControlsService) GetAccessControls(domain string) (*model.A
|
|||||||
|
|
||||||
// If we have a label provider configured, try to get ACLs from it
|
// If we have a label provider configured, try to get ACLs from it
|
||||||
if service.labelProvider != nil {
|
if service.labelProvider != nil {
|
||||||
return service.getACLs(domain, service.labelProvider.Lookup)
|
return service.getACLs(domain, func(locator func(name string, app *model.App) bool) error {
|
||||||
|
return service.labelProvider.Lookup(locator)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// No labels
|
// No labels
|
||||||
|
|||||||
@@ -186,9 +186,10 @@ func TestAccessControlsService(t *testing.T) {
|
|||||||
// get acls should return an error when the provider fails
|
// get acls should return an error when the provider fails
|
||||||
mock := newMockProvider(map[string]model.App{}, true)
|
mock := newMockProvider(map[string]model.App{}, true)
|
||||||
acls := NewAccessControlsService(AccessControlServiceInput{
|
acls := NewAccessControlsService(AccessControlServiceInput{
|
||||||
Log: log,
|
Log: log,
|
||||||
Runtime: &runtime,
|
Runtime: &runtime,
|
||||||
Config: &model.Config{},
|
Config: &model.Config{},
|
||||||
|
LabelProvider: mock,
|
||||||
})
|
})
|
||||||
_, err := acls.getACLs("example.com", mock.Lookup)
|
_, err := acls.getACLs("example.com", mock.Lookup)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
||||||
|
"github.com/tinyauthapp/tinyauth/pkg/apis/tinyauth/v1alpha1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
)
|
||||||
|
|
||||||
|
type KubernetesCRDInput struct {
|
||||||
|
Log *logger.Logger
|
||||||
|
Client kubernetes.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
type KubernetesCRDExtractor struct {
|
||||||
|
log *logger.Logger
|
||||||
|
client kubernetes.Interface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewKubernetesCRDExtractor(i KubernetesCRDInput) *KubernetesCRDExtractor {
|
||||||
|
return &KubernetesCRDExtractor{
|
||||||
|
log: i.Log,
|
||||||
|
client: i.Client,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *KubernetesCRDExtractor) Extract(app *v1alpha1.Application) ExtractionResult {
|
||||||
|
meta := &ResourceMeta{
|
||||||
|
Typ: ResourceTypeCRD,
|
||||||
|
Name: app.GetName(),
|
||||||
|
Namespace: app.GetNamespace(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ensureResourceMeta(meta) {
|
||||||
|
k.log.App.Warn().Str("namespace", meta.Namespace).Str("name", meta.Name).Msg("Resource has no namespace or name, skipping")
|
||||||
|
return ExtractionResult{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if app.Spec.Config.Domain == "" {
|
||||||
|
k.log.App.Warn().Str("name", meta.Name).Str("namespace", meta.Namespace).Msg("Application has no domain, skipping")
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
Apps: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ensureAscii(app.Spec.Config.Domain) {
|
||||||
|
k.log.App.Warn().Str("name", meta.Name).Str("namespace", meta.Namespace).Str("domain", app.Spec.Config.Domain).Msg("Domain is invalid, skipping")
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
Apps: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the CRD to the internal representation.
|
||||||
|
internalApp := app.Spec.ToInternalApp()
|
||||||
|
passwordRef := app.Spec.Response.BasicAuth.PasswordSecretRef
|
||||||
|
if passwordRef != nil {
|
||||||
|
secret, err := k.client.CoreV1().Secrets(meta.Namespace).Get(context.Background(), passwordRef.Name, metav1.GetOptions{})
|
||||||
|
if err != nil {
|
||||||
|
k.log.App.Warn().Err(err).Str("namespace", meta.Namespace).Str("name", meta.Name).Str("secret", passwordRef.Name).Str("key", passwordRef.Key).Msg("Failed to read basic auth password Secret, skipping")
|
||||||
|
return ExtractionResult{Meta: meta}
|
||||||
|
}
|
||||||
|
|
||||||
|
password, ok := secret.Data[passwordRef.Key]
|
||||||
|
if !ok {
|
||||||
|
k.log.App.Warn().Str("namespace", meta.Namespace).Str("name", meta.Name).Str("secret", passwordRef.Name).Str("key", passwordRef.Key).Msg("Basic auth password Secret key does not exist, skipping")
|
||||||
|
return ExtractionResult{Meta: meta}
|
||||||
|
}
|
||||||
|
|
||||||
|
internalApp.Response.BasicAuth.Password = string(password)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
Apps: map[string]model.App{
|
||||||
|
meta.Name: internalApp,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/utils/decoders"
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
||||||
|
networking "k8s.io/api/networking/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
func hostMatchesHostname(host string, hostname string) bool {
|
||||||
|
host = normalizeDomain(host)
|
||||||
|
hostname = normalizeDomain(hostname)
|
||||||
|
if suffix, ok := strings.CutPrefix(host, "*."); ok {
|
||||||
|
return strings.HasSuffix(hostname, "."+suffix)
|
||||||
|
}
|
||||||
|
return host == hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
func hostCoversName(host string, name string) bool {
|
||||||
|
host = strings.ToLower(host)
|
||||||
|
if strings.HasPrefix(host, "*.") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return strings.HasPrefix(host, strings.ToLower(name+"."))
|
||||||
|
}
|
||||||
|
|
||||||
|
type KubernetesIngressExtractor struct {
|
||||||
|
log *logger.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
type KubernetesIngressExtractorInput struct {
|
||||||
|
Log *logger.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewKubernetesIngressExtractor(i KubernetesIngressExtractorInput) *KubernetesIngressExtractor {
|
||||||
|
return &KubernetesIngressExtractor{
|
||||||
|
log: i.Log,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *KubernetesIngressExtractor) getPaths(rule networking.IngressRule) []string {
|
||||||
|
var paths []string
|
||||||
|
|
||||||
|
if rule.HTTP == nil {
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range rule.HTTP.Paths {
|
||||||
|
paths = append(paths, path.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *KubernetesIngressExtractor) getHosts(rules []networking.IngressRule) []string {
|
||||||
|
var hosts []string
|
||||||
|
|
||||||
|
for _, rule := range rules {
|
||||||
|
hosts = append(hosts, rule.Host)
|
||||||
|
paths := k.getPaths(rule)
|
||||||
|
|
||||||
|
if len(paths) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if !slices.Contains(paths, "/") {
|
||||||
|
k.log.App.Warn().Strs("hosts", hosts).Strs("paths", paths).Msg("Ingress rule does not contain a catch-all path, another ingress may be able to bypass auth checks if it routes the same host with a different path. Consider adding a catch-all path to this rule to ensure auth checks are applied to all paths for this host.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hosts
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *KubernetesIngressExtractor) Extract(ingress *networking.Ingress) ExtractionResult {
|
||||||
|
meta := &ResourceMeta{
|
||||||
|
Typ: ResourceTypeIngress,
|
||||||
|
Name: ingress.GetName(),
|
||||||
|
Namespace: ingress.GetNamespace(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ensureResourceMeta(meta) {
|
||||||
|
k.log.App.Warn().Str("namespace", meta.Namespace).Str("name", meta.Name).Msg("Resource has no namespace or name, skipping")
|
||||||
|
return ExtractionResult{}
|
||||||
|
}
|
||||||
|
|
||||||
|
annotations := ingress.GetAnnotations()
|
||||||
|
hosts := k.getHosts(ingress.Spec.Rules)
|
||||||
|
|
||||||
|
if len(hosts) == 0 {
|
||||||
|
k.log.App.Warn().Str("namespace", meta.Namespace).Str("name", meta.Name).Msg("No hosts found in resource, skipping")
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labels, err := decoders.DecodeLabels[model.Apps](annotations, "apps")
|
||||||
|
if err != nil {
|
||||||
|
k.log.App.Warn().Err(err).Str("namespace", meta.Namespace).Str("name", meta.Name).Msg("Failed to decode resource labels, skipping")
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apps := make(map[string]model.App)
|
||||||
|
|
||||||
|
for name, config := range labels.Apps {
|
||||||
|
if config.Config.Domain != "" {
|
||||||
|
if !ensureAscii(config.Config.Domain) {
|
||||||
|
k.log.App.Warn().Err(err).Str("namespace", meta.Namespace).Str("name", meta.Name).Str("domain", config.Config.Domain).Msg("Domain is invalid, matching will rely on app name")
|
||||||
|
} else {
|
||||||
|
if slices.ContainsFunc(hosts, func(host string) bool {
|
||||||
|
return hostMatchesHostname(host, config.Config.Domain)
|
||||||
|
}) {
|
||||||
|
apps[name] = config
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if slices.ContainsFunc(hosts, func(host string) bool {
|
||||||
|
return hostCoversName(host, name)
|
||||||
|
}) {
|
||||||
|
apps[name] = config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ExtractionResult{
|
||||||
|
Meta: meta,
|
||||||
|
Apps: apps,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,43 +3,123 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/steveiliop56/ding"
|
"github.com/steveiliop56/ding"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/model"
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/utils/decoders"
|
|
||||||
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
||||||
"github.com/tinyauthapp/tinyauth/pkg/validators"
|
"github.com/tinyauthapp/tinyauth/pkg/apis/tinyauth/v1alpha1"
|
||||||
"go.uber.org/dig"
|
"go.uber.org/dig"
|
||||||
|
networking "k8s.io/api/networking/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ingressEntry struct {
|
type watchedResource struct {
|
||||||
name string
|
gvr schema.GroupVersionResource
|
||||||
app model.App
|
typ ResourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
type ingressKey struct {
|
func (w watchedResource) pretty() string {
|
||||||
namespace string
|
return w.gvr.Group + "/" + w.gvr.Version + "/" + w.gvr.Resource
|
||||||
name string
|
}
|
||||||
|
|
||||||
|
func ensureResourceMeta(meta *ResourceMeta) bool {
|
||||||
|
return meta.Name != "" && meta.Namespace != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceMeta struct {
|
||||||
|
Typ ResourceType
|
||||||
|
Name string
|
||||||
|
Namespace string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExtractionResult struct {
|
||||||
|
Meta *ResourceMeta
|
||||||
|
Apps map[string]model.App
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ResourceTypeIngress ResourceType = "ingress"
|
||||||
|
ResourceTypeCRD ResourceType = "crd"
|
||||||
|
)
|
||||||
|
|
||||||
|
var supportedResources = []watchedResource{
|
||||||
|
{
|
||||||
|
gvr: schema.GroupVersionResource{
|
||||||
|
Group: "networking.k8s.io",
|
||||||
|
Version: "v1",
|
||||||
|
Resource: "ingresses",
|
||||||
|
},
|
||||||
|
typ: ResourceTypeIngress,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gvr: schema.GroupVersionResource{
|
||||||
|
Group: "tinyauth.app",
|
||||||
|
Version: "v1alpha1",
|
||||||
|
Resource: "applications",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type typedItem struct {
|
||||||
|
typ ResourceType
|
||||||
|
ingress *networking.Ingress
|
||||||
|
crd *v1alpha1.Application
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertFromUnstructured[T any](obj *unstructured.Unstructured) (*T, error) {
|
||||||
|
var typed *T
|
||||||
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &typed)
|
||||||
|
if err != nil {
|
||||||
|
var zero *T
|
||||||
|
return zero, fmt.Errorf("failed to convert ingress to typed object: %w", err)
|
||||||
|
}
|
||||||
|
return typed, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ti *typedItem) fromUnstructured(typ ResourceType, obj *unstructured.Unstructured) (*typedItem, error) {
|
||||||
|
switch typ {
|
||||||
|
case ResourceTypeIngress:
|
||||||
|
typed, err := convertFromUnstructured[networking.Ingress](obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &typedItem{
|
||||||
|
typ: ResourceTypeIngress,
|
||||||
|
ingress: typed,
|
||||||
|
}, nil
|
||||||
|
case ResourceTypeCRD:
|
||||||
|
typed, err := convertFromUnstructured[v1alpha1.Application](obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &typedItem{
|
||||||
|
typ: ResourceTypeCRD,
|
||||||
|
crd: typed,
|
||||||
|
}, nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown resource type %s", typ)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type KubernetesService struct {
|
type KubernetesService struct {
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
|
|
||||||
client dynamic.Interface
|
apps map[ResourceMeta]map[string]model.App
|
||||||
connected bool
|
client dynamic.Interface
|
||||||
mu sync.RWMutex
|
typedClient kubernetes.Interface
|
||||||
ingressEntries map[ingressKey][]ingressEntry
|
mu sync.RWMutex
|
||||||
|
connected bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type KubernetesServiceInput struct {
|
type KubernetesServiceInput struct {
|
||||||
@@ -60,33 +140,43 @@ func NewKubernetesService(i KubernetesServiceInput) (*KubernetesService, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create kubernetes client: %w", err)
|
return nil, fmt.Errorf("failed to create kubernetes client: %w", err)
|
||||||
}
|
}
|
||||||
|
typedClient, err := kubernetes.NewForConfig(cfg)
|
||||||
gvr := schema.GroupVersionResource{
|
|
||||||
Group: "networking.k8s.io",
|
|
||||||
Version: "v1",
|
|
||||||
Resource: "ingresses",
|
|
||||||
}
|
|
||||||
|
|
||||||
accessCtx, accessCancel := context.WithTimeout(i.Ctx, 5*time.Second)
|
|
||||||
defer accessCancel()
|
|
||||||
|
|
||||||
_, err = client.Resource(gvr).List(accessCtx, metav1.ListOptions{Limit: 1})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.Log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Failed to access Ingress API, Kubernetes label provider will be disabled")
|
return nil, fmt.Errorf("failed to create typed kubernetes client: %w", err)
|
||||||
return nil, fmt.Errorf("failed to access ingress api: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Log.App.Debug().Str("api", gvr.GroupVersion().String()).Msg("Successfully accessed Ingress API, starting watcher")
|
|
||||||
|
|
||||||
service := &KubernetesService{
|
service := &KubernetesService{
|
||||||
log: i.Log,
|
log: i.Log,
|
||||||
client: client,
|
client: client,
|
||||||
ingressEntries: make(map[ingressKey][]ingressEntry),
|
typedClient: typedClient,
|
||||||
|
apps: make(map[ResourceMeta]map[string]model.App),
|
||||||
}
|
}
|
||||||
|
|
||||||
i.Ding.Go(func(ctx context.Context) {
|
watchedGVRs := make(map[string]bool)
|
||||||
service.watchGVR(gvr, ctx)
|
|
||||||
}, ding.RingMajor)
|
for _, res := range supportedResources {
|
||||||
|
ctx, cancel := context.WithTimeout(i.Ctx, 5*time.Second)
|
||||||
|
_, err := client.Resource(res.gvr).List(ctx, metav1.ListOptions{Limit: 1})
|
||||||
|
cancel()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
// The CRD may not be available yet, so we'll fall back to ingress
|
||||||
|
i.Log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Failed to access resource, skipping watcher")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
i.Log.App.Debug().Str("res", res.pretty()).Msg("Successfully accessed resource, starting watcher")
|
||||||
|
|
||||||
|
i.Ding.Go(func(ctx context.Context) {
|
||||||
|
service.watchGVR(res, ctx)
|
||||||
|
}, ding.RingMajor)
|
||||||
|
|
||||||
|
watchedGVRs[res.gvr.Resource] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(watchedGVRs) == 0 {
|
||||||
|
return nil, fmt.Errorf("failed to access any supported kubernetes api (ingresses, httproutes, grpcroutes)")
|
||||||
|
}
|
||||||
|
|
||||||
service.connected = true
|
service.connected = true
|
||||||
i.Log.App.Debug().Msg("Kubernetes label provider started successfully")
|
i.Log.App.Debug().Msg("Kubernetes label provider started successfully")
|
||||||
@@ -94,182 +184,101 @@ func NewKubernetesService(i KubernetesServiceInput) (*KubernetesService, error)
|
|||||||
return service, nil
|
return service, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) addIngressEntries(key ingressKey, entries []ingressEntry) {
|
func (k *KubernetesService) addResource(result ExtractionResult) {
|
||||||
k.mu.Lock()
|
k.mu.Lock()
|
||||||
defer k.mu.Unlock()
|
defer k.mu.Unlock()
|
||||||
k.ingressEntries[key] = entries
|
k.apps[*result.Meta] = result.Apps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) removeIngress(key ingressKey) {
|
func (k *KubernetesService) removeResource(meta ResourceMeta) {
|
||||||
k.mu.Lock()
|
k.mu.Lock()
|
||||||
defer k.mu.Unlock()
|
defer k.mu.Unlock()
|
||||||
delete(k.ingressEntries, key)
|
delete(k.apps, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) getEntry(locator func(name string, app *model.App) bool) {
|
func (k *KubernetesService) getEntry(locator func(name string, app *model.App) bool) {
|
||||||
k.mu.RLock()
|
k.mu.RLock()
|
||||||
defer k.mu.RUnlock()
|
defer k.mu.RUnlock()
|
||||||
|
|
||||||
// O(n^2) is not great but the number of ingress entries is expected to be small
|
for _, apps := range k.apps {
|
||||||
for _, entries := range k.ingressEntries {
|
for name, app := range apps {
|
||||||
for _, entry := range entries {
|
if ok := locator(name, &app); ok {
|
||||||
if ok := locator(entry.name, &entry.app); ok {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) extractPaths(rule map[string]any) ([]string, error) {
|
func (k *KubernetesService) watchedItemChange(res watchedResource, typedItem *typedItem, event watch.EventType) {
|
||||||
http, found, err := unstructured.NestedMap(rule, "http")
|
if typedItem == nil {
|
||||||
if err != nil {
|
k.log.App.Warn().Str("res", res.pretty()).Msg("Resource is nil, skipping")
|
||||||
return nil, fmt.Errorf("reading http from rule: %w", err)
|
return
|
||||||
}
|
}
|
||||||
if !found {
|
|
||||||
return nil, nil
|
var result ExtractionResult
|
||||||
}
|
|
||||||
paths, found, err := unstructured.NestedSlice(http, "paths")
|
switch typedItem.typ {
|
||||||
if err != nil {
|
case ResourceTypeIngress:
|
||||||
return nil, fmt.Errorf("reading http.paths: %w", err)
|
if typedItem.ingress == nil {
|
||||||
}
|
k.log.App.Warn().Str("res", res.pretty()).Msg("Ingress is nil, skipping")
|
||||||
if !found {
|
return
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
var result []string
|
|
||||||
for _, p := range paths {
|
|
||||||
path, ok := p.(map[string]any)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
if p, ok := path["path"].(string); ok && p != "" {
|
extractor := NewKubernetesIngressExtractor(KubernetesIngressExtractorInput{
|
||||||
result = append(result, p)
|
Log: k.log,
|
||||||
|
})
|
||||||
|
result = extractor.Extract(typedItem.ingress)
|
||||||
|
case ResourceTypeCRD:
|
||||||
|
if typedItem.crd == nil {
|
||||||
|
k.log.App.Warn().Str("res", res.pretty()).Msg("CRD is nil, skipping")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
extractor := NewKubernetesCRDExtractor(KubernetesCRDInput{
|
||||||
|
Log: k.log,
|
||||||
|
Client: k.typedClient,
|
||||||
|
})
|
||||||
|
result = extractor.Extract(typedItem.crd)
|
||||||
}
|
}
|
||||||
return result, nil
|
|
||||||
|
if event == watch.Deleted {
|
||||||
|
if result.Meta != nil {
|
||||||
|
k.removeResource(*result.Meta)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Apps == nil {
|
||||||
|
k.log.App.Warn().Str("res", res.pretty()).Msg("Failed to extract resource, skipping")
|
||||||
|
if result.Meta != nil {
|
||||||
|
k.removeResource(*result.Meta)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
k.addResource(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) extractHosts(item *unstructured.Unstructured) ([]string, error) {
|
func (k *KubernetesService) resyncGVR(res watchedResource, ctx context.Context) error {
|
||||||
rules, found, err := unstructured.NestedSlice(item.Object, "spec", "rules")
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("reading spec.rules: %w", err)
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
var hosts []string
|
|
||||||
for _, r := range rules {
|
|
||||||
rule, ok := r.(map[string]any)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if host, ok := rule["host"].(string); ok && host != "" {
|
|
||||||
hosts = append(hosts, host)
|
|
||||||
}
|
|
||||||
paths, err := k.extractPaths(rule)
|
|
||||||
if err != nil {
|
|
||||||
// This is purely to warn users
|
|
||||||
// It doesn't affect our ability to extract hosts, so we won't fail the whole operation
|
|
||||||
k.log.App.Warn().Err(err).Str("namespace", item.GetNamespace()).Str("name", item.GetName()).Msg("Failed to extract paths from ingress rule")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if len(paths) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !slices.Contains(paths, "/") {
|
|
||||||
k.log.App.Warn().Str("namespace", item.GetNamespace()).Str("name", item.GetName()).Strs("paths", paths).Msg("Ingress rule does not contain a catch-all path, another ingress may be able to bypass auth checks if it routes the same host with a different path. Consider adding a catch-all path to this rule to ensure auth checks are applied to all paths for this host.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k.log.App.Trace().Strs("hosts", hosts).Msg("Extracted hosts from ingress rules")
|
|
||||||
return hosts, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *KubernetesService) updateFromItem(item *unstructured.Unstructured) {
|
|
||||||
key := ingressKey{
|
|
||||||
namespace: item.GetNamespace(),
|
|
||||||
name: item.GetName(),
|
|
||||||
}
|
|
||||||
|
|
||||||
annotations := item.GetAnnotations()
|
|
||||||
if annotations == nil {
|
|
||||||
k.removeIngress(key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
hosts, err := k.extractHosts(item)
|
|
||||||
if err != nil {
|
|
||||||
k.removeIngress(key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(hosts) == 0 {
|
|
||||||
k.log.App.Warn().Str("namespace", key.namespace).Str("name", key.name).Msg("No hosts found in ingress, skipping")
|
|
||||||
k.removeIngress(key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
labels, err := decoders.DecodeLabels[model.Apps](annotations, "apps")
|
|
||||||
if err != nil {
|
|
||||||
k.log.App.Warn().Err(err).Str("namespace", key.namespace).Str("name", key.name).Msg("Failed to decode ingress labels, skipping")
|
|
||||||
k.removeIngress(key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var entries []ingressEntry
|
|
||||||
|
|
||||||
v := validators.NewDomainValidator(validators.DomainValidatorOptions{})
|
|
||||||
|
|
||||||
for name, config := range labels.Apps {
|
|
||||||
if config.Config.Domain != "" {
|
|
||||||
hostname, err := v.SafeHostname(config.Config.Domain)
|
|
||||||
if err != nil {
|
|
||||||
k.log.App.Warn().Err(err).Str("namespace", key.namespace).Str("name", key.name).Str("domain", config.Config.Domain).Msg("Domain is invalid, matching will rely on app name")
|
|
||||||
} else if slices.Contains(hosts, hostname) {
|
|
||||||
entries = append(entries, ingressEntry{
|
|
||||||
name: name,
|
|
||||||
app: config,
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, host := range hosts {
|
|
||||||
if strings.HasPrefix(strings.ToLower(host), strings.ToLower(name+".")) {
|
|
||||||
entries = append(entries, ingressEntry{
|
|
||||||
name: name,
|
|
||||||
app: config,
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(entries) == 0 {
|
|
||||||
k.removeIngress(key)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
k.addIngressEntries(key, entries)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *KubernetesService) resyncGVR(gvr schema.GroupVersionResource, ctx context.Context) error {
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
list, err := k.client.Resource(gvr).List(ctx, metav1.ListOptions{})
|
list, err := k.client.Resource(res.gvr).List(ctx, metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Failed to list resources for resync")
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Failed to list resources for resync")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i := range list.Items {
|
for _, item := range list.Items {
|
||||||
k.updateFromItem(&list.Items[i])
|
newTypedItem, err := new(typedItem).fromUnstructured(res.typ, &item)
|
||||||
|
if err != nil {
|
||||||
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Failed to decode resource, skipping")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
k.watchedItemChange(res, newTypedItem, watch.Modified)
|
||||||
}
|
}
|
||||||
k.log.App.Debug().Str("api", gvr.GroupVersion().String()).Int("count", len(list.Items)).Msg("Resync complete")
|
k.log.App.Debug().Str("res", res.pretty()).Int("count", len(list.Items)).Msg("Resync complete")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// runWatcher drains events from an active watcher until it closes or the context is done.
|
func (k *KubernetesService) runWatcher(res watchedResource, w watch.Interface, resyncTicker *time.Ticker, ctx context.Context) bool {
|
||||||
// Returns true if the caller should restart the watcher, false if it should exit.
|
|
||||||
func (k *KubernetesService) runWatcher(gvr schema.GroupVersionResource, w watch.Interface, resyncTicker *time.Ticker, ctx context.Context) bool {
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@@ -277,62 +286,62 @@ func (k *KubernetesService) runWatcher(gvr schema.GroupVersionResource, w watch.
|
|||||||
return false
|
return false
|
||||||
case event, ok := <-w.ResultChan():
|
case event, ok := <-w.ResultChan():
|
||||||
if !ok {
|
if !ok {
|
||||||
k.log.App.Warn().Str("api", gvr.GroupVersion().String()).Msg("Watcher channel closed, restarting watcher")
|
k.log.App.Warn().Str("res", res.pretty()).Msg("Watcher channel closed, restarting watcher")
|
||||||
w.Stop()
|
w.Stop()
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
item, ok := event.Object.(*unstructured.Unstructured)
|
item, ok := event.Object.(*unstructured.Unstructured)
|
||||||
if !ok {
|
if !ok {
|
||||||
k.log.App.Warn().Str("api", gvr.GroupVersion().String()).Msg("Received unexpected event object, skipping")
|
k.log.App.Warn().Str("res", res.pretty()).Msg("Received unexpected event object, skipping")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newTypedItem, err := new(typedItem).fromUnstructured(res.typ, item)
|
||||||
|
if err != nil {
|
||||||
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Failed to decode resource, skipping")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case watch.Added, watch.Modified:
|
case watch.Added, watch.Modified, watch.Deleted:
|
||||||
k.updateFromItem(item)
|
k.watchedItemChange(res, newTypedItem, event.Type)
|
||||||
case watch.Deleted:
|
|
||||||
k.removeIngress(ingressKey{
|
|
||||||
namespace: item.GetNamespace(),
|
|
||||||
name: item.GetName(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
case <-resyncTicker.C:
|
case <-resyncTicker.C:
|
||||||
if err := k.resyncGVR(gvr, ctx); err != nil {
|
if err := k.resyncGVR(res, ctx); err != nil {
|
||||||
k.log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Periodic resync failed during watcher run")
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Periodic resync failed during watcher run")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *KubernetesService) watchGVR(gvr schema.GroupVersionResource, ctx context.Context) {
|
func (k *KubernetesService) watchGVR(res watchedResource, ctx context.Context) {
|
||||||
resyncTicker := time.NewTicker(5 * time.Minute)
|
resyncTicker := time.NewTicker(5 * time.Minute)
|
||||||
defer resyncTicker.Stop()
|
defer resyncTicker.Stop()
|
||||||
|
|
||||||
if err := k.resyncGVR(gvr, ctx); err != nil {
|
if err := k.resyncGVR(res, ctx); err != nil {
|
||||||
k.log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Initial resync failed, will retry")
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Initial resync failed, will retry")
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
k.log.App.Debug().Str("api", gvr.GroupVersion().String()).Msg("Shutting down kubernetes watcher")
|
k.log.App.Debug().Str("res", res.pretty()).Msg("Shutting down kubernetes watcher")
|
||||||
return
|
return
|
||||||
case <-resyncTicker.C:
|
case <-resyncTicker.C:
|
||||||
if err := k.resyncGVR(gvr, ctx); err != nil {
|
if err := k.resyncGVR(res, ctx); err != nil {
|
||||||
k.log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Periodic resync failed, will retry")
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Periodic resync failed, will retry")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
watcher, err := k.client.Resource(gvr).Watch(ctx, metav1.ListOptions{})
|
watcher, err := k.client.Resource(res.gvr).Watch(ctx, metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
k.log.App.Warn().Err(err).Str("api", gvr.GroupVersion().String()).Msg("Failed to start watcher, will retry")
|
k.log.App.Warn().Err(err).Str("res", res.pretty()).Msg("Failed to start watcher, will retry")
|
||||||
cancel()
|
cancel()
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
k.log.App.Debug().Str("api", gvr.GroupVersion().String()).Msg("Watcher started successfully")
|
k.log.App.Debug().Str("res", res.pretty()).Msg("Watcher started successfully")
|
||||||
if !k.runWatcher(gvr, watcher, resyncTicker, ctx) {
|
if !k.runWatcher(res, watcher, resyncTicker, ctx) {
|
||||||
cancel()
|
cancel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,679 +1,243 @@
|
|||||||
|
//go:build ignore
|
||||||
|
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/model"
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
||||||
|
networking "k8s.io/api/networking/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestKubernetesService(t *testing.T) {
|
func watchedResourceForTest(t *testing.T, typ ResourceType) watchedResource {
|
||||||
|
t.Helper()
|
||||||
|
for _, resource := range supportedResources {
|
||||||
|
if resource.typ == typ {
|
||||||
|
return resource
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Fatalf("unsupported resource type %q", typ)
|
||||||
|
return watchedResource{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newKubernetesServiceForTest(log *logger.Logger) *KubernetesService {
|
||||||
|
service := &KubernetesService{
|
||||||
|
apps: make(map[resourceKey]routedApps),
|
||||||
|
log: log,
|
||||||
|
}
|
||||||
|
service.extractors.ingress = NewKubernetesIngressExtractor(KubernetesIngressExtractorInput{Log: log})
|
||||||
|
return service
|
||||||
|
}
|
||||||
|
|
||||||
|
func testIngress(name string, annotations map[string]string, hosts ...string) *typedItem {
|
||||||
|
rules := make([]networking.IngressRule, 0, len(hosts))
|
||||||
|
for _, host := range hosts {
|
||||||
|
rules = append(rules, networking.IngressRule{Host: host})
|
||||||
|
}
|
||||||
|
return &typedItem{
|
||||||
|
typ: ResourceTypeIngress,
|
||||||
|
ingress: &networking.Ingress{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: "default", Annotations: annotations},
|
||||||
|
Spec: networking.IngressSpec{Rules: rules},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupApp(service *KubernetesService, domain string) *model.App {
|
||||||
|
var app *model.App
|
||||||
|
service.getEntry(domain, func(name string, candidate *model.App) bool {
|
||||||
|
if candidate.Config.Domain == domain || strings.HasPrefix(domain, name+".") {
|
||||||
|
app = candidate
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
return app
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKubernetesServiceUpdateFromItem(t *testing.T) {
|
||||||
log := logger.NewLogger().WithTestConfig()
|
log := logger.NewLogger().WithTestConfig()
|
||||||
log.Init()
|
log.Init()
|
||||||
|
|
||||||
type testCase struct {
|
tests := []struct {
|
||||||
description string
|
name string
|
||||||
run func(t *testing.T, svc *KubernetesService)
|
resource ResourceType
|
||||||
|
item *typedItem
|
||||||
|
domain string
|
||||||
|
wantConfigDomain string
|
||||||
|
allow string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Ingress matches a configured domain",
|
||||||
|
resource: ResourceTypeIngress,
|
||||||
|
item: testIngress("ingress", map[string]string{
|
||||||
|
"tinyauth.apps.dashboard.config.domain": "dashboard.example.com",
|
||||||
|
"tinyauth.apps.dashboard.users.allow": "alice",
|
||||||
|
}, "dashboard.example.com"),
|
||||||
|
domain: "dashboard.example.com", wantConfigDomain: "dashboard.example.com", allow: "alice",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ingress matches an app name case insensitively",
|
||||||
|
resource: ResourceTypeIngress,
|
||||||
|
item: testIngress("ingress", map[string]string{
|
||||||
|
"tinyauth.apps.dashboard.users.allow": "alice",
|
||||||
|
}, "Dashboard.example.com"),
|
||||||
|
domain: "dashboard.example.com", allow: "alice",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []testCase{
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
service := newKubernetesServiceForTest(log)
|
||||||
|
service.updateFromItem(watchedResourceForTest(t, test.resource), test.item)
|
||||||
|
|
||||||
|
app := lookupApp(service, test.domain)
|
||||||
|
require.NotNil(t, app)
|
||||||
|
assert.Equal(t, test.allow, app.Users.Allow)
|
||||||
|
assert.Equal(t, test.wantConfigDomain, app.Config.Domain)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKubernetesServiceUpdateFromItemRemovesStaleEntries(t *testing.T) {
|
||||||
|
log := logger.NewLogger().WithTestConfig()
|
||||||
|
log.Init()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
resource ResourceType
|
||||||
|
item *typedItem
|
||||||
|
}{
|
||||||
|
{"Ingress without annotations", ResourceTypeIngress, testIngress("route", nil, "app.example.com")},
|
||||||
|
{"Ingress without hosts", ResourceTypeIngress, testIngress("route", map[string]string{"tinyauth.apps.app.users.allow": "alice"})},
|
||||||
|
{"Ingress with invalid annotations", ResourceTypeIngress, testIngress("route", map[string]string{"tinyauth.apps.app.users.break": "invalid"}, "app.example.com")},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
service := newKubernetesServiceForTest(log)
|
||||||
|
key := resourceKey{typ: test.resource, namespace: "default", name: "route"}
|
||||||
|
service.addResourceEntries(key, []string{"app.example.com"}, []resourceEntry{{
|
||||||
|
name: "app",
|
||||||
|
app: model.App{Config: model.AppConfig{Domain: "app.example.com"}},
|
||||||
|
}})
|
||||||
|
|
||||||
|
service.updateFromItem(watchedResourceForTest(t, test.resource), test.item)
|
||||||
|
assert.Nil(t, lookupApp(service, "app.example.com"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTypedItemFromUnstructured(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
resource ResourceType
|
||||||
|
item unstructured.Unstructured
|
||||||
|
assert func(t *testing.T, item *typedItem)
|
||||||
|
}{
|
||||||
{
|
{
|
||||||
description: "Cache by domain returns app and misses unknown domain",
|
name: "Ingress",
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
resource: ResourceTypeIngress,
|
||||||
app := model.App{Config: model.AppConfig{Domain: "foo.example.com"}}
|
item: unstructured.Unstructured{Object: map[string]any{
|
||||||
svc.addIngressEntries(ingressKey{
|
"metadata": map[string]any{"name": "ingress", "namespace": "default"},
|
||||||
namespace: "default",
|
"spec": map[string]any{"rules": []any{map[string]any{"host": "app.example.com"}}},
|
||||||
name: "my-ingress",
|
}},
|
||||||
}, []ingressEntry{
|
assert: func(t *testing.T, item *typedItem) {
|
||||||
{
|
require.NotNil(t, item.ingress)
|
||||||
app: app,
|
assert.Equal(t, "app.example.com", item.ingress.Spec.Rules[0].Host)
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "foo.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "foo.example.com", got.Config.Domain)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "RemoveIngress clears domain and app name entries",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
app := model.App{Config: model.AppConfig{Domain: "foo.example.com"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: app,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "foo.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "foo.example.com", got.Config.Domain)
|
|
||||||
|
|
||||||
got = nil
|
|
||||||
svc.removeIngress(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
})
|
|
||||||
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "foo.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "AddIngressApps replaces stale entries for the same ingress",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
old := model.App{Config: model.AppConfig{Domain: "old.example.com"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: old,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
updated := model.App{Config: model.AppConfig{Domain: "new.example.com"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: updated,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "old.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "new.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "new.example.com", got.Config.Domain)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "GetLabels returns app from cache when connected",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
svc.connected = true
|
|
||||||
|
|
||||||
app := model.App{Config: model.AppConfig{Domain: "hit.example.com"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: app,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
err := svc.Lookup(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "hit.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "hit.example.com", got.Config.Domain)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "GetLabels returns empty app on cache miss when started",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
svc.connected = true
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
err := svc.Lookup(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "notfound.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "GetLabels resolves app by app name",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
svc.connected = true
|
|
||||||
|
|
||||||
app := model.App{Path: model.AppPath{Allow: "/foo"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: app,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
err := svc.Lookup(func(name string, app *model.App) bool {
|
|
||||||
if strings.HasPrefix("foo.internal.example.com", "foo.") {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "/foo", got.Path.Allow)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "GetLabels returns empty app when service not yet started",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
var got *model.App
|
|
||||||
err := svc.Lookup(func(name string, app *model.App) bool {
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem parses annotations and populates cache",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
"tinyauth.apps.myapp.users.allow": "alice",
|
|
||||||
})
|
|
||||||
item.Object["spec"] = map[string]any{
|
|
||||||
"rules": []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "myapp.example.com",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "myapp.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "myapp.example.com", got.Config.Domain)
|
|
||||||
assert.Equal(t, "alice", got.Users.Allow)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "Update from item skips annotations with no hosts",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
})
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "myapp.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem fails when label parsing fails",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
"tinyauth.apps.myapp.users.break": "i-dont-exist",
|
|
||||||
})
|
|
||||||
item.Object["spec"] = map[string]any{
|
|
||||||
"rules": []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "myapp.example.com",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "myapp.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
require.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem with no annotations removes existing cache entries",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
app := model.App{Config: model.AppConfig{Domain: "todelete.example.com"}}
|
|
||||||
svc.addIngressEntries(ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "my-ingress",
|
|
||||||
}, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: app,
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("my-ingress")
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if app.Config.Domain == "todelete.example.com" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractPaths returns all non empty paths from a rule",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
rule := map[string]any{
|
|
||||||
"http": map[string]any{
|
|
||||||
"paths": []any{
|
|
||||||
map[string]any{"path": "/"},
|
|
||||||
map[string]any{"path": "/api"},
|
|
||||||
map[string]any{"path": ""},
|
|
||||||
map[string]any{"pathType": "Prefix"},
|
|
||||||
"not-a-map",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
paths, err := svc.extractPaths(rule)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, []string{"/", "/api"}, paths)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractPaths returns nothing when http or paths are missing",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
paths, err := svc.extractPaths(map[string]any{})
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Empty(t, paths)
|
|
||||||
|
|
||||||
paths, err = svc.extractPaths(map[string]any{
|
|
||||||
"http": map[string]any{},
|
|
||||||
})
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Empty(t, paths)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractPaths errors when http is not a map",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
paths, err := svc.extractPaths(map[string]any{
|
|
||||||
"http": "invalid",
|
|
||||||
})
|
|
||||||
require.Error(t, err)
|
|
||||||
assert.Nil(t, paths)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractPaths errors when paths is not a slice",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
paths, err := svc.extractPaths(map[string]any{
|
|
||||||
"http": map[string]any{
|
|
||||||
"paths": "invalid",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require.Error(t, err)
|
|
||||||
assert.Nil(t, paths)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractHosts returns hosts from all rules",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "foo.example.com",
|
|
||||||
"http": map[string]any{
|
|
||||||
"paths": []any{
|
|
||||||
map[string]any{"path": "/"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
map[string]any{
|
|
||||||
"host": "bar.example.com",
|
|
||||||
},
|
|
||||||
map[string]any{
|
|
||||||
"host": "",
|
|
||||||
},
|
|
||||||
"not-a-map",
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
hosts, err := svc.extractHosts(&item)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, []string{"foo.example.com", "bar.example.com"}, hosts)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractHosts still returns hosts when a rule has no catch all path",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "foo.example.com",
|
|
||||||
"http": map[string]any{
|
|
||||||
"paths": []any{
|
|
||||||
map[string]any{"path": "/api"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
hosts, err := svc.extractHosts(&item)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, []string{"foo.example.com"}, hosts)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractHosts still returns hosts when path extraction fails",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "foo.example.com",
|
|
||||||
"http": "invalid",
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
hosts, err := svc.extractHosts(&item)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, []string{"foo.example.com"}, hosts)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractHosts returns nothing when spec.rules is missing",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
|
|
||||||
hosts, err := svc.extractHosts(&item)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Empty(t, hosts)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "ExtractHosts errors when spec.rules is not a slice",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
require.NoError(t, unstructured.SetNestedField(item.Object, "invalid", "spec", "rules"))
|
|
||||||
|
|
||||||
hosts, err := svc.extractHosts(&item)
|
|
||||||
require.Error(t, err)
|
|
||||||
assert.Nil(t, hosts)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem registers app when its domain matches an ingress host",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
})
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "myapp.example.com",
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if name == "myapp" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "myapp.example.com", got.Config.Domain)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem registers app when its name matches an ingress host prefix",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.users.allow": "alice",
|
|
||||||
})
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "MyApp.example.com",
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if name == "myapp" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
assert.Equal(t, "alice", got.Users.Allow)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem skips apps that match neither host nor name",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
})
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "other.example.com",
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem falls back to app name when the domain is invalid",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace("default")
|
|
||||||
item.SetName("test-ingress")
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "not a domain",
|
|
||||||
})
|
|
||||||
require.NoError(t, unstructured.SetNestedSlice(item.Object, []any{
|
|
||||||
map[string]any{
|
|
||||||
"host": "myapp.example.com",
|
|
||||||
},
|
|
||||||
}, "spec", "rules"))
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
if name == "myapp" {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
require.NotNil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem removes entries when host extraction fails",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
key := ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "test-ingress",
|
|
||||||
}
|
|
||||||
svc.addIngressEntries(key, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: model.App{Config: model.AppConfig{Domain: "stale.example.com"}},
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace(key.namespace)
|
|
||||||
item.SetName(key.name)
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.domain": "myapp.example.com",
|
|
||||||
})
|
|
||||||
require.NoError(t, unstructured.SetNestedField(item.Object, "invalid", "spec", "rules"))
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "UpdateFromItem removes entries when annotations are not decodable",
|
|
||||||
run: func(t *testing.T, svc *KubernetesService) {
|
|
||||||
key := ingressKey{
|
|
||||||
namespace: "default",
|
|
||||||
name: "test-ingress",
|
|
||||||
}
|
|
||||||
svc.addIngressEntries(key, []ingressEntry{
|
|
||||||
{
|
|
||||||
app: model.App{Config: model.AppConfig{Domain: "stale.example.com"}},
|
|
||||||
name: "foo",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
item := unstructured.Unstructured{}
|
|
||||||
item.SetNamespace(key.namespace)
|
|
||||||
item.SetName(key.name)
|
|
||||||
item.SetAnnotations(map[string]string{
|
|
||||||
"tinyauth.apps.myapp.config.oauthWhitelist": "[",
|
|
||||||
})
|
|
||||||
|
|
||||||
svc.updateFromItem(&item)
|
|
||||||
|
|
||||||
var got *model.App
|
|
||||||
svc.getEntry(func(name string, app *model.App) bool {
|
|
||||||
got = app
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
assert.Nil(t, got)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
svc := &KubernetesService{
|
item, err := new(typedItem).fromUnstructured(test.resource, &test.item)
|
||||||
ingressEntries: make(map[ingressKey][]ingressEntry),
|
require.NoError(t, err)
|
||||||
log: log,
|
assert.Equal(t, test.resource, item.typ)
|
||||||
}
|
test.assert(t, item)
|
||||||
test.run(t, svc)
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKubernetesServiceLookup(t *testing.T) {
|
||||||
|
log := logger.NewLogger().WithTestConfig()
|
||||||
|
log.Init()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
connected bool
|
||||||
|
domain string
|
||||||
|
wantApp bool
|
||||||
|
}{
|
||||||
|
{"Returns a matching app when connected", true, "app.example.com", true},
|
||||||
|
{"Skips the cache before the service is connected", false, "app.example.com", false},
|
||||||
|
{"Skips an invalid domain", true, "app.example.com\xC3\xA9", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
service := newKubernetesServiceForTest(log)
|
||||||
|
service.connected = test.connected
|
||||||
|
service.addResourceEntries(resourceKey{typ: ResourceTypeIngress, namespace: "default", name: "route"}, []string{"app.example.com"}, []resourceEntry{{
|
||||||
|
name: "app",
|
||||||
|
app: model.App{Config: model.AppConfig{Domain: "app.example.com"}},
|
||||||
|
}})
|
||||||
|
|
||||||
|
var app *model.App
|
||||||
|
err := service.Lookup(test.domain, func(_ string, candidate *model.App) bool {
|
||||||
|
app = candidate
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, test.wantApp, app != nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKubernetesServiceKeepsResourceTypesSeparate(t *testing.T) {
|
||||||
|
log := logger.NewLogger().WithTestConfig()
|
||||||
|
log.Init()
|
||||||
|
service := newKubernetesServiceForTest(log)
|
||||||
|
|
||||||
|
resources := []struct {
|
||||||
|
resource ResourceType
|
||||||
|
item *typedItem
|
||||||
|
domain string
|
||||||
|
}{
|
||||||
|
{ResourceTypeIngress, testIngress("shared", map[string]string{"tinyauth.apps.ingress.config.domain": "ingress.example.com"}, "ingress.example.com"), "ingress.example.com"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, resource := range resources {
|
||||||
|
service.updateFromItem(watchedResourceForTest(t, resource.resource), resource.item)
|
||||||
|
}
|
||||||
|
for _, resource := range resources {
|
||||||
|
assert.NotNil(t, lookupApp(service, resource.domain))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKubernetesHostMatching(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
host string
|
||||||
|
domain string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"Exact host", "app.example.com", "app.example.com", true},
|
||||||
|
{"Case insensitive exact host", "App.Example.com", "app.example.com", true},
|
||||||
|
{"Wildcard host", "*.example.com", "deep.app.example.com", true},
|
||||||
|
{"Wildcard does not match its apex", "*.example.com", "example.com", false},
|
||||||
|
{"Different host", "app.example.com", "other.example.com", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
assert.Equal(t, test.want, hostMatchesHostname(test.host, test.domain))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:generate controller-gen object paths=$GOFILE
|
||||||
|
//go:generate controller-gen rbac:roleName=tinyauth crd paths=./... output:crd:dir=./crds output:stdout
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||||
|
|
||||||
|
// Application is a set of access control rules that can be applied to a
|
||||||
|
// specific domain. It is an alternative to environment variable or config-based
|
||||||
|
// access controls.
|
||||||
|
type Application struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
Spec ApplicationSpec `json:"spec,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// ApplicationSpec describes the application to which this rule applies to
|
||||||
|
type ApplicationSpec struct {
|
||||||
|
Config AppConfig `json:"config,omitempty"`
|
||||||
|
Users AppUsers `json:"users,omitempty"`
|
||||||
|
OAuth AppOAuth `json:"oauth,omitempty"`
|
||||||
|
IP AppIP `json:"ip,omitempty"`
|
||||||
|
Response AppResponse `json:"response,omitempty"`
|
||||||
|
Path AppPath `json:"path,omitempty"`
|
||||||
|
LDAP AppLDAP `json:"ldap,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppConfig specifies configuration for the application
|
||||||
|
type AppConfig struct {
|
||||||
|
// +required
|
||||||
|
Domain string `json:"domain,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppUsers specifies user access control rules
|
||||||
|
type AppUsers struct {
|
||||||
|
Allow string `json:"allow,omitempty"`
|
||||||
|
Block string `json:"block,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppOAuth specifies OAuth access control rules
|
||||||
|
type AppOAuth struct {
|
||||||
|
Whitelist string `json:"whitelist,omitempty"`
|
||||||
|
Groups string `json:"groups,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppLDAP specifies LDAP access control rules
|
||||||
|
type AppLDAP struct {
|
||||||
|
Groups string `json:"groups,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppIP specifies IP access control rules
|
||||||
|
type AppIP struct {
|
||||||
|
Allow []string `json:"allow,omitempty"`
|
||||||
|
Block []string `json:"block,omitempty"`
|
||||||
|
Bypass []string `json:"bypass,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppResponse specifies response headers and basic auth credentials
|
||||||
|
type AppResponse struct {
|
||||||
|
Headers []string `json:"headers,omitempty"`
|
||||||
|
BasicAuth AppBasicAuth `json:"basicAuth,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppBasicAuth specifies basic auth credentials
|
||||||
|
type AppBasicAuth struct {
|
||||||
|
Username string `json:"username,omitempty"`
|
||||||
|
PasswordSecretRef *corev1.SecretKeySelector `json:"passwordSecretRef,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +k8s:deepcopy-gen=true
|
||||||
|
|
||||||
|
// AppPath specifies path-based access control rules
|
||||||
|
type AppPath struct {
|
||||||
|
Allow string `json:"allow,omitempty"`
|
||||||
|
Block string `json:"block,omitempty"`
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
---
|
||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
controller-gen.kubebuilder.io/version: v0.22.0
|
||||||
|
name: applications.tinyauth.app
|
||||||
|
spec:
|
||||||
|
group: tinyauth.app
|
||||||
|
names:
|
||||||
|
kind: Application
|
||||||
|
listKind: ApplicationList
|
||||||
|
plural: applications
|
||||||
|
singular: application
|
||||||
|
scope: Namespaced
|
||||||
|
versions:
|
||||||
|
- name: v1alpha1
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
description: |-
|
||||||
|
Application is a set of access control rules that can be applied to a
|
||||||
|
specific domain. It is an alternative to environment variable or config-based
|
||||||
|
access controls.
|
||||||
|
properties:
|
||||||
|
apiVersion:
|
||||||
|
description: |-
|
||||||
|
APIVersion defines the versioned schema of this representation of an object.
|
||||||
|
Servers should convert recognized schemas to the latest internal value, and
|
||||||
|
may reject unrecognized values.
|
||||||
|
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||||
|
type: string
|
||||||
|
kind:
|
||||||
|
description: |-
|
||||||
|
Kind is a string value representing the REST resource this object represents.
|
||||||
|
Servers may infer this from the endpoint the client submits requests to.
|
||||||
|
Cannot be updated.
|
||||||
|
In CamelCase.
|
||||||
|
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||||
|
type: string
|
||||||
|
metadata:
|
||||||
|
type: object
|
||||||
|
spec:
|
||||||
|
description: ApplicationSpec describes the application to which this rule
|
||||||
|
applies to
|
||||||
|
properties:
|
||||||
|
config:
|
||||||
|
description: AppConfig specifies configuration for the application
|
||||||
|
properties:
|
||||||
|
domain:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- domain
|
||||||
|
type: object
|
||||||
|
ip:
|
||||||
|
description: AppIP specifies IP access control rules
|
||||||
|
properties:
|
||||||
|
allow:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
block:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
bypass:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
ldap:
|
||||||
|
description: AppLDAP specifies LDAP access control rules
|
||||||
|
properties:
|
||||||
|
groups:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
oauth:
|
||||||
|
description: AppOAuth specifies OAuth access control rules
|
||||||
|
properties:
|
||||||
|
groups:
|
||||||
|
type: string
|
||||||
|
whitelist:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
path:
|
||||||
|
description: AppPath specifies path-based access control rules
|
||||||
|
properties:
|
||||||
|
allow:
|
||||||
|
type: string
|
||||||
|
block:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
response:
|
||||||
|
description: AppResponse specifies response headers and basic auth
|
||||||
|
credentials
|
||||||
|
properties:
|
||||||
|
basicAuth:
|
||||||
|
description: AppBasicAuth specifies basic auth credentials
|
||||||
|
properties:
|
||||||
|
passwordSecretRef:
|
||||||
|
description: SecretKeySelector selects a key of a Secret.
|
||||||
|
properties:
|
||||||
|
key:
|
||||||
|
description: The key of the secret to select from. Must
|
||||||
|
be a valid secret key.
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
default: ""
|
||||||
|
description: |-
|
||||||
|
Name of the referent.
|
||||||
|
This field is effectively required, but due to backwards compatibility is
|
||||||
|
allowed to be empty. Instances of this type with an empty value here are
|
||||||
|
almost certainly wrong.
|
||||||
|
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
|
||||||
|
type: string
|
||||||
|
optional:
|
||||||
|
description: Specify whether the Secret or its key must
|
||||||
|
be defined
|
||||||
|
type: boolean
|
||||||
|
required:
|
||||||
|
- key
|
||||||
|
type: object
|
||||||
|
x-kubernetes-map-type: atomic
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
headers:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
users:
|
||||||
|
description: AppUsers specifies user access control rules
|
||||||
|
properties:
|
||||||
|
allow:
|
||||||
|
type: string
|
||||||
|
block:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
//+groupName=tinyauth.app
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ToInternalApp converts the ApplicationSpec to the internal App structure
|
||||||
|
func (s *ApplicationSpec) ToInternalApp() model.App {
|
||||||
|
return model.App{
|
||||||
|
Config: model.AppConfig{
|
||||||
|
Domain: s.Config.Domain,
|
||||||
|
},
|
||||||
|
Users: model.AppUsers{
|
||||||
|
Allow: s.Users.Allow,
|
||||||
|
Block: s.Users.Block,
|
||||||
|
},
|
||||||
|
OAuth: model.AppOAuth{
|
||||||
|
Whitelist: s.OAuth.Whitelist,
|
||||||
|
Groups: s.OAuth.Groups,
|
||||||
|
},
|
||||||
|
IP: model.AppIP{
|
||||||
|
Allow: s.IP.Allow,
|
||||||
|
Block: s.IP.Block,
|
||||||
|
Bypass: s.IP.Bypass,
|
||||||
|
},
|
||||||
|
Response: model.AppResponse{
|
||||||
|
Headers: s.Response.Headers,
|
||||||
|
BasicAuth: model.AppBasicAuth{
|
||||||
|
Username: s.Response.BasicAuth.Username,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Path: model.AppPath{
|
||||||
|
Allow: s.Path.Allow,
|
||||||
|
Block: s.Path.Block,
|
||||||
|
},
|
||||||
|
LDAP: model.AppLDAP{
|
||||||
|
Groups: s.LDAP.Groups,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
const GroupName = "tinyauth.app"
|
||||||
|
const GroupVersion = "v1alpha1"
|
||||||
|
|
||||||
|
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}
|
||||||
|
|
||||||
|
var (
|
||||||
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
)
|
||||||
|
|
||||||
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||||
|
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||||
|
&Application{},
|
||||||
|
)
|
||||||
|
|
||||||
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
//go:build !ignore_autogenerated
|
||||||
|
|
||||||
|
// Code generated by controller-gen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppBasicAuth) DeepCopyInto(out *AppBasicAuth) {
|
||||||
|
*out = *in
|
||||||
|
if in.PasswordSecretRef != nil {
|
||||||
|
in, out := &in.PasswordSecretRef, &out.PasswordSecretRef
|
||||||
|
*out = new(v1.SecretKeySelector)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppBasicAuth.
|
||||||
|
func (in *AppBasicAuth) DeepCopy() *AppBasicAuth {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppBasicAuth)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppConfig) DeepCopyInto(out *AppConfig) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppConfig.
|
||||||
|
func (in *AppConfig) DeepCopy() *AppConfig {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppConfig)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppIP) DeepCopyInto(out *AppIP) {
|
||||||
|
*out = *in
|
||||||
|
if in.Allow != nil {
|
||||||
|
in, out := &in.Allow, &out.Allow
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
if in.Block != nil {
|
||||||
|
in, out := &in.Block, &out.Block
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
if in.Bypass != nil {
|
||||||
|
in, out := &in.Bypass, &out.Bypass
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppIP.
|
||||||
|
func (in *AppIP) DeepCopy() *AppIP {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppIP)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppLDAP) DeepCopyInto(out *AppLDAP) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppLDAP.
|
||||||
|
func (in *AppLDAP) DeepCopy() *AppLDAP {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppLDAP)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppOAuth) DeepCopyInto(out *AppOAuth) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppOAuth.
|
||||||
|
func (in *AppOAuth) DeepCopy() *AppOAuth {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppOAuth)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppPath) DeepCopyInto(out *AppPath) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppPath.
|
||||||
|
func (in *AppPath) DeepCopy() *AppPath {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppPath)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppResponse) DeepCopyInto(out *AppResponse) {
|
||||||
|
*out = *in
|
||||||
|
if in.Headers != nil {
|
||||||
|
in, out := &in.Headers, &out.Headers
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
in.BasicAuth.DeepCopyInto(&out.BasicAuth)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppResponse.
|
||||||
|
func (in *AppResponse) DeepCopy() *AppResponse {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppResponse)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AppUsers) DeepCopyInto(out *AppUsers) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppUsers.
|
||||||
|
func (in *AppUsers) DeepCopy() *AppUsers {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AppUsers)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *Application) DeepCopyInto(out *Application) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
in.Spec.DeepCopyInto(&out.Spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Application.
|
||||||
|
func (in *Application) DeepCopy() *Application {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(Application)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *Application) DeepCopyObject() runtime.Object {
|
||||||
|
if c := in.DeepCopy(); c != nil {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) {
|
||||||
|
*out = *in
|
||||||
|
out.Config = in.Config
|
||||||
|
out.Users = in.Users
|
||||||
|
out.OAuth = in.OAuth
|
||||||
|
in.IP.DeepCopyInto(&out.IP)
|
||||||
|
in.Response.DeepCopyInto(&out.Response)
|
||||||
|
out.Path = in.Path
|
||||||
|
out.LDAP = in.LDAP
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec.
|
||||||
|
func (in *ApplicationSpec) DeepCopy() *ApplicationSpec {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(ApplicationSpec)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user