[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11052] controller: fix css
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11052] controller: fix css |
Date: |
Wed, 10 Apr 2013 13:58:21 +0000 |
Revision: 11052
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11052
Author: sigurdne
Date: 2013-04-10 13:58:21 +0000 (Wed, 10 Apr 2013)
Log Message:
-----------
controller: fix css
Modified Paths:
--------------
trunk/mobilefrontend/templates/base/config.tpl
trunk/phpgwapi/inc/class.login.inc.php
trunk/phpgwapi/inc/class.ofphpgwapi.inc.php
Added Paths:
-----------
trunk/phpgwapi/inc/auth/class.auth_custom_sso.inc.php
Modified: trunk/mobilefrontend/templates/base/config.tpl
===================================================================
--- trunk/mobilefrontend/templates/base/config.tpl 2013-04-10 13:53:25 UTC
(rev 11051)
+++ trunk/mobilefrontend/templates/base/config.tpl 2013-04-10 13:58:21 UTC
(rev 11052)
@@ -18,7 +18,7 @@
<select name="newsettings[auth_type]">
<option value="0"
{selected_auth_type_0}>Same as framework</option>
<option value="sql"
{selected_auth_type_sql}>SQL</option>
- <option value="custom"
{selected_auth_type_custom}>Custom</option>
+ <option value="custom_sso"
{selected_auth_type_custom_sso}>Custom SSO</option>
</select>
</td>
</tr>
Added: trunk/phpgwapi/inc/auth/class.auth_custom_sso.inc.php
===================================================================
--- trunk/phpgwapi/inc/auth/class.auth_custom_sso.inc.php
(rev 0)
+++ trunk/phpgwapi/inc/auth/class.auth_custom_sso.inc.php 2013-04-10
13:58:21 UTC (rev 11052)
@@ -0,0 +1,174 @@
+<?php
+ /**
+ * Authentication based on SQL table
+ * @author Dan Kuykendall <address@hidden>
+ * @author Joseph Engo <address@hidden>
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2013 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
+ * @package phpgwapi
+ * @subpackage accounts
+ * @version $Id: class.auth_custom_sso.inc.php 10127 2012-10-07
17:06:01Z sigurdne $
+ */
+
+ /*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /**
+ * Authentication based on SQL table
+ *
+ * @package phpgwapi
+ * @subpackage accounts
+ */
+ class phpgwapi_auth_custom_sso extends phpgwapi_auth_
+ {
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Authenticate a user based on SSO
+ *
+ * @param string $username the login to authenticate
+ * @param string $passwd the password supplied by the user
+ * @return bool did the user sucessfully authenticate
+ */
+ public function authenticate($username, $passwd='')
+ {
+ $username =
$GLOBALS['phpgw']->db->db_addslashes($username);
+
+ $sql = 'SELECT account_pwd FROM phpgw_accounts'
+ . " WHERE account_lid = '{$username}'"
+ . " AND account_status = 'A'";
+
+ $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+ return !!$GLOBALS['phpgw']->db->next_record();
+ }
+
+ /* php ping function
+ */
+ private function ping($host)
+ {
+ exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res,
$rval);
+ return $rval === 0;
+ }
+
+ public function get_username()
+ {
+ $config = CreateObject('phpgwapi.config','rental');
+ $config->read();
+
+ if(! $config->config_data['external_db_host'] ||
!$this->ping($config->config_data['external_db_host']))
+ {
+ $message ="Database server
{$config->config_data['external_db_host']} is not accessible";
+ phpgwapi_cache::message_set($message, 'error');
+ return false;
+ }
+
+ $db = createObject('phpgwapi.db', null, null, true);
+
+ $db->debug =
!!$config->config_data['external_db_debug'];
+ $db->Host = $config->config_data['external_db_host'];
+ $db->Port = $config->config_data['external_db_port'];
+ $db->Type = $config->config_data['external_db_type'];
+ $db->Database =
$config->config_data['external_db_name'];
+ $db->User = $config->config_data['external_db_user'];
+ $db->Password =
$config->config_data['external_db_password'];
+
+ try
+ {
+ $db->connect();
+ }
+ catch(Exception $e)
+ {
+ $message =
lang('unable_to_connect_to_database');
+ phpgwapi_cache::message_set($message, 'error');
+ return false;
+ }
+
+ $headers = getallheaders();
+ $fodsels_nr = substr($headers['Osso-User-Dn'],2, 11);
+
+ $sql = "SELECT V_ORG_PERSON.BRUKERNAVN FROM
V_ORG_PERSON WHERE FODSELSNR ='{$fodsels_nr}'";
+ $db->query($sql,__LINE__,__FILE__);
+ $db->next_record();
+ return $db->f('BRUKERNAVN',true);
+ }
+
+ /**
+ * Set the user's password to a new value
+ *
+ * @param string $old_passwd the user's old password
+ * @param string $new_passwd the user's new password
+ * @param int $account_id the account to change the password for
- defaults to current user
+ * @return string the new encrypted hash, or an empty string on
failure
+ */
+ public function change_password($old_passwd, $new_passwd,
$account_id = 0)
+ {
+ $account_id = (int) $account_id;
+ // Don't allow passwords changes for other accounts
when using XML-RPC
+ if ( !$account_id )
+ {
+ $account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ if ( $GLOBALS['phpgw_info']['flags']['currentapp'] ==
'login')
+ {
+ if (
!$this->authenticate($GLOBALS['phpgw']->accounts->id2lid($account_id),
$old_passwd) )
+ {
+ return '';
+ }
+ }
+
+ $hash = $this->create_hash($new_passwd);
+ $hash_safe =
$GLOBALS['phpgw']->db->db_addslashes($hash); // just to be safe :)
+ $now = time();
+
+ $sql = 'UPDATE phpgw_accounts'
+ . " SET account_pwd = '{$hash_safe}',
account_lastpwd_change = {$now}"
+ . " WHERE account_id = {$account_id}";
+
+ if ( !!$GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__) )
+ {
+ return $hash;
+ }
+ return '';
+ }
+
+ /**
+ * Update when the user last logged in
+ *
+ * @param int $account_id the user's account id
+ * @param string $ip the source IP adddress for the request
+ */
+ public function update_lastlogin($account_id, $ip)
+ {
+ $ip = $GLOBALS['phpgw']->db->db_addslashes($ip);
+ $account_id = (int) $account_id;
+ $now = time();
+
+ $sql = 'UPDATE phpgw_accounts'
+ . " SET account_lastloginfrom = '{$ip}',"
+ . " account_lastlogin = {$now}"
+ . " WHERE account_id = {$account_id}";
+
+ $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+ }
+ }
Modified: trunk/phpgwapi/inc/class.login.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.login.inc.php 2013-04-10 13:53:25 UTC (rev
11051)
+++ trunk/phpgwapi/inc/class.login.inc.php 2013-04-10 13:58:21 UTC (rev
11052)
@@ -161,7 +161,7 @@
$extra_vars['cd'] = 'yes';
$GLOBALS['phpgw']->hooks->process('login');
- $GLOBALS['phpgw']->redirect_link('/home.php',
$extra_vars);
+
$GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars);
//----------------- End login ntlm
}
@@ -199,6 +199,47 @@
unset($sslattributes);
}
+ if ($GLOBALS['phpgw_info']['server']['auth_type'] ==
'custom_sso' && !isset($_GET['cd']))
+ {
+ //Reset auth object
+ $GLOBALS['phpgw']->auth =
createObject('phpgwapi.auth');
+ $login =
$GLOBALS['phpgw']->auth->get_username();
+
+ $GLOBALS['sessionid'] =
$GLOBALS['phpgw']->session->create($login, '');
+
+ if (!isset($GLOBALS['sessionid']) ||
!$GLOBALS['sessionid'])
+ {
+ $cd_array = array();
+ if
($GLOBALS['phpgw']->session->cd_reason)
+ {
+ $cd_array['cd']
= $GLOBALS['phpgw']->session->cd_reason;
+ }
+ $cd_array['skip_remote'] = true;
+
+
$GLOBALS['phpgw']->redirect_link("/{$partial_url}", $cd_array);
+ exit;
+ }
+
+ $forward = phpgw::get_var('phpgw_forward');
+ if ($forward)
+ {
+ $extra_vars['phpgw_forward'] = $forward;
+ foreach ($_GET as $name => $value)
+ {
+ if (ereg('phpgw_', $name))
+ {
+ $name
= urlencode($name);
+ $extra_vars[$name]
= urlencode($value);
+ }
+ }
+ }
+
+ $extra_vars['cd'] = 'yes';
+
+ $GLOBALS['phpgw']->hooks->process('login');
+
$GLOBALS['phpgw']->redirect_link("{$frontend}/home.php", $extra_vars);
+ }
+
if ((isset($_POST['submitit']) ||
isset($_POST['submit_x']) || isset($_POST['submit_y'])))
{
if ($_SERVER['REQUEST_METHOD'] != 'POST' &&
@@ -230,13 +271,7 @@
$receipt[] = lang('Info: you
have changed domain from "%1" to "%2"', $_COOKIE['domain'], $logindomain);
}
}
-/*
-unset($GLOBALS['phpgw']->auth);
-$GLOBALS['phpgw']->auth = createObject('phpgwapi.auth');
-_debug_array($GLOBALS['phpgw']->auth);die();
-//_debug_array($GLOBALS['phpgw_info']['server']);die();
-*/
$GLOBALS['sessionid'] =
$GLOBALS['phpgw']->session->create($login, $passwd);
if (!isset($GLOBALS['sessionid']) ||
!$GLOBALS['sessionid'])
Modified: trunk/phpgwapi/inc/class.ofphpgwapi.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.ofphpgwapi.inc.php 2013-04-10 13:53:25 UTC (rev
11051)
+++ trunk/phpgwapi/inc/class.ofphpgwapi.inc.php 2013-04-10 13:58:21 UTC (rev
11052)
@@ -109,6 +109,7 @@
case 'ldap':
case 'mail':
// case 'nis': - doesn't currently work AFAIK -
skwashd may08
+ case 'custom_sso':
case 'ntlm':
case 'remoteuser':
case 'sql':
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11052] controller: fix css,
Sigurd Nes <=