Exemple #1
0
def buildGuardedResource():
    return simpleguard.guardResource(
        Authenticated(),
        [checkers.InMemoryUsernamePasswordDatabaseDontUse(bob="12345")],
        nonauthenticated=LoginPage(),
        callback=callback,
        errback=LoginPage)
Exemple #2
0
def MakeWebServer():

    checker = MyChecker()
    

    reactor.listenTCP(8080, server.Site(
        simpleguard.guardResource(SimpleResource(), [checker])))
Exemple #3
0
from twisted.web import server, resource
from twisted.web.woven import simpleguard

class SimpleResource(resource.Resource):

    def getChild(self, path, request):
        return self

    def render_GET(self, request):
        name = request.getComponent(simpleguard.Authenticated).name
        return "hello my friend "+name

class HaHa(resource.Resource):

    def getChild(self, path, request):
        return self

    def render_GET(self, request):
        return """I don't know you!<br />
        <a href='perspective-init'>login</a>
        """


checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("bob", "12345")

reactor.listenTCP(8889, server.Site(
      simpleguard.guardResource(SimpleResource(), [checker],
                                nonauthenticated=HaHa())))
reactor.run()
Exemple #4
0
from twisted.cred import checkers
from twisted.internet import reactor
from twisted.web import server, resource
from twisted.web.woven import simpleguard


class SimpleResource(resource.Resource):
    def getChild(self, path, request):
        return self

    def render_GET(self, request):
        auth = request.getComponent(simpleguard.Authenticated)
        if auth:
            return "hello my friend " + auth.name
        else:
            return """
                I don't think we've met
        <a href="perspective-init">login</a>
            """


checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("bob", "12345")

reactor.listenTCP(
    8889,
    server.Site(
        resource=simpleguard.guardResource(SimpleResource(), [checker])))
reactor.run()
Exemple #5
0
def buildGuardedResource():
    return simpleguard.guardResource(
               Authenticated(),
               [checkers.InMemoryUsernamePasswordDatabaseDontUse(bob="12345")],
               nonauthenticated=LoginPage(),
               callback=callback, errback=LoginPage)
from twisted.cred import checkers
from twisted.internet import reactor
from twisted.web import server, resource
from twisted.web.woven import simpleguard

class SimpleResource(resource.Resource):

    def getChild(self, path, request):
        return self

    def render_GET(self, request):
        auth = request.getComponent(simpleguard.Authenticated)
        if auth:
            return "hello my friend "+auth.name
        else:
            return """
                I don't think we've met
        <a href="perspective-init">login</a>
            """

checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("bob", "12345")

reactor.listenTCP(8889, server.Site(
      resource = simpleguard.guardResource(SimpleResource(), [checker])))
reactor.run()