Changeset 8114


Ignore:
Timestamp:
24/08/12 13:25:52 (7 years ago)
Author:
pjkersha
Message:

Completed clear out of examples dir

  • two examples - bearer tok and slcs
  • shared config files held in shared_config
Location:
trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples
Files:
2 added
10 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/__init__.py

    r8058 r8114  
     1"""OAuth 2.0 WSGI server test application for use with client middleware 
     2""" 
     3__author__ = "R B Wilkinson" 
     4__date__ = "09/12/11" 
     5__copyright__ = "(C) 2011 Science and Technology Facilities Council" 
     6__license__ = "BSD - see LICENSE file in top-level directory" 
     7__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     8__revision__ = "$Id$" 
     9 
     10 
     11class WsgiTestApp(object): 
     12    """ 
     13    Simple WSGI application that displays a token set in the WSGI environ by 
     14    Oauth2ClientMiddleware. 
     15    """ 
     16    method = { 
     17        "/": 'default', 
     18        "/token": 'tok' 
     19    } 
     20    TOKEN_ENV_KEYNAME = 'oauth2client.token' 
     21    def __init__(self, app, globalConfig, **localConfig): 
     22        self.beakerSessionKeyName = globalConfig['beakerSessionKeyName'] 
     23        self.app = app 
     24 
     25    def __call__(self, environ, start_response): 
     26        methodName = self.method.get(environ['PATH_INFO'], '').rstrip() 
     27        if methodName: 
     28            action = getattr(self, methodName) 
     29            return action(environ, start_response) 
     30        elif self.app is not None: 
     31            return self.app(environ, start_response) 
     32        else: 
     33            start_response('404 Not Found', [('Content-type', 'text/plain')]) 
     34            return "ndg_oauth WSGI Test Application: invalid URI" 
     35 
     36    def default(self, environ, start_response): 
     37        response = "<h2>ndg_oauth WSGI Test Application</h2>" 
     38        start_response('200 OK',  
     39                       [('Content-type', 'text/html'), 
     40                        ('Content-length', str(len(response)))]) 
     41        return [response] 
     42 
     43    def tok(self, environ, start_response): 
     44        tok = environ.get(self.TOKEN_ENV_KEYNAME) 
     45        response = ["<h2>ndg_oauth WSGI Test Application - Get Token" 
     46                    "</h2>"] 
     47        if tok: 
     48            response.append("<pre>%s</pre>" % tok) 
     49        else: 
     50            response.append("<p>token not found</p>") 
     51 
     52        start_response('200 OK',  
     53                       [('Content-type', 'text/html'), 
     54                        ('Content-length',  
     55                         str(sum([len(r) for r in response])))]) 
     56        return response 
     57 
     58    @classmethod 
     59    def app_factory(cls, globalConfig, **localConfig): 
     60        return cls(None, globalConfig, **localConfig) 
     61 
     62    @classmethod 
     63    def filter_app_factory(cls, app, globalConfig, **localConfig): 
     64        return cls(app, globalConfig, **localConfig) 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/bearer_tok/__init__.py

    r8112 r8114  
     1"""NDG OAuth 2.0  
     2 
     3Bearer token example client app 
     4""" 
     5__author__ = "Philip Kershaw" 
     6__date__ = "24/08/12" 
     7__copyright__ = "(C) 2012 Science and Technology Facilities Council" 
     8__license__ = "BSD - see LICENSE file in top-level directory" 
     9__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     10__revision__ = "$Id$" 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/bearer_tok/bearer_tok_client_app.ini

    r8112 r8114  
    6161 
    6262[app:App] 
    63 paste.app_factory = ndg.oauth.client.examples.wsgi.cert_req_app:WsgiTestApp.app_factory 
     63paste.app_factory = ndg.oauth.client.examples:WsgiTestApp.app_factory 
    6464resource_url = https://localhost:5000/oauth/request_certificate 
    65 client_cert = %(here)s/pki/localhost.crt 
    66 client_key = %(here)s/pki/localhost.key 
    67 ca_dir = %(here)s/pki/ca 
     65client_cert = %(here)s/../shared_config/pki/localhost.crt 
     66client_key = %(here)s/../shared_config/pki/localhost.key 
     67ca_dir = %(here)s/../shared_config/pki/ca 
    6868 
    6969 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/bearer_tok/bearer_tok_client_app_serve.py

    r8112 r8114  
     1"""NDG OAuth 2.0  
     2 
     3Example paster script to run bearer token example client app 
     4""" 
     5__author__ = "Philip Kershaw" 
     6__date__ = "24/08/12" 
     7__copyright__ = "(C) 2012 Science and Technology Facilities Council" 
     8__license__ = "BSD - see LICENSE file in top-level directory" 
     9__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     10__revision__ = "$Id$" 
    111from paste.script.serve import ServeCommand 
    212 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/shared_config/__init__.py

    r8112 r8114  
     1"""NDG OAuth 2.0  
     2 
     3Package for example client app configuration 
     4""" 
     5__author__ = "Philip Kershaw" 
     6__date__ = "24/08/12" 
     7__copyright__ = "(C) 2012 Science and Technology Facilities Council" 
     8__license__ = "BSD - see LICENSE file in top-level directory" 
     9__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     10__revision__ = "$Id$" 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/slcs/__init__.py

    r8083 r8114  
     1"""NDG OAuth 2.0  
     2 
     3Short-lived credential service client app example 
     4""" 
     5__author__ = "Philip Kershaw" 
     6__date__ = "24/08/12" 
     7__copyright__ = "(C) 2012 Science and Technology Facilities Council" 
     8__license__ = "BSD - see LICENSE file in top-level directory" 
     9__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     10__revision__ = "$Id$" 
  • trunk/ndg_oauth/ndg_oauth_client/ndg/oauth/client/examples/slcs/slcs_oauth_client_serve.py

    r8083 r8114  
     1"""NDG OAuth 2.0  
     2 
     3Example paster script to run short-lived credential service example client app 
     4""" 
     5__author__ = "Philip Kershaw" 
     6__date__ = "24/08/12" 
     7__copyright__ = "(C) 2012 Science and Technology Facilities Council" 
     8__license__ = "BSD - see LICENSE file in top-level directory" 
     9__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     10__revision__ = "$Id$" 
    111from paste.script.serve import ServeCommand 
    212 
Note: See TracChangeset for help on using the changeset viewer.