From 7aba73396120acd62814081a19ec9e76a0138e34 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 26 Apr 2011 00:08:59 +1000 Subject: [PATCH] Enabled cookie as a valid auth_type --- lib/HTMLTree.php | 1 + lib/ds.php | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php index 07d3d27..506b938 100644 --- a/lib/HTMLTree.php +++ b/lib/HTMLTree.php @@ -126,6 +126,7 @@ class HTMLTree extends Tree { # We are not logged in, draw a login... link. } else { switch ($server->getAuthType()) { + case 'cookie': case 'http': case 'session': $this->draw_login_link(); diff --git a/lib/ds.php b/lib/ds.php index 1f626f4..9bd9f2b 100644 --- a/lib/ds.php +++ b/lib/ds.php @@ -133,6 +133,7 @@ abstract class DS { debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); switch ($this->getValue('login','auth_type')) { + case 'cookie': case 'config': case 'http': case 'proxy': @@ -165,6 +166,13 @@ abstract class DS { return null; switch ($this->getAuthType()) { + case 'cookie': + if (! isset($_COOKIE[$method.'-USER'])) + # If our bind_id is set, we'll pass that back for logins. + return (! is_null($this->getValue('login','bind_id')) && $method == 'login') ? $this->getValue('login','bind_id') : null; + else + return blowfish_decrypt($_COOKIE[$method.'-USER']); + case 'config': if (! isset($_SESSION['USER'][$this->index][$method]['name'])) return $this->getValue('login','bind_id'); @@ -201,6 +209,11 @@ abstract class DS { $method = $this->getMethod($method); switch ($this->getAuthType()) { + case 'cookie': + set_cookie($method.'-USER',blowfish_encrypt($user),NULL,'/'); + set_cookie($method.'-PASS',blowfish_encrypt($pass),NULL,'/'); + return TRUE; + case 'config': return true; @@ -238,6 +251,13 @@ abstract class DS { return null; switch ($this->getAuthType()) { + case 'cookie': + if (! isset($_COOKIE[$method.'-PASS'])) + # If our bind_id is set, we'll pass that back for logins. + return (! is_null($this->getValue('login','bind_pass')) && $method == 'login') ? $this->getValue('login','bind_pass') : null; + else + return blowfish_decrypt($_COOKIE[$method.'-PASS']); + case 'config': case 'proxy': if (! isset($_SESSION['USER'][$this->index][$method]['pass'])) @@ -375,6 +395,10 @@ abstract class DS { unset ($_SESSION['cache'][$this->index]); switch ($this->getAuthType()) { + case 'cookie': + set_cookie($method.'-USER','',time()-3600,'/'); + set_cookie($method.'-PASS','',time()-3600,'/'); + case 'config': return true;