@@ -10,25 +10,16 @@ const OAUTH2_PROXY_MIRROR_IMAGE =
1010const OAUTH2_PROXY_FALLBACK_IMAGE =
1111 "quay.io/oauth2-proxy/oauth2-proxy:v7.15.2@sha256:aa0bd8dd5ab0c78e4c91c92755ad573a5f92241f88138b4141b8ec803463b4fd" ;
1212
13- const LOGTO_REDIRECT_CONDITION =
14- "{% if (terrarium_idp_provider_effective | default(terrarium_idp_provider | default('', true), true) | string | trim | lower) != 'logto' %}" ;
15- const RELATIVE_REDIRECT_BLOCK = 'redirect_url = "/oauth2/callback"\nrelative_redirect_url = true\n' ;
16- const CONDITIONAL_RELATIVE_REDIRECT_BLOCK = `${ LOGTO_REDIRECT_CONDITION } \n${ RELATIVE_REDIRECT_BLOCK } {% endif %}\n` ;
17-
1813function oauth2ProxyTemplate ( ) {
1914 return readFileSync ( join ( import . meta. dir , "../ansible/roles/oauth2_proxy/templates/oauth2-proxy.cfg.j2" ) , "utf8" ) ;
2015}
2116
22- function renderOauth2ProxyTemplate ( provider : string ) {
23- const replacement = provider . trim ( ) . toLowerCase ( ) === "logto" ? "" : RELATIVE_REDIRECT_BLOCK ;
24- return oauth2ProxyTemplate ( ) . replace ( CONDITIONAL_RELATIVE_REDIRECT_BLOCK , replacement ) ;
25- }
26-
2717describe ( "management oauth2-proxy template" , ( ) => {
2818 test ( "uses host-only cookies for management hosts" , ( ) => {
2919 const template = oauth2ProxyTemplate ( ) ;
3020
31- expect ( template ) . toContain ( CONDITIONAL_RELATIVE_REDIRECT_BLOCK ) ;
21+ expect ( template ) . not . toContain ( 'redirect_url = "/oauth2/callback"' ) ;
22+ expect ( template ) . not . toContain ( "relative_redirect_url = true" ) ;
3223 expect ( template ) . toContain ( 'cookie_name = "__Host-terrarium_admin_oauth2_proxy"' ) ;
3324 expect ( template ) . toContain ( 'cookie_path = "/"' ) ;
3425 expect ( template ) . toContain ( 'whitelist_domains = [ "{{ terrarium_manage_domain }}", "{{ terrarium_proxy_domain }}" ]' ) ;
@@ -40,15 +31,12 @@ describe("management oauth2-proxy template", () => {
4031 expect ( template ) . not . toContain ( "terrarium_oauth2_proxy_cookie_domain" ) ;
4132 } ) ;
4233
43- test ( "omits relative redirect settings for Logto while preserving other providers" , ( ) => {
44- const logtoConfig = renderOauth2ProxyTemplate ( "logto" ) ;
45- const zitadelConfig = renderOauth2ProxyTemplate ( "zitadel" ) ;
46- const genericConfig = renderOauth2ProxyTemplate ( "generic" ) ;
34+ test ( "lets oauth2-proxy derive an absolute callback URL from reverse-proxy headers" , ( ) => {
35+ const template = oauth2ProxyTemplate ( ) ;
4736
48- expect ( logtoConfig ) . not . toContain ( 'redirect_url = "/oauth2/callback"' ) ;
49- expect ( logtoConfig ) . not . toContain ( "relative_redirect_url = true" ) ;
50- expect ( zitadelConfig ) . toContain ( RELATIVE_REDIRECT_BLOCK ) ;
51- expect ( genericConfig ) . toContain ( RELATIVE_REDIRECT_BLOCK ) ;
37+ expect ( template ) . not . toContain ( 'redirect_url = "/oauth2/callback"' ) ;
38+ expect ( template ) . not . toContain ( "relative_redirect_url = true" ) ;
39+ expect ( template ) . toContain ( "reverse_proxy = true" ) ;
5240 } ) ;
5341
5442 test ( "uses provider-aware OIDC claim and scope variables" , ( ) => {
0 commit comments