Skip to content

Commit db626c1

Browse files
committed
feat: add configurable auth cookie lifetime and httpOnly setting
1 parent 1446f3b commit db626c1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ ENV PREFETCH_FILES=false
126126

127127
ENV CORS_ALLOW_ANY_ORIGIN=true
128128

129+
# seconds. default 60 * 60 * 24 * 7 = 7 days
130+
ENV AUTH_COOKIE_LIFETIME=604800
131+
132+
ENV AUTH_COOKIE_HTTPONLY=true
133+
129134
EXPOSE 8080
130135

131136
CMD ["/init.sh"]

src/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ function set_auth_cookie(string $key): void
8181
if ($path === '') $path = '/';
8282
// Cookie is httpOnly to avoid leaking via JS.
8383
setcookie('dir_browser_key', $key, [
84-
'expires' => time() + 60 * 60 * 24 * 30,
84+
'expires' => time() + ${{`process.env.AUTH_COOKIE_LIFETIME`}}$,
8585
'path' => $path,
8686
'secure' => $secure,
87-
'httponly' => true,
87+
'httponly' => ${{`process.env.AUTH_COOKIE_HTTPONLY`}}$,
8888
'samesite' => 'Lax',
8989
]);
9090
}

0 commit comments

Comments
 (0)