Exemple #1
0
    def setUp(self):
        def check(self):
            self.user = self.who_am_i
            return self.user

        def default_forbidden():
            return "this is default 403"

        acl_init(check, default_forbidden)

        @acl(["jedi", "sith"])
        class TheEndOfTheGalaxyPub(object):
            def get(self):
                return "Yeah, it's working"

            def forbidden(self):
                if self.user == "pony":
                    return "No ponies allowed here!"
                raise Exception(44)
        self.test1 = TheEndOfTheGalaxyPub()

        @acl(["sith"])
        class DeathStar(object):
            def get(self):
                return "Yeah, it's working and you are using the Dark Force!"
        self.test2 = DeathStar()
Exemple #2
0
    def setUp(self):
        def check(self):
            self.user = self.who_am_i
            return self.user

        def default_forbidden():
            return "this is default 403"

        acl_init(check, default_forbidden)

        @acl(["jedi", "sith"])
        class TheEndOfTheGalaxyPub(object):
            def get(self):
                return "Yeah, it's working"

            def forbidden(self):
                if self.user == "pony":
                    return "No ponies allowed here!"
                raise Exception(44)

        self.test1 = TheEndOfTheGalaxyPub()

        @acl(["sith"])
        class DeathStar(object):
            def get(self):
                return "Yeah, it's working and you are using the Dark Force!"

        self.test2 = DeathStar()
Exemple #3
0
    def setUp(self):
        def check(self):
            return False

        acl_init(check)

        @acl(True)
        class BlackHole(object):
            def get(self):
                return "Yeah, it's working"
        self.test1 = BlackHole()
Exemple #4
0
    def setUp(self):
        def check(self):
            return False

        acl_init(check)

        @acl(True)
        class BlackHole(object):
            def get(self):
                return "Yeah, it's working"

        self.test1 = BlackHole()
Exemple #5
0
    if user_agent.lower().find("chrome") != -1:
        self.user = "******"
    elif user_agent.lower().find("ie") != -1:
        self.user = "******"
    else:
        self.user = "******"
    return self.user


# Default behaviour when user is not permitted to access the resource
def forbidden():
    raise HTTPError(403, "To enter this area you are allowed not")


# Initialize the Access Control List checker!
acl_init(check, forbidden)


class StartPoint(tornado.web.RequestHandler):
    def get(self):
        self.finish(
            "Welcome <b>" + check(self) + "</b>" +
            "<h1>Everyone can acess this area</h1>Choose a place to go: " +
            "<ul><li><a href='/potentium'>Potentium (Sith & Jedi)</a></li>" +
            "<li><a href='/lightside_hq'>GalacticCity (Jedi only)</a></li>" +
            "<li><a href='/darkside_hq'> DeathStar (Sith only)</a></li>" +
            "</ul>")


# Let's say all Force users can access it freely
class Potentium(tornado.web.RequestHandler):
Exemple #6
0
    # IE user as the Sith - hey! no bad feelings!
    if user_agent.lower().find("chrome") != -1:
        self.user = "******"
    elif user_agent.lower().find("ie") != -1:
        self.user = "******"
    else:
        self.user = "******"
    return self.user


# Default behaviour when user is not permitted to access the resource
def forbidden():
    raise HTTPError(403, "To enter this area you are allowed not")

# Initialize the Access Control List checker!
acl_init(check, forbidden)


class StartPoint(tornado.web.RequestHandler):
    def get(self):
        self.finish(
            "Welcome <b>" + check(self) + "</b>" +
            "<h1>Everyone can acess this area</h1>Choose a place to go: " +
            "<ul><li><a href='/potentium'>Potentium (Sith & Jedi)</a></li>" +
            "<li><a href='/lightside_hq'>GalacticCity (Jedi only)</a></li>" +
            "<li><a href='/darkside_hq'> DeathStar (Sith only)</a></li>" +
            "</ul>")


# Let's say all Force users can access it freely
class Potentium(tornado.web.RequestHandler):