From fdc2cd755477220c027e026aa70594af87427bed Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 27 Apr 2016 09:38:30 +0200 Subject: Add token auth for OCS APIs --- lib/private/Authentication/Token/DefaultTokenProvider.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/private/Authentication/Token/DefaultTokenProvider.php') diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index a4e44f3c5d2..97567e53cd0 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -83,7 +83,11 @@ class DefaultTokenProvider implements IProvider { * * @param DefaultToken $token */ - public function updateToken(DefaultToken $token) { + public function updateToken(IToken $token) { + if (!($token instanceof DefaultToken)) { + throw new InvalidTokenException(); + } + /** @var DefaultToken $token */ $token->setLastActivity(time()); $this->mapper->update($token); @@ -130,14 +134,14 @@ class DefaultTokenProvider implements IProvider { /** * @param string $token * @throws InvalidTokenException - * @return string user UID + * @return IToken user UID */ public function validateToken($token) { $this->logger->debug('validating default token <' . $token . '>'); try { $dbToken = $this->mapper->getToken($this->hashToken($token)); $this->logger->debug('valid token for ' . $dbToken->getUid()); - return $dbToken->getUid(); + return $dbToken; } catch (DoesNotExistException $ex) { $this->logger->warning('invalid token'); throw new InvalidTokenException(); -- cgit v1.2.3