Compare commits

...
3 Commits
Author SHA1 Message Date
rock 8b01e04569 fix: update CI registry path to new riotpiao-poimen org
CI / CI (pull_request) Successful in 4m13s
2026-09-08 08:50:51 -07:00
rock 8ac2bd580b feat: add auth mode none for testing (no auth required)
- Add AuthMode::None variant for disassembly/testing
- Returns synthetic JWT claims when auth disabled
- Set MEM_AUTH_MODE=none in config for dev/test
- Allows full API access without Authentik OIDC
2026-09-08 08:50:51 -07:00
rock 5fc9101888 fix: extract auth config to ConfigMap + SOPS, update Authentik slug (#40)
CI / CI (push) Successful in 15m28s
## Problem

JWT validation failing with `error decoding response body: expected value at line 6 column 1`.

Root cause: `AUTHENTIK_ISSUER` pointed to slug `poimen-memory` which returns 404 on OIDC discovery. Slug was renamed to `poimen` in Authentik.

Secondary issue: auth env vars were set via `kubectl set env` (not in git), so every ArgoCD sync reverted them.

## Changes

- **k8s/app/config.yaml** — ConfigMap for non-sensitive env (auth mode, rate limits, OpenSearch/Obsidian URLs)
- **k8s/app/auth.enc.yaml** — SOPS-encrypted Secret with `AUTHENTIK_ISSUER`, `AUTHENTIK_AUDIENCE`, `JWT_CACHE_TTL_SECS`
- **k8s/app/secret-generator.yaml** — KSOPS generator for ArgoCD decryption
- **k8s/app/deployment.yaml** — `envFrom` referencing ConfigMap + Secret
- **k8s/app/kustomization.yaml** — Added config.yaml + KSOPS generator
- **k8s/app/opensearch-deployment.yaml** — Updated JWKS/issuer URLs to `poimen` slug

## Rollout

Reloader (`--auto-reload-all=true`) triggers rolling restart when ConfigMap/Secret change. Merge and ArgoCD sync handles everything.Reviewed-on: rock/poimen-memory#40

Co-authored-by: rock <[email protected]>
2026-09-08 05:34:17 +00:00
8 changed files with 93 additions and 6 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ on:
env:
REGISTRY: forgejo.riotpiao.com
IMAGE: forgejo.riotpiao.com/rock/poimen-memory
IMAGE: forgejo.riotpiao.com/riotpiao-poimen/poimen-memory
DOCKER_HOST: tcp://localhost:2375
SQLX_OFFLINE: "true"
+18 -1
View File
@@ -50,13 +50,29 @@ pub struct AppState {
pub enum AuthMode {
Jwt, // Validate JWT from Authentik
ApiKey, // Fallback to static API key
None, // No auth (testing only)
}
/// Auth extractor — validates JWT or fallback to apikey
/// Auth extractor — validates JWT, apikey, or disabled
async fn validate_auth(req: &HttpRequest, state: &AppState) -> Result<(JwtClaims, String), HttpResponse> {
match state.auth_mode {
AuthMode::Jwt => validate_jwt_token(req, state).await,
AuthMode::ApiKey => validate_apikey(req, state),
AuthMode::None => {
tracing::warn!("Auth disabled - returning synthetic claims");
let claims = JwtClaims {
sub: "test-user".to_string(),
iss: "test".to_string(),
aud: "memory".to_string(),
exp: i64::MAX,
iat: chrono::Utc::now().timestamp(),
nbf: None,
permissions: Some(vec!["memory:write".to_string(), "memory:read".to_string()]),
groups: Some(vec!["test".to_string()]),
roles: None,
};
Ok((claims, "synthetic-token".to_string()))
}
}
}
@@ -256,6 +272,7 @@ pub async fn start_server(port: u16, api_key: String, database_url: &str) -> Res
let auth_mode = match auth_mode.as_str() {
"jwt" => AuthMode::Jwt,
"apikey" => AuthMode::ApiKey,
"none" => AuthMode::None,
_ => {
tracing::warn!("Unknown auth mode: {}, defaulting to apikey", auth_mode);
AuthMode::ApiKey
+28
View File
@@ -0,0 +1,28 @@
apiVersion: ENC[AES256_GCM,data:TZY=,iv:sKXTsB2VO5ZAL6s/xzqcIgwtlNqk0xxOclb6ErYz02Q=,tag:yfK6Ax8mHaYZQVImcrsLcA==,type:str]
kind: ENC[AES256_GCM,data:Xr4rR7y/,iv:edAtbejU0PElYRZyAntlyuj5WnGf+Eksr+c636ovMc8=,tag:Hwv1higF27NzOTk/8EawYw==,type:str]
metadata:
name: ENC[AES256_GCM,data:Oe7W0UZxilfIUCIJRM4xP2sR,iv:w1NOlc20m8NX/WRT4JhXZ1MWjY0sFQa8ZJDeXemrL2M=,tag:cJ5TV8nKYHQhtLEnQa2mwQ==,type:str]
namespace: ENC[AES256_GCM,data:+4jnzJeY,iv:nfooi5BOr9Exx8r5m00HJRSnFYiSofV9/+heWjJNmww=,tag:TYoi+OJK6+1oe8SpyGeEEg==,type:str]
labels:
app.kubernetes.io/name: ENC[AES256_GCM,data:gxlL3o3C3mA9Th9OaQ==,iv:Hw4a9d9xAnX9MOdFkj3jf524I6wgBwPfoVYmXKUQgtU=,tag:9lTd7W1kx/Uv9E0MVMnclA==,type:str]
app.kubernetes.io/component: ENC[AES256_GCM,data:4DePKA==,iv:6f1Pvu+vWI+VkF8YrlSAM7yMvSckHWk+lu3qeMAz/ew=,tag:krszM09nNTo0EMtLJGw6Ew==,type:str]
type: ENC[AES256_GCM,data:Ri5WKSXq,iv:D1APSbaBiSL1FQS3eKQ2Jbl+BZ2EgKjIbpjh4TjRntU=,tag:rdCSkAFBkGn5qCmEZh6KxQ==,type:str]
stringData:
AUTHENTIK_ISSUER: ENC[AES256_GCM,data:LpLo+01McEw9gNwRqq06GgNXxi40QjmGXWKQfPBEw3rJ2vBaNyAbQv82vsFMdnrwUyTEulPsVvWHO9IS6fGip224UA==,iv:EUME2lcjH103kRgfktAnABT+HA5ckJ8FG/N8x/qKv5M=,tag:GhVZYiEFw8tSRUz/hxTROQ==,type:str]
AUTHENTIK_AUDIENCE: ENC[AES256_GCM,data:vhI7n2TG,iv:Q2E3aE6dx6BMqGHBNrEpUFwdEecmP/ZetkOmx5b4RB8=,tag:y+Wj9riWxFbOV+C04CGoJQ==,type:str]
JWT_CACHE_TTL_SECS: ENC[AES256_GCM,data:8ckJPw==,iv:/OL2ke9KSeUZHC2+wtqh7oNoU0YYlkxtbsXhjiCxLsk=,tag:LzPFyzFCXoaLs892/OKHCQ==,type:str]
sops:
age:
- enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlSDFVZWdWZ0tVREV1UWVI
YVJ5eVVZdGcwSzdjREkzbkFLTmpWZi9mRnc0CkJ2Ujh4ZWVLMjFUczIzVmYwWEo4
eGpwZStvY1BYU1FHWEZDV1FhTE4zdWsKLS0tIDRJYmI5UzFVVFRCcCtUM1hYc3d3
S29NczhTb044SzlVWVBlN2paL0hzSEEKo/Q48c7IxhII1QJIwNDgUp7fSnbe2KOa
cnRlDnfN/6+6xTePnu+4uhmCJqHKprdpH/2RPrj51k4psgiOZdBi7w==
-----END AGE ENCRYPTED FILE-----
recipient: age1e5fq3hwxy78psus2nfvmtmua36g0u3suk78ephw6246l974d2utsvn0hla
lastmodified: "2026-09-08T05:17:56Z"
mac: ENC[AES256_GCM,data:ug9mPSxKAr2ZAci0S2DeYRrmaeQJLeC9N4B6fVRjy+pSaul2tfa9v6trTgrCnEI+VCqQMcDtlUQmrBy6CHoxlcHn8inHXMj+56mVAmxv0riHiyQOwtiZGVm1xX5kKA/z2q9tyT13aSPcsoVeuX6BOuwNjHCdAegsSEbZhuzrP4c=,iv:b2XdpqSeZAwNmbtSMwysHlsfPUJJCAN8qScWEj/JF9c=,tag:d2R/sQCFzB7+P2GUJGnHCg==,type:str]
unencrypted_suffix: _unencrypted
version: 3.13.2
+23
View File
@@ -0,0 +1,23 @@
# Non-sensitive environment variables for poimen-memory
# Change these without redeploying secrets.
apiVersion: v1
kind: ConfigMap
metadata:
name: poimen-memory-config
namespace: poimen
labels:
app.kubernetes.io/name: poimen-memory
app.kubernetes.io/component: config
data:
# Auth mode: jwt | apikey
MEM_AUTH_MODE: "none"
# Rate limiting
MEM_RATE_LIMIT_INGEST: "100"
MEM_RATE_LIMIT_QUERY: "1000"
MEM_IDEMPOTENCY_TTL_SECS: "86400"
# Embeddings
MEM_EMBEDDING_BATCH_SIZE: "32"
# OpenSearch
OPENSEARCH_HOST: "opensearch.poimen.svc.cluster.local:9200"
# Obsidian
OBSIDIAN_URL: "http://obsidian-server.poimen.svc.cluster.local:8080"
+6 -1
View File
@@ -66,11 +66,16 @@ spec:
secretKeyRef:
name: poimen-memory-secrets
key: llm-api-key
# Server config
# Server config (from ConfigMap)
- name: MEM_PORT
value: "8080"
- name: MEM_HOME
value: "/tmp"
envFrom:
- configMapRef:
name: poimen-memory-config
- secretRef:
name: poimen-memory-auth
args:
- serve
- --port
+4 -1
View File
@@ -5,6 +5,9 @@ resources:
# vault-pvc.yaml removed — memory service uses pgvector, not local storage
- deployment.yaml
- service.yaml
- config.yaml
- obsidian.yaml
# Secret managed separately (SealedSecret in homelab)
# Legacy secret managed separately
# - secrets.yaml
generators:
- secret-generator.yaml
+2 -2
View File
@@ -53,11 +53,11 @@ data:
subject_key: "sub"
# JWKS endpoint from Authentik
jwks_uri: "https://authentik.riotpiao.com/application/o/poimen-memory/jwks/"
jwks_uri: "https://authentik.riotpiao.com/application/o/poimen/jwks/"
jwks_refresh_interval_ms: 3600000 # 1 hour
# Issuer validation
issuer: "https://authentik.riotpiao.com/application/o/poimen-memory/"
issuer: "https://authentik.riotpiao.com/application/o/poimen/"
audience: null
# Claims mapping
+11
View File
@@ -0,0 +1,11 @@
# KSOPS generator — ArgoCD decrypts auth.enc.yaml at sync time
apiVersion: viaduct.ai/v1
kind: ksops
metadata:
name: poimen-memory-auth-generator
annotations:
config.kubernetes.io/function: |
exec:
path: ksops
files:
- auth.enc.yaml