Пример #1
0
 def _checkParams(self, params):
     try:
         RHOAuth._checkParams(self, params)
         base.RHProtected._checkParams(self, params)
         request_token_key = self._oauth_request.get_parameter('oauth_token')
         if not TempRequestTokenHolder().hasKey(request_token_key):
             raise OAuthError("Invalid Token", 401)
         self._request_token = TempRequestTokenHolder().getById(request_token_key)
         if not ConsumerHolder().getById(self._request_token.getConsumer().getId()):
             raise OAuthError("Invalid Consumer Key", 401)
     except oauth.Error, err:
         raise OAuthError(err.message, 401)
Пример #2
0
 def _process(self):
     user = self.getAW().getUser()
     old_request_token = self._checkThirdPartyAuthPermissible(
         self._request_token.getConsumer().getName(), user.getId())
     TempRequestTokenHolder().remove(self._request_token)
     self._request_token.setUser(user)
     if old_request_token is not None:
         self._request_token.setAuthorized(old_request_token.isAuthorized())
         RequestTokenHolder().update(old_request_token, self._request_token)
     else:
         RequestTokenHolder().add(self._request_token)
     if not self._request_token.getConsumer().isTrusted(
     ) and not self._request_token.isAuthorized():
         redirectURL = UHOAuthThirdPartyAuth.getURL()
         redirectURL.addParams({
             'callback':
             self._request_token.getToken().get_callback_url(),
             #'returnURL': str(urlHandlers.UHOAuthAuthorizeConsumer.getURL()),
             'third_party_app':
             self._request_token.getConsumer().getName()
         })
         self._redirect(redirectURL)
         return
     verifier = OAuthUtils.gen_random_string()
     self._request_token.getToken().set_verifier(verifier)
     self._request_token._p_changed = 1
     self._redirect(self._request_token.getToken().get_callback_url())
Пример #3
0
 def _process(self):
     # TODO: Token should have flag authorized=False
     token = oauth.Token(OAuthUtils.gen_random_string(), OAuthUtils.gen_random_string())
     token.set_callback(self._oauth_request.get_parameter('oauth_callback'))
     timestamp = nowutc()
     TempRequestTokenHolder().add(Token(token.key, token, timestamp, self._consumer, None))
     Logger.get('oauth.request_token').info(token.to_string())
     return token.to_string()