Changeset 4905
- Timestamp:
- 03/02/09 16:40:11 (12 years ago)
- Location:
- TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/relyingparty
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/relyingparty/__init__.py
r4863 r4905 13 13 import logging 14 14 log = logging.getLogger(__name__) 15 16 import httplib # to get official status code messages 15 17 16 18 import authkit.authenticate … … 47 49 @param app_conf: application specific configuration - must follow 48 50 format of propertyDefaults class variable""" 51 52 53 authKitApp = authkit.authenticate.middleware(app, app_conf) 54 app = beaker.middleware.SessionMiddleware(authKitApp) 49 55 50 56 # Check for sign in template settings … … 73 79 del conf[k] 74 80 75 app_conf['authkit.openid.template.string']=app.makeTemplate() 76 77 app = authkit.authenticate.middleware(app, app_conf) 78 app = beaker.middleware.SessionMiddleware(app) 81 authKitApp.template = app.getTemplateFunc()#app.makeTemplate() 79 82 80 83 super(OpenIDRelyingPartyMiddleware, self).__init__(app, … … 84 87 85 88 def __call__(self, environ, start_response): 86 return self._app(environ, start_response) 89 '''Alter start_response to override the status code and force to 401. 90 This will non-browser based client code to bypass the OpenID interface 91 ''' 92 def setUnauthorizedResponse(status, header, exc_info=None): 93 return start_response("%s %s" % (401, httplib.responses[401]), 94 header, 95 exc_info) 96 97 return self._app(environ, setUnauthorizedResponse) 87 98 88 99 class SigninInterfaceError(Exception): -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/relyingparty/signin_interface/buffet/__init__.py
r4863 r4905 32 32 propertyDefaults = { 33 33 'templateType': 'kid', 34 'template RootDir': None,34 'templatePackage': None, 35 35 'staticContentRootDir': './', 36 36 'baseURL': 'http://localhost', 37 'logoutURI': '', 37 38 'leftLogo': None, 38 39 'leftAlt': None, … … 58 59 59 60 self._buffet = OpenIDRelyingPartyRenderingBuffet(self.templateType, 60 template_root=self.template RootDir)61 template_root=self.templatePackage) 61 62 62 63 self.title = "Enter your OpenID to Sign in" … … 64 65 self.headExtras = '' 65 66 self.loginStatus = True 67 self.loggedIn = False 68 69 # TODO: handle session object scope 70 self.session = {'username': ''} 66 71 67 72 staticApp = StaticURLParser(self.staticContentRootDir) 68 app = Cascade([staticApp, self._app])73 self._app = Cascade([staticApp, app]) 69 74 70 75 def _render(self, templateName, c=None, **kw): … … 91 96 92 97 def __call__(self, environ, start_response): 93 static_app = StaticURLParser(document_root=self.documentRootDir) 94 app = Cascade([static_app, self._app]) 95 return app 98 return self._app(environ, start_response) -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/relyingparty/signin_interface/buffet/templates/ndgpage.kid
r4863 r4905 7 7 <title py:content="c.title">title</title> 8 8 ${XML(c.headExtras)} 9 <!--! The following includes the javascript, note that the XML 10 function is needed to avoid escaping the < character --> 11 <!-- 12 <?python 13 # Fudge for WebHelpers migration to 0.6.1 14 if hasattr(h, 'javascript_include_tag'): 15 javascript_include_tag = h.javascript_include_tag 16 else: 17 javascript_include_tag = h.rails.javascript_include_tag 18 ?> 19 ${XML(javascript_include_tag(builtins=True))} 20 <script type="text/javascript" src="${c.baseURL}/js/toggleDiv.js"/> 21 --> 22 <link media="all, screen" href="${c.baseURL}/layout/ndg2.css" type="text/css" rel="stylesheet"/> 23 <link rel="icon" type="image/ico" href="${c.baseURL}/layout/favicon.jpg" /> 9 <link media="all, screen" href="${c.baseURL}/layout/ndg2.css" 10 type="text/css" rel="stylesheet"/> 11 <link rel="icon" type="image/ico" 12 href="${c.baseURL}/layout/favicon.jpg"/> 24 13 </head> 25 14 … … 41 30 ?> 42 31 <li class="$status"><span class="pagetab"> 43 <!--44 ${XML(h.link_to_if(linkto,tab[0],tab[1]))}45 -->46 32 </span></li> 47 33 </span> … … 59 45 <td align="left" width="60%"> 60 46 <table><tbody> 61 <tr><td><span py:replace="linkimage(c.ndgLink,c.ndgImage,'NDG')"/></td> 62 <td>OpenID Provider Site for <a href="http://ndg.nerc.ac.uk"> NERC DataGrid</a> 63 ${c.disclaimer} </td> 47 <tr> 48 <td><span py:replace="linkimage(c.ndgLink,c.ndgImage,'NDG')"/></td> 49 <td>OpenID Provider Site for <a href="http://ndg.nerc.ac.uk">NERC DataGrid</a> 50 ${c.disclaimer}</td> 64 51 </tr> 65 52 </tbody></table> … … 68 55 <div py:if="c.loginStatus" id="loginStatus"> 69 56 <!--! now we choose one of the next two (logged in or not) --> 70 <div py:if=" 'username' in c.session" id="loggedIn">57 <div py:if="c.loggedIn" id="loggedIn"> 71 58 <table><tbody><tr><td> 72 <!-- Create link using embedded python73 construct because including a link with '&'74 directly causes an error75 -->76 <?python77 logOutLink='%s?submit=true&success_to=%s&fail_to=%s' % \78 (c.urls['url_loginsubmit'],79 c.urls['url_login'],80 c.urls['url_mainpage'])81 ?>82 59 Logged in as ${c.session['username']}. 83 [<a href="$logOutLink"> 84 Log out 85 </a>] 86 </td></tr></tbody></table> 87 </div> 88 <div py:if="'username' not in c.session" id="loggedOut"> 89 <table><tbody><tr><td> 90 Other services may be available if you <a href="${c.urls['url_login']}">login</a>. 60 [<a href="$c.logOutURI">Log out</a>] 91 61 </td></tr></tbody></table> 92 62 </div> -
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/relyingparty/signin_interface/buffet/templates/signin.kid
r4863 r4905 2 2 <div py:def="openIDSignin()" class="openIDSignin" style="text-indent:5px"> 3 3 <form action="$c.baseURL/verify" method="post"> 4 <table cellspacing="0" border="0" cellpadding="5">5 <tr>6 <td>OpenID:</td>7 <td>8 <input type="text" name="openid" value="" class='openid-identifier'/>9 </td>10 <td align="right">11 <input type="submit" name="authform" value="Go"/>12 </td>13 <td>14 <a href="http://openid.net/what/" target="_blank"><small>What's this?</small></a>15 </td>16 </tr>4 <table cellspacing="0" border="0" cellpadding="5" style="align: left"> 5 <tr align="left"> 6 <td>OpenID:</td> 7 <td align="left"> 8 <input type="text" name="openid" value="" class='openid-identifier'/> 9 </td> 10 <td align="right"> 11 <input type="submit" name="authform" value="Go"/> 12 </td> 13 <td> 14 <a href="http://openid.net/what/" target="_blank"><small>What's this?</small></a> 15 </td> 16 </tr> 17 17 </table> 18 18 </form> 19 <div id="message"> 20 $$message 21 </div> 19 22 </div> 20 23 21 24 <head> 22 25 <style>
Note: See TracChangeset
for help on using the changeset viewer.