ownCloud module for single logon with Amahi

User avatar
cpg
Administrator
Posts: 2604
Joined: Wed Dec 03, 2008 7:40 am
Contact:

ownCloud module for single logon with Amahi

Postby cpg » Tue Sep 18, 2012 2:08 pm

[update]

it's an ownCloud app now: https://github.com/tomneedham/Playgroun ... ster/amahi

---

Hi, here is a module written for single logon of ownCloud with Amahi, written by user Tom Neeham.

Anyone available to test it?

There are some open issues:
  • what to name the file with this content
  • exactly where to put this file, relative to an amahi-installed owncloud setup
  • adjusting it to make it work!
-c

Code: Select all

<?php /** * ownCloud * * @author Tom Needham * @copyright 2012 Tom Needham tom@owncloud.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library 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 AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ /** * Class for user authentication against an Amahi install */ class OC_User_Amahi extends OC_User_Backend { const HOSTNAME = 'localhost'; const USERNAME = 'amahihda'; const PASSWORD = 'AmahiHDARulez'; const DATABASE = 'hda_production'; self::init = false; private function init(){ if(!self::$init){ // Make the database connection $conn = mysql_connect(HOSTNAME, USERNAME, PASSWORD); mysql_select_db(DATABASE); } } private function encrypt($password, $salt) { $digest = $password . $salt; for ( $i = 0; $i < 20; $i++ ) $digest = hash("sha512", $digest); return $digest; } /** * @brief Check if the password is correct * @param $uid The username * @param $password The password * @returns string * * Check if the password is correct without logging in the user * returns the user id or false */ public function checkPassword( $uid, $password ) { $this->init(); $sql = "SELECT password_salt, crypted_password FROM users WHERE login = '$uid'"; $results = mysql_query($sql); $user = mysql_fetch_assoc(); $user = $user[0]; $password = $this->encrypt($password, $user['password_salt']); return ($password==$user['password']); } /** * @brief Get a list of all users * @returns array with all uids * * Get a list of all users. */ public function getUsers($search = '', $limit = null, $offset = null) { $this->init(); $sql = "SELECT * FROM users"; $results = mysql_query($sql); $users= mysql_fetch_assoc(); return $users; } /** * @brief check if a user exists * @param string $uid the username * @return boolean */ public function userExists($uid) { $this->init(); $sql = "SELECT * FROM users WHERE login=$uid"; $results = mysql_query($sql); return mysql_num_rows($results); } }
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1

User avatar
bigfoot65
Project Manager
Posts: 11419
Joined: Mon May 25, 2009 4:31 pm

Re: ownCloud module for single logon with Amahi

Postby bigfoot65 » Tue Sep 18, 2012 6:18 pm

Cool. So does this mean with ownCloud installed the Dashboard login will automatically log into the app as well or just that the Amahi users will be ownCloud users?
ßîgƒσστ65
Applications Manager

User avatar
cpg
Administrator
Posts: 2604
Joined: Wed Dec 03, 2008 7:40 am
Contact:

Re: ownCloud module for single logon with Amahi

Postby cpg » Tue Sep 18, 2012 6:28 pm

Good question. It means when someone tries to login in the ownCloud app they can use the credentials from the dashboard.

No automatic login, tho.
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1

Who is online

Users browsing this forum: No registered users and 1 guest