summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-05-27 11:46:42 -0400
committerFreya Murphy <freya@freyacat.org>2024-05-27 11:46:42 -0400
commit928267287df532a6e8fb0775e3138ee21f2173f5 (patch)
treeb47ccfe7694784d9632abff25f108ce1d60a4b3b
parentaaa (diff)
downloadldap_forwardauth-928267287df532a6e8fb0775e3138ee21f2173f5.tar.gz
ldap_forwardauth-928267287df532a6e8fb0775e3138ee21f2173f5.tar.bz2
ldap_forwardauth-928267287df532a6e8fb0775e3138ee21f2173f5.zip
fix cookies
-rw-r--r--.gitignore1
-rw-r--r--conf/ldap/ldap.env1
-rw-r--r--src/web/helpers/auth.php13
3 files changed, 10 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 0b12f2d..1269488 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
data
-conf/ldap/ldap.env
diff --git a/conf/ldap/ldap.env b/conf/ldap/ldap.env
index f387147..29f55c0 100644
--- a/conf/ldap/ldap.env
+++ b/conf/ldap/ldap.env
@@ -7,3 +7,4 @@ LDAP_FILTER="(&)"
LDAP_UID="cn"
HTTP_HOST=auth.example.com
+COOKIE_DOMAIN=example.com
diff --git a/src/web/helpers/auth.php b/src/web/helpers/auth.php
index 3ff1e71..9228706 100644
--- a/src/web/helpers/auth.php
+++ b/src/web/helpers/auth.php
@@ -13,13 +13,18 @@ function get_cookie() {
function store_cookie($key) {
$cookie_name = 'X-LDAP-Auth-Key';
+ $cookie_options = array (
+ 'expires' => time() + 60*60*24*30,
+ 'path' => '/',
+ 'domain' => getenv("COOKIE_DOMAIN"),
+ 'secure' => true,
+ 'httponly' => true,
+ 'samesite' => 'None'
+ );
setcookie(
$cookie_name,
$key,
- time() + (86400 * 30),
- "/",
- TRUE,
- TRUE
+ $cookie_options
);
}