Changeset 8033 for trunk/ndg_oauth/ndg_oauth_server
- Timestamp:
- 02/03/12 10:33:02 (9 years ago)
- Location:
- trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/lib/authorization_server.py
r8030 r8033 412 412 content = json.dumps(content_dict) 413 413 return (content, None, None) 414 415 def is_registered_client(self, request): 416 """Determines whether the client ID in the request is registered. 417 @type request: WebOb.request 418 @param request: request 419 @rtype: tuple (basestring, basestring) or (NoneType, NoneType) 420 @return: (error, error description) or None if client ID is found and 421 registered 422 """ 423 client_id = request.params.get('client_id', None) 424 if not client_id: 425 return ('invalid_request', 'Missing request parameter: client_id') 426 else: 427 error_description = self.client_register.is_registered_client( 428 client_id) 429 if error_description: 430 return ('unauthorized_client', error_description) 431 return (None, None) -
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/lib/register/client.py
r7952 r8033 50 50 self.register[client_id] = client_registration 51 51 52 def is_registered_client(self, client_id): 53 """Determines if a client ID is in the client register. 54 """ 55 if client_id not in self.register: 56 return ('Client of id "%s" is not registered.' % client_id) 57 return None 58 52 59 def is_valid_client(self, client_id, redirect_uri): 60 """Determines if a client ID is in the client register and the 61 redirect_uri is registered for that client. 62 """ 53 63 # Check if client ID is registered. 54 64 if client_id not in self.register: -
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/wsgi/authorization_filter.py
r8030 r8033 11 11 import logging 12 12 13 from genshi.template import MarkupTemplate14 13 from webob import Request 15 14 … … 205 204 """ 206 205 client = self.client_register.register.get(client_id) 207 # tmpl_file = open(self.client_authorization_form) 208 # tmpl = MarkupTemplate(tmpl_file) 209 # tmpl_file.close() 210 submit_url = req.application_url + self.base_path + '/client_auth' 211 c = {'client_name': client.name, 212 'client_id': client_id, 213 'scope': scope, 214 'submit_url': submit_url} 215 # response = tmpl.generate(c=c).render('html') 216 response = self.renderer.render(self.client_authorization_form, c) 206 if client is None: 207 # Client ID is not registered. 208 log.error("OAuth client of ID %s is not registered with the server", 209 client_id) 210 211 response = ( 212 "OAuth client of ID %s is not registered with the server" % 213 client_id) 214 else: 215 submit_url = req.application_url + self.base_path + '/client_auth' 216 c = {'client_name': client.name, 217 'client_id': client_id, 218 'scope': scope, 219 'submit_url': submit_url} 220 response = self.renderer.render(self.client_authorization_form, c) 217 221 start_response(self._get_http_status_string(httplib.OK), 218 222 [('Content-type', 'text/html'), -
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/wsgi/oauth2_server.py
r8030 r8033 184 184 return [] 185 185 186 # Stop immediately if the client is not registered. 187 (error, error_description 188 ) = self._authorizationServer.is_registered_client(req) 189 if error: 190 return self._error_response(error, error_description, 191 start_response) 186 192 187 193 # User authorization for the client is also required. … … 197 203 (redirect_uri, error, error_description) = self._authorizationServer.authorize(req, client_authorized) 198 204 if error: 199 response = ("%s: %s" %(error, error_description)) 200 log.error("Returning error: %s - %s", error, error_description) 201 start_response(self._get_http_status_string(httplib.BAD_REQUEST), 202 [('Content-type', 'text/plain'), 203 ('Content-length', str(len(response))) 204 ]) 205 return[response] 205 self._error_response(error, error_description, start_response) 206 206 else: 207 207 return self._redirect(redirect_uri, start_response) 208 209 def _error_response(self, error, error_description, start_response): 210 """Returns and error response. 211 """ 212 response = ("%s: %s" %(error, error_description)).encode('ascii', 213 'ignore') 214 log.error("Returning error: %s - %s", error, error_description) 215 start_response(self._get_http_status_string(httplib.BAD_REQUEST), 216 [('Content-type', 'text/plain'), 217 ('Content-length', str(len(response))) 218 ]) 219 return[response] 208 220 209 221 def _check_client_authorization(self, user, req):
Note: See TracChangeset
for help on using the changeset viewer.