goa/appobjects/gauthservice.py
brancholdstable
changeset 6665 90f2f20367bc
parent 6018 f4d1d5d9ccbb
parent 6661 1719137de7da
child 6701 fd4267ecbba6
child 6710 a89dc08e5970
equal deleted inserted replaced
6018:f4d1d5d9ccbb 6665:90f2f20367bc
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """authentication using google authentication service
       
    19 
       
    20 """
       
    21 __docformat__ = "restructuredtext en"
       
    22 
       
    23 from cubicweb.web.views.basecomponents import UserLink
       
    24 from cubicweb.web.views.actions import LogoutAction
       
    25 
       
    26 from google.appengine.api import users
       
    27 
       
    28 
       
    29 class GACWUserLink(UserLink):
       
    30 
       
    31     def anon_user_link(self):
       
    32         self.w(self.req._('anonymous'))
       
    33         self.w(u'&#160;[<a class="logout" href="%s">%s</a>]'
       
    34                % (users.create_login_url(self.req.url()), self.req._('login')))
       
    35 
       
    36 class GAELogoutAction(LogoutAction):
       
    37 
       
    38     def url(self):
       
    39         return users.create_logout_url(self.req.build_url('logout') )
       
    40 
       
    41 def registration_callback(vreg):
       
    42     if hasattr(vreg.config, 'has_resource'):
       
    43         vreg.register(GACWUserLink, clear=True)
       
    44         vreg.register(GAELogoutAction, clear=True)