Skip to content

Commit 6073fbf

Browse files
authored
Rework auth (#1)
1 parent e71bb30 commit 6073fbf

56 files changed

Lines changed: 2573 additions & 1818 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ COPY --from=frontend-builder /app/docs/out ./docs/out/
8989
# Fetch model catalog (embedded at compile time via include_str!)
9090
RUN mkdir -p data && curl -sSL https://models.dev/api.json -o data/models-dev-catalog.json
9191

92-
# Touch main.rs to invalidate the dummy build
93-
RUN touch src/main.rs
92+
# Force fresh build of the main crate by removing cached artifacts.
93+
# The --mount=type=cache for target/ persists across builds, but fingerprints
94+
# may not detect all source changes. Removing the crate's artifacts ensures
95+
# a full recompile of application code (dependencies remain cached).
96+
RUN touch src/main.rs && \
97+
rm -rf target/release/.fingerprint/hadrian-* \
98+
target/release/deps/hadrian-* \
99+
target/release/deps/libhadrian-* \
100+
target/release/hadrian
94101

95102
# Build the actual application
96103
RUN --mount=type=cache,target=/usr/local/cargo/registry \

deploy/config/hadrian.dlq.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ path = "/app/data/hadrian.db"
99
type = "redis"
1010
url = "${REDIS_URL}"
1111

12-
[auth.gateway]
13-
type = "api_key"
14-
header_name = "X-API-Key"
15-
key_prefix = "gw_"
16-
cache_ttl_secs = 300
12+
[auth.mode]
13+
type = "none"
1714

1815
[providers]
1916
default_provider = "test"

deploy/config/hadrian.keycloak.toml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# Development setup with Keycloak for per-org OIDC authentication
33
# OIDC SSO is configured via Admin API, not in this config file
44

5+
[server]
6+
# Allow Docker-internal private IPs for OIDC discovery (Keycloak runs in Docker)
7+
allow_private_urls = true
8+
# Keycloak advertises issuer as http://localhost:8080 (host-mapped port)
9+
allow_loopback_urls = true
10+
511
[ui]
612
enabled = true
713

@@ -15,13 +21,19 @@ enabled = true
1521
api_key = "gw_test_bootstrap_key_for_e2e"
1622

1723
# ==============================================================================
18-
# Session Configuration (for per-org SSO)
24+
# Auth Mode: IdP (per-org SSO + API keys)
1925
# ==============================================================================
2026
# OIDC authentication is configured per-organization via the Admin API.
21-
# This section only configures session management for authenticated users.
22-
# The test setup creates the SSO connection with OIDC settings.
23-
[auth.admin]
24-
type = "session"
27+
# Session management for authenticated users is configured below.
28+
[auth.mode]
29+
type = "idp"
30+
31+
[auth.api_key]
32+
header_name = "X-API-Key"
33+
key_prefix = "gw_"
34+
cache_ttl_secs = 300
35+
36+
[auth.session]
2537
secure = false # For local dev over HTTP
2638

2739
[database]
@@ -32,12 +44,6 @@ path = "/app/data/hadrian.db"
3244
type = "redis"
3345
url = "${REDIS_URL}"
3446

35-
[auth.gateway]
36-
type = "api_key"
37-
header_name = "X-API-Key"
38-
key_prefix = "gw_"
39-
cache_ttl_secs = 300
40-
4147
# RBAC is disabled for this basic keycloak test to allow unauthenticated admin API access.
4248
# For comprehensive RBAC testing with OIDC authentication, see the university deployment tests.
4349

deploy/config/hadrian.observability.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ path = "/app/data/hadrian.db"
99
type = "redis"
1010
url = "${REDIS_URL}"
1111

12-
[auth.gateway]
13-
type = "api_key"
14-
header_name = "X-API-Key"
15-
key_prefix = "gw_"
16-
cache_ttl_secs = 300
12+
[auth.mode]
13+
type = "none"
1714

1815
[providers]
1916
default_provider = "test"

deploy/config/hadrian.postgres-ha.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ read_url = "${DATABASE_READ_URL}"
1111
type = "redis"
1212
url = "${REDIS_URL}"
1313

14-
[auth.gateway]
15-
type = "api_key"
16-
header_name = "X-API-Key"
17-
key_prefix = "gw_"
18-
cache_ttl_secs = 300
14+
[auth.mode]
15+
type = "none"
1916

2017
[providers]
2118
default_provider = "test"

deploy/config/hadrian.postgres.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ url = "${DATABASE_URL}"
99
type = "redis"
1010
url = "${REDIS_URL}"
1111

12-
[auth.gateway]
13-
type = "api_key"
14-
header_name = "X-API-Key"
15-
key_prefix = "gw_"
16-
cache_ttl_secs = 300 # 5 minutes with Redis
12+
[auth.mode]
13+
type = "none"
1714

18-
# Optional: Reverse proxy authentication for UI
15+
# Optional: IAP (Identity-Aware Proxy) authentication
1916
# Trusts identity headers from an authenticating proxy (Cloudflare Access, oauth2-proxy, etc.)
2017
# IMPORTANT: Configure [server.trusted_proxies] to prevent header spoofing
21-
# [auth.admin]
22-
# type = "proxy_auth"
18+
# [auth.mode]
19+
# type = "iap"
2320
# identity_header = "Cf-Access-Authenticated-User-Email"
2421
# email_header = "Cf-Access-Authenticated-User-Email"
2522
# name_header = "X-Forwarded-User"

deploy/config/hadrian.production.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ url = "${DATABASE_URL}"
1111
type = "redis"
1212
url = "${REDIS_URL}"
1313

14-
[auth.gateway]
14+
[auth.mode]
1515
type = "api_key"
16+
17+
[auth.api_key]
1618
header_name = "X-API-Key"
1719
key_prefix = "gw_"
1820
cache_ttl_secs = 300

deploy/config/hadrian.provider-health.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ path = "/app/data/hadrian.db"
88
[cache]
99
type = "memory"
1010

11-
[auth.gateway]
12-
type = "api_key"
13-
header_name = "X-API-Key"
14-
key_prefix = "gw_"
11+
[auth.mode]
12+
type = "none"
1513

1614
[providers]
1715
default_provider = "test"

deploy/config/hadrian.redis-cluster.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ retry_delay_ms = 100
1717
connection_timeout_secs = 5
1818
response_timeout_secs = 1
1919

20-
[auth.gateway]
21-
type = "api_key"
22-
header_name = "X-API-Key"
23-
key_prefix = "gw_"
24-
cache_ttl_secs = 300
20+
[auth.mode]
21+
type = "none"
2522

2623
[providers]
2724
default_provider = "test"

deploy/config/hadrian.saml.toml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# - SAML groups are captured for the group mapping feature
1717
# - Group mappings are configured via Admin API, not parsed from assertion attributes
1818

19+
[server]
20+
# Allow Docker-internal private IPs for SAML/OIDC discovery (Authentik runs in Docker)
21+
allow_private_urls = true
22+
1923
[ui]
2024
enabled = true
2125

@@ -31,22 +35,16 @@ api_key = "gw_test_bootstrap_key_for_e2e"
3135
auto_verify_domains = ["university.edu"]
3236

3337
# ==============================================================================
34-
# Session Configuration (for per-org SSO)
38+
# Auth Mode: IdP (per-org SSO)
3539
# ==============================================================================
3640
# SAML authentication is configured per-organization via the Admin API.
37-
# This section configures session management for authenticated users.
38-
[auth.admin]
39-
type = "session"
40-
secure = false # For local dev over HTTP
41+
# Session management for authenticated users is configured below.
42+
# No API key requirement for this test — focuses on SAML SSO flow.
43+
[auth.mode]
44+
type = "idp"
4145

42-
# ==============================================================================
43-
# API Authentication
44-
# ==============================================================================
45-
# For SAML E2E tests, we disable API authentication to allow bootstrapping.
46-
# In production, you would use API keys for programmatic access.
47-
# The test focuses on SAML SSO flow, not API key management.
48-
[auth.gateway]
49-
type = "none"
46+
[auth.session]
47+
secure = false # For local dev over HTTP
5048

5149
# ==============================================================================
5250
# RBAC Configuration

0 commit comments

Comments
 (0)