diff options
author | F. Kooman <fkooman@tuxed.net> | 2012-10-29 14:47:34 +0400 |
---|---|---|
committer | F. Kooman <fkooman@tuxed.net> | 2012-10-29 14:47:34 +0400 |
commit | 4c9749d15964570d2831addb2ba62a7a948d446c (patch) | |
tree | f9ae8cd6a3da91a29977a1b23ae045374470e37d /user_oauth | |
parent | ebf3a1840c5a350c181728412ae98499fe1edb87 (diff) |
by default use resourceOwnerId for user_id
Diffstat (limited to 'user_oauth')
-rw-r--r-- | user_oauth/oauth.php | 17 | ||||
-rw-r--r-- | user_oauth/remote.php | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/user_oauth/oauth.php b/user_oauth/oauth.php index 8230709b6..5544a059d 100644 --- a/user_oauth/oauth.php +++ b/user_oauth/oauth.php @@ -6,9 +6,13 @@ class OC_Connector_Sabre_OAuth implements Sabre_DAV_Auth_IBackend { private $currentUser; private $tokenInfoEndpoint; + private $useResourceOwnerId; + private $userIdAttributeName; - public function __construct($tokenInfoEndpoint) { + public function __construct($tokenInfoEndpoint, $useResourceOwnerId = TRUE, $userIdAttributeName = "uid") { $this->tokenInfoEndpoint = $tokenInfoEndpoint; + $this->useResourceOwnerId = $useResourceOwnerId; + $this->userIdAttributeName = $userIdAttributeName; } public function getCurrentUser() { @@ -34,9 +38,16 @@ class OC_Connector_Sabre_OAuth implements Sabre_DAV_Auth_IBackend { $resourceServer = new RemoteResourceServer($config); $resourceServer->verifyAuthorizationHeader($authorizationHeader); - $attributes = $resourceServer->getAttributes(); - $this->currentUser = $attributes["uid"][0]; + if($this->useResourceOwnerId) { + // when using the user_id + $this->currentUser = $resourceServer->getResourceOwnerId(); + } else { + // when using a (SAML) attribute + $attributes = $resourceServer->getAttributes(); + $this->currentUser = $attributes[$this->userIdAttributeName][0]; + } + OC_Util::setupFS($this->currentUser); return true; diff --git a/user_oauth/remote.php b/user_oauth/remote.php index c598ecfab..f0f0075e2 100644 --- a/user_oauth/remote.php +++ b/user_oauth/remote.php @@ -27,11 +27,13 @@ $RUNTIME_APPTYPES=array('filesystem','authentication'); OC_App::loadApps($RUNTIME_APPTYPES); $tokenInfoEndpoint = \OC_Config::getValue( "tokenInfoEndpoint", "https://www.googleapis.com/oauth2/v1/tokeninfo" ); +$useResourceOwnerId = TRUE; // FIXME: take this from configuration instead +$userIdAttributeName = "uid"; // FIXME: take this from configuration instead require_once "oauth.php"; // Backends -$authBackend = new OC_Connector_Sabre_OAuth($tokenInfoEndpoint); +$authBackend = new OC_Connector_Sabre_OAuth($tokenInfoEndpoint, $useResourceOwnerId, $userIdAttributeName); $lockBackend = new OC_Connector_Sabre_Locks(); // Create ownCloud Dir |