Skip to content

Commit

Permalink
Merge pull request #1021 from christer77/Error-Ocurred-when-attemptin…
Browse files Browse the repository at this point in the history
…g-gmail-oauth2-setup

[FIX]Error Ocurred when attempting gmail oauth2 setup
  • Loading branch information
kroky authored May 15, 2024
2 parents 84317f0 + 92f66b7 commit 054e60d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Hm_Functions {
* @param string $value
* @return boolean
*/
public static function setcookie($name, $value, $lifetime = 0, $path = '', $domain = '', $secure = false, $html_only = false) {
public static function setcookie($name, $value, $lifetime = 0, $path = '', $domain = '', $secure = false, $html_only = false, $same_site = 'Strict') {
$prefix = ($lifetime != 0 && $lifetime < time()) ? 'Deleting' : 'Setting';
Hm_Debug::add(sprintf('%s cookie: name: %s, lifetime: %s, path: %s, domain: %s, secure: %s, html_only %s',$prefix, $name, $lifetime, $path, $domain, $secure, $html_only));
if (version_compare(PHP_VERSION, '7.3', '>=')) {
Expand All @@ -76,7 +76,7 @@ public static function setcookie($name, $value, $lifetime = 0, $path = '', $doma
'domain' => $domain,
'secure' => $secure,
'httponly' => $html_only,
'samesite' => 'Strict'
'samesite' => $same_site
]
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/ini_set.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* limit session cookie to HTTP only */
ini_set('session.cookie_httponly', 1);
if (version_compare(PHP_VERSION, 7.3, '>=')) {
ini_set('session.cookie_samesite', 'Strict');
ini_set('session.cookie_samesite', 'Lax');
}

/* HTTPS required for session cookie */
Expand Down
6 changes: 3 additions & 3 deletions lib/session_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function plaintext($data) {
*/
protected function set_key($request) {
$this->enc_key = Hm_Crypt::unique_id();
$this->secure_cookie($request, 'hm_id', $this->enc_key);
$this->secure_cookie($request, 'hm_id', $this->enc_key, '', '', 'Lax');
}

/**
Expand Down Expand Up @@ -329,9 +329,9 @@ private function cookie_path($request) {
* @param string $domain cookie domain
* @return boolean
*/
public function secure_cookie($request, $name, $value, $path='', $domain='') {
public function secure_cookie($request, $name, $value, $path='', $domain='', $same_site = 'Strict') {
list($path, $domain, $html_only) = $this->prep_cookie_params($request, $name, $path, $domain);
return Hm_Functions::setcookie($name, $value, $this->lifetime, $path, $domain, $request->tls, $html_only);
return Hm_Functions::setcookie($name, $value, $this->lifetime, $path, $domain, $request->tls, $html_only, $same_site);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/api_login/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function process() {
return;
}
list($secure, $path, $domain) = $this->session->set_session_params($this->request);
Hm_Functions::setcookie('hm_id', stripslashes($form['hm_id']), 0, $path, $domain, $secure, true);
Hm_Functions::setcookie('hm_session', stripslashes($form['hm_session']), 0, $path, $domain, $secure, true);
Hm_Functions::setcookie('hm_id', stripslashes($form['hm_id']), 0, $path, $domain, $secure, true, 'Lax');
Hm_Functions::setcookie('hm_session', stripslashes($form['hm_session']), 0, $path, $domain, $secure, true, 'Lax');
Hm_Dispatch::page_redirect('?page=home');
}
}
Expand Down

0 comments on commit 054e60d

Please sign in to comment.