Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]Error Ocurred when attempting gmail oauth2 setup #1021

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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