]>
jfr.im git - irc/quakenet/qwebirc.git/blob - qwebirc/authgateengine.py
1 from authgate
import twisted
as authgate
2 from twisted
.web
import resource
, server
, static
3 import config
, urlparse
, urllib
5 class AuthgateEngine(resource
.Resource
):
8 def __init__(self
, prefix
):
11 def deleteCookie(self
, request
, key
):
12 request
.addCookie(key
, "", path
="/", expires
="Sat, 29 Jun 1996 01:44:48 GMT")
14 def render_GET(self
, request
):
15 if request
.args
.get("logout"):
16 self
.deleteCookie(request
, "user")
18 a
= authgate(request
, config
.AUTHGATEDOMAIN
)
20 ticket
= a
.login_required(accepting
=lambda x
: True)
21 except a
.redirect_exception
, e
:
24 # only used for informational purposes, the backend stores this seperately
25 # so if the user changes it just their front end will be messed up!
26 request
.addCookie("user", ticket
.username
, path
="/")
28 location
= request
.getCookie("redirect")
32 self
.deleteCookie(request
, "redirect")
33 _
, _
, path
, params
, query
, _
= urlparse
.urlparse(urllib
.unquote(location
))
34 location
= urlparse
.urlunparse(("", "", path
, params
, query
, ""))
36 request
.redirect(location
)
39 return server
.NOT_DONE_YET
41 def getSessionData(request
):
42 return authgate
.get_session_data(request
)
44 def login_optional(request
):
45 return authgate(request
, config
.AUTHGATEDOMAIN
).login_optional()