-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Kronolith-specific caldav_url hook with global davusername hook.
It's much simpler, sufficient for the most use cases, and has the big advantage that we can translate the user names back too. The other DAV APIs beside Kronolith's CalDAV API still need to be updated to use this hook. I wonder if we should generalize it even further to a "rpcusername" hook, because any RPC request suffers from the problem that users cannot select an authentication backend (IMAP server), which is what this hook is trying to solve.
- Loading branch information
Showing
16 changed files
with
236 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Copyright 2016 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @author Jan Schneider <jan@horde.org> | ||
* @category Horde | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Core | ||
*/ | ||
|
||
/** | ||
* Extends Horde's authentication backend for Sabre to support username hooks. | ||
* | ||
* @author Jan Schneider <jan@horde.org> | ||
* @category Horde | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Core | ||
*/ | ||
class Horde_Core_Dav_Auth extends Horde_Dav_Auth | ||
{ | ||
/** | ||
* Returns information about the currently logged in username. | ||
* | ||
* If nobody is currently logged in, this method should return null. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getCurrentUser() | ||
{ | ||
$user = $this->_auth->getCredential('userId'); | ||
try { | ||
$user = $GLOBALS['injector']->getInstance('Horde_Core_Hooks') | ||
->callHook('davusername', 'horde', array($user, false)); | ||
} catch (Horde_Exception_HookNotSet $e) { | ||
} | ||
return $user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
framework/Core/lib/Horde/Core/Factory/Identity/DavUsernameHook.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Copyright 2016 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @package Core | ||
* @author Jan Schneider <jan@horde.org> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
|
||
/** | ||
* A Horde_Injector based Horde_Identity factory that converts the user name | ||
* through the davusername hook. | ||
* | ||
* @category Horde | ||
* @package Core | ||
* @author Jan Schneider <jan@horde.org> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
class Horde_Core_Factory_Identity_DavUsernameHook extends Horde_Core_Factory_Identity_UsernameHook | ||
{ | ||
/** | ||
* Returns the Horde_Identity instance. | ||
* | ||
* @param string $user The user to use, if not the current user. | ||
* @param string $driver The identity driver. Either empty (use default | ||
* driver) or an application name. | ||
* | ||
* @return Horde_Identity The singleton identity instance. | ||
* @throws Horde_Exception | ||
*/ | ||
public function create($user = null, $driver = null) | ||
{ | ||
try { | ||
$user = $this->_injector->getInstance('Horde_Core_Hooks') | ||
->callHook('davusername', 'horde', array($user, true)); | ||
} catch (Horde_Exception_HookNotSet $e) { | ||
} | ||
return parent::create($user, $driver); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.