Changeset 8251 for trunk/ndg_oauth/ndg_oauth_server
- Timestamp:
- 30/10/12 16:34:39 (8 years ago)
- Location:
- trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/examples/bearer_tok/bearer_tok_server_app.ini
r8143 r8251 5 5 # * a resource server. This is a specialised one which enables delegated 6 6 # clients to obtain short-lived X.509 certificate credentials. It does this 7 # by using MyProxyCA as a backend certificate issuing service. A MyProxyCA 8 # instance is required to demonstrate this but not to demonstrate the 9 # authorisation service. 7 # by using the Contrail Online CA package 10 8 # 11 9 # The %(here)s variable will be replaced with the parent directory of this file … … 18 16 error_email_from = paste@localhost 19 17 18 # These are common variables referenced by more than one section below. They 19 # set the paths for the OAuth services and the protected resources (just one in 20 # this case - the OnlineCA's certificate issuing path) 21 oauth_server_basepath = /oauth 22 secured_resource_path = /resource1.html 23 24 # The OAuth client to this service will request a resource on behalf of a user 25 # based on an access token passed. The resource server checks the token looking 26 # it up in cached session information. This session also holds the id of the 27 # user who granted the token. This id can be made available from the resource 28 # server to the downstream application being protected. In this case, this is 29 # the OnlineCA service. The OnlineCA needs the id in order to create the 30 # correct certificate subject for the certificate to be issued. 31 claimed_userid_environ_key = oauth_granting_userid 32 20 33 beakerSessionKeyName = beaker.session.oauth2server 21 34 … … 30 43 pipeline = BeakerSessionFilter 31 44 repoze_who 32 AuthnForm 33 MyProxyClient 34 OAuth2Authz 35 OAuth2ServerFilterApp 45 AuthenticationFormFilter 46 OAuth2AuthorisationFilter 47 OAuth2ServerFilter 48 OAuth2ResourceServerFilter 49 FilterApp 36 50 37 51 # This filter sets up a server side session linked to a cookie. The session … … 56 70 log_level = debug 57 71 58 [filter:Auth nForm]72 [filter:AuthenticationFormFilter] 59 73 paste.filter_app_factory = ndg.oauth.server.wsgi.authentication_filter:AuthenticationFormMiddleware.filter_app_factory 60 74 authenticationForm.base_url_path = /authentication … … 76 90 authenticationForm.layout.helpIcon = /layout/help.png 77 91 78 [filter:OAuth2Auth z]92 [filter:OAuth2AuthorisationFilter] 79 93 # Authorization filter configuration options - defaults are commented out. 80 94 paste.filter_app_factory = ndg.oauth.server.wsgi.authorization_filter:Oauth2AuthorizationMiddleware.filter_app_factory … … 94 108 oauth2authorization.layout.helpIcon = /layout/icons/help.png 95 109 96 # Add a MyProxy Client into WSGI environ so that OAuth resource server can 97 # request certificates 98 [filter:MyProxyClient] 99 paste.filter_app_factory = myproxy.server.wsgi.middleware:MyProxyClientMiddleware.filter_app_factory 100 # Default environ key for MyProxy client 101 # myproxy.client.clientEnvKeyName=myproxy.server.wsgi.middleware.MyProxyClientMiddleware.myProxyClient 102 103 # MyProxy server which this MyProxy WSGI app is a client to. Set here to the 104 # fully qualified domain name or else set the MYPROXY_SERVER environment 105 # variable. See the documentation for the MyProxyClient egg for details 106 myproxy.client.hostname = pampero.badc.rl.ac.uk 107 #myproxy.client.port = 7512 108 109 # CA Certificate directory to enable this application to trust the MyProxy 110 # server that it fronts e.g. set to /etc/grid-security/certificates. For these 111 # tests set to local ca directory 112 MyProxy.client.caCertDir = %(here)s/pki/ca 113 114 [app:OAuth2Server] 115 paste.app_factory = ndg.oauth.server.wsgi.oauth2_server:Oauth2ServerMiddleware.app_factory 110 [filter:OAuth2ServerFilter] 111 paste.filter_app_factory = ndg.oauth.server.wsgi.oauth2_server:Oauth2ServerMiddleware.filter_app_factory 116 112 117 113 # OAuth2 server configuration options - defaults are commented out. … … 122 118 #oauth2server.access_token_type=bearer 123 119 #oauth2server.authorization_grant_lifetime=600 124 oauth2server.base_url_path= /oauth120 oauth2server.base_url_path=%(oauth_server_basepath)s 125 121 #oauth2server.certificate_request_parameter=certificate_request 126 122 # Allowed values: certificate (default) or none. … … 133 129 #oauth2server.user_identifier_key=REMOTE_USER 134 130 135 # This is specific to the special configuration of a resource server protecting136 # a MyProxyCA short-lived credential service (SLCS). The resource server will137 # accept a bearer token and SLCS specific input: a certificate signing request138 # (CSR). Provided that the token is accepted, the CSR is passed on to the139 # underlying MyProxy server along with the special password below. On success,140 # the MyProxyCA server returns a signed certificate. A MyProxyCA instance141 # is required to support this resource request. The OAuth app can be extended142 # as needed to support access to other more generic resource types. This is143 # just an example144 oauth2server.myproxy_global_password=testpassword145 146 131 # Configuration of access token cache 147 132 oauth2server.cache.accesstokenregister.expire=86400 … … 158 143 #oauth2server.cache.authorizationgrantregister.lock_dir 159 144 160 [filter-app:OAuth2ServerFilterApp] 145 [filter:OAuth2ResourceServerFilter] 146 paste.filter_app_factory = ndg.oauth.server.wsgi.resource_server:Oauth2ResourceServerMiddleware.filter_app_factory 147 148 # Sets which paths are protected by OAuth. In this example, the OnlineCA's 149 # certificate issuing service 150 oauth2.resource_server.resource_uripaths: %(secured_resource_path)s 151 152 # Scope required to access this resource. More than one value can be set. 153 # Values should be space delimited. In this case, the value has been set to the 154 # path of the certificate issuing path for the OnlineCA but this is just a 155 # convenient value. Any arbitrary string could have been set. 156 oauth2.resource_server.required_scope: https://localhost:5000/resource1.html 157 158 # Set the userid of the delegator as a key in environ. This is useful for 159 # access by the downstream app that the resource server middleware is 160 # protecting. In this case, the OnlineCA service. 161 oauth2.resource_server.claimed_userid_environ_key: %(claimed_userid_environ_key)s 162 163 [filter-app:FilterApp] 161 164 use = egg:Paste#httpexceptions 162 165 next = cascade … … 164 167 [composit:cascade] 165 168 use = egg:Paste#cascade 166 app1 = OAuth2Server 167 app2 = StaticContent 169 app1 = StaticContent 168 170 catch = 404 169 171 … … 171 173 use = egg:Paste#static 172 174 document_root = %(here)s/static 173 174 # WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*175 # Debug mode will enable the interactive debugging tool, allowing ANYONE to176 # execute malicious code after an exception is raised.177 #set debug = false178 175 179 176 -
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/lib/authorization_server.py
r8195 r8251 34 34 Provides the core OAuth 2.0 server functions. 35 35 """ 36 AUTHZ_HDR_ENV_KEYNAME = 'HTTP_AUTHORIZATION' 37 36 38 def __init__(self, client_register_file, authorizer, client_authenticator, 37 39 access_token_generator, config): … … 509 511 ) 510 512 """ 511 params = request.params 512 token = None 513 if 'access_token' not in params: 513 authorization_hdr = request.environ.get( 514 self.__class__.AUTHZ_HDR_ENV_KEYNAME) 515 try: 516 token_type, access_token = authorization_hdr.split() 517 518 except AttributeError: 519 log.error('No Authorization header present for request to %r', 520 request.path_url) 514 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 515 528 else: 516 access_token = params['access_token']517 if scope:518 required_scope = scope519 else:520 required_scope = params.get('scope', None)521 522 token, error = self.access_token_register.get_token(access_token,523 required_scope)529 if token_type != 'Bearer': 530 log.error('Token type retrieved is %r, expecting "Bearer" type', 531 token_type) 532 error = 'invalid_request' 533 else: 534 token, error = self.access_token_register.get_token( 535 access_token, 536 None) 524 537 525 538 status = {'invalid_request': httplib.BAD_REQUEST, -
trunk/ndg_oauth/ndg_oauth_server/ndg/oauth/server/wsgi/oauth2_server.py
r8236 r8251 67 67 USER_IDENTIFIER_GRANT_DATA_KEY = 'user_identifier' 68 68 69 AUTHORISATION_SERVER_ENVIRON_KEYNAME = 'ndg.server.authorisation.server' 69 AUTHORISATION_SERVER_ENVIRON_KEYNAME = \ 70 'ndg.oauth.server.authorisation.server' 70 71 71 72 # Configuration option defaults … … 238 239 239 240 # User authorization for the client is also required. 240 (client_authorized, authz_uri)= self._check_client_authorization(user,241 241 client_authorized, authz_uri = self._check_client_authorization(user, 242 req) 242 243 if authz_uri: 243 244 log.debug("Redirecting to %s", authz_uri)
Note: See TracChangeset
for help on using the changeset viewer.