Beispiel #1
0
def authenticate_user( db ):

    oid = webopenid.status()
    if oid:
        return oid

    authentication_token = web.cookies().get( "authentication_token" )
    user_from_token = authenticate_token( db, authentication_token )
    if user_from_token is not None:
        return user_from_token

    auth = web.ctx.env.get( "HTTP_AUTHORIZATION" )
    if auth is None:
        return None

    user, pw = base64.decodestring( re.sub( "^Basic ", "", auth ) ).split( ":" )

    if user in known_users and known_users[user] == pw:
        return user
    else:
        raise unathorized()
Beispiel #2
0
def authenticate_user(db):

    oid = webopenid.status()
    if oid:
        return oid

    authentication_token = web.cookies().get("authentication_token")
    user_from_token = authenticate_token(db, authentication_token)
    if user_from_token is not None:
        return user_from_token

    auth = web.ctx.env.get("HTTP_AUTHORIZATION")
    if auth is None:
        return None

    user, pw = base64.decodestring(re.sub("^Basic ", "", auth)).split(":")

    if user in known_users and known_users[user] == pw:
        return user
    else:
        raise unathorized()
Beispiel #3
0
 def GET(self):
     if webopenid.status():
         return "Logged in."
     else:
         web.header('Content-Type', 'text/html')
         return webopenid.form('/openid')
Beispiel #4
0
 def GET(self):
     if webopenid.status():
         return "Logged in."
     else:
         web.header("Content-Type", "text/html")
         return webopenid.form("/openid")