From e27d393165e184f76a3e72562758f09985984a76 Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Wed, 12 Nov 2025 16:17:04 -0500 Subject: [PATCH] PREAUTH_SEND_TO environment variable, to set a default redirection after authenticating --- example.env | 3 ++- src/Auth.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example.env b/example.env index a749928..4e2ae52 100644 --- a/example.env +++ b/example.env @@ -4,10 +4,11 @@ PREAUTH_KEY='' # TOTP (RFC 6238) secret/token (static random bytes) in base32 PREAUTH_TOKEN='' -# optional, change time-to-live, subdomain, text or colors +# optional, change time-to-live, subdomain, default-redirect, text or colors # how long a session lasts (in minutes): 43200 is 30 days PREAUTH_TTL=43200 PREAUTH_SUBDOMAIN='preauth' +PREAUTH_SEND_TO='https://secure.example.com/' PREAUTH_BACKGROUND='#029386' PREAUTH_FOREGROUND='#ffffff' PREAUTH_TITLE='Pre-Authentication System' diff --git a/src/Auth.php b/src/Auth.php index 166167e..0efa392 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -107,6 +107,8 @@ class Auth { if ($this->login()) { if (isset($this->get['rt'])) { header("Location: {$this->get['rt']}"); + } else if (getenv('PREAUTH_SEND_TO')) { + header("Location: " . getenv('PREAUTH_SEND_TO')); } echo "ok $this->id"; return;