Esempio n. 1
0
File: user.py Progetto: bjornua/dna
def authenticate(username, password):
    doc = None
    for x in db().view("user/auth", key=[username, password], include_docs=True):
        doc = x["doc"]
        break

    if doc is None:
        return
        
    macs = doc["macaddrs"]
    maxmacs = doc["macaddrs_max"]
    
    if macaddr != None:
        macs.append(macaddr)

        while len(macs) > maxmacs:
            iptables.delmac(macs.pop(0))
        
        if len(macs) == 0:
            return

        iptables.addmac(macaddr)
        
        db().save_doc(doc)
        
        return x["id"]
Esempio n. 2
0
File: user.py Progetto: bjornua/dna
def authenticate(username, password):
    doc = None
    for x in db().view("user/auth",
                       key=[username, password],
                       include_docs=True):
        doc = x["doc"]
        break

    if doc is None:
        return

    macs = doc["macaddrs"]
    maxmacs = doc["macaddrs_max"]

    if macaddr != None:
        macs.append(macaddr)

        while len(macs) > maxmacs:
            iptables.delmac(macs.pop(0))

        if len(macs) == 0:
            return

        iptables.addmac(macaddr)

        db().save_doc(doc)

        return x["id"]
Esempio n. 3
0
 def __init__(self, debug):
     local.application = self
     iptables.reset(config["interface_lan"], config["interface_wan"])
     for addr in user.getmacs():
         iptables.addmac(addr)
     self.debug = debug
     self.dispatch = SharedDataMiddleware(self.safedispatch, {"/static": path["static"]})