Changeset 8252 for trunk/ndg_oauth/ndg_oauth_server
- Timestamp:
- 02/11/12 16:34:25 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/lib/authorization_server.py
r8251 r8252 35 35 """ 36 36 AUTHZ_HDR_ENV_KEYNAME = 'HTTP_AUTHORIZATION' 37 37 BEARER_TOK_ID = 'Bearer' 38 MAC_TOK_ID = 'MAC' 39 TOKEN_TYPES = (BEARER_TOK_ID, MAC_TOK_ID) 40 38 41 def __init__(self, client_register_file, authorizer, client_authenticator, 39 42 access_token_generator, config): … … 481 484 Checks that a token in the request is valid. It would 482 485 be called from a resource service that trusts this authorization 483 service. This is not part of the OAuth specification. 484 485 Request parameters 486 487 access_token 488 REQUIRED. Bearer token 489 scope 490 OPTIONAL. Scope 486 service. 487 488 Request parameters: 489 set in Authorization header (OAuth spec., Section 7.1 Access 490 Token Types 491 token type: Bearer or MAC 492 access token: access token to obtain access 491 493 492 494 Response: … … 513 515 authorization_hdr = request.environ.get( 514 516 self.__class__.AUTHZ_HDR_ENV_KEYNAME) 515 try: 516 token_type, access_token = authorization_hdr.split() 517 if authorization_hdr is None: 518 log.error('No Authorization header present for request to %r', 519 request.path_url) 520 error = 'invalid_request' 521 else: 522 authorization_hdr_parts = authorization_hdr.split() 523 if len(authorization_hdr_parts) < 2: 524 log.error('Expecting at least two Authorization header ' 525 'elements for request to %r; ' 526 'header is: %r', request.path_url, authorization_hdr) 527 error = 'invalid_request' 528 529 token_type, access_token = authorization_hdr_parts[:2] 517 530 518 except AttributeError: 519 log.error('No Authorization header present for request to %r', 520 request.path_url) 521 error = 'invalid_request' 522 523 except ValueError: 524 log.error('Unexpected Authorization header values %r for request ' 525 'to %r', authorization_hdr, request.path_url) 526 error = 'invalid_request' 527 528 else: 529 if token_type != 'Bearer': 530 log.error('Token type retrieved is %r, expecting "Bearer" type', 531 token_type) 531 # Currently only supports bearer type tokens 532 if token_type != self.__class__.BEARER_TOK_ID: 533 log.error('Token type retrieved is %r, expecting "Bearer" ' 534 'type for request to %r', token_type) 532 535 error = 'invalid_request' 533 536 else: 534 537 token, error = self.access_token_register.get_token( 535 538 access_token, 536 None)539 scope) 537 540 538 541 status = {'invalid_request': httplib.BAD_REQUEST,
Note: See TracChangeset
for help on using the changeset viewer.