def _do_delete_bindings(self, request, arg): #TODO: it would be nice to get a response conveying what bindings were # removed, but this isn't possible using the event method try: type_str = get_principal_type_from_args(arg) principal_name = arg["<principal name>"] dir_name = arg["<dir name>"] principalid = mangle_name(dir_name, principal_name).encode('utf-8') if type_str == "user": ae = Auth_event(Auth_event.DEAUTHENTICATE, datapathid.from_host(0), 0, create_eaddr(0), 0, False, Authenticator.get_unknown_name(), principalid, 0, 0) elif type_str == "host": ae = Auth_event(Auth_event.DEAUTHENTICATE, datapathid.from_host(0), 0, create_eaddr(0), 0, False, principalid, Authenticator.get_unknown_name(), 0, 0) else: raise Exception("Invalid principal type %s" % type_str) self._dm.post(ae) return simplejson.dumps("success") except Exception, e: return self.err(Failure(), request, "do_delete_bindings", "Could not construct deauth event.")
def get_name(self, principal_id): #currently, we get the names from authenticator, which may result in #not having a name if authenticator has timed it out #TODO: persist names? name = unicode(self._auth.get_name(principal_id), 'utf-8') if name == Authenticator.get_unknown_name(): name = "discovered;unknown name (%d)"%principal_id return name
def get_name(self, principal_id): #currently, we get the names from authenticator, which may result in #not having a name if authenticator has timed it out #TODO: persist names? name = unicode(self._auth.get_name(principal_id), 'utf-8') if name == Authenticator.get_unknown_name(): name = "discovered;unknown name (%d)" % principal_id return name
def _do_auth_event(self, request, arg): content = json_parse_message_body(request) try : type = Auth_event.AUTHENTICATE if "type" in content and content["type"] == "deauthenticate": type = Auth_event.DEAUTHENTICATE ni = NetInfo.from_str_dict(content) hostname =str(content.get("hostname",Authenticator.get_unknown_name())) username =str(content.get("username", Authenticator.get_unknown_name())) ae = Auth_event(type, ni.dpid, ni.port, ni.dladdr,ni.nwaddr,False, hostname, username, 0, 0) self.post(ae) return "[]" except Exception , e : traceback.print_exc() return webservice.badRequest(request, str(e))
def _do_auth_event(self, request, arg): content = json_parse_message_body(request) try: type = Auth_event.AUTHENTICATE if "type" in content and content["type"] == "deauthenticate": type = Auth_event.DEAUTHENTICATE ni = NetInfo.from_str_dict(content) hostname = str( content.get("hostname", Authenticator.get_unknown_name())) username = str( content.get("username", Authenticator.get_unknown_name())) ae = Auth_event(type, ni.dpid, ni.port, ni.dladdr, ni.nwaddr, False, hostname, username, 0, 0) self.post(ae) return "[]" except Exception, e: traceback.print_exc() return webservice.badRequest(request, str(e))
def cb(entity_list): if len(entity_list) == 0: msg = "User '%s' is not currently authenticated. No entries removed." % \ (mangled_name) request.write(simplejson.dumps(msg)) request.finish() return for e in entity_list: dpid = datapathid.from_host(e[0]) port = e[1] dladdr = ethernetaddr(e[2]) nwaddr = e[3] hostname = Authenticator.get_unknown_name() username = mangled_name ae = Auth_event(Auth_event.DEAUTHENTICATE, dpid, port, dladdr, nwaddr, False, hostname, username, 0, 0) self.post(ae) msg = "successfully removed %s user entries for '%s'" % \ (len(entity_list), mangled_name) request.write(simplejson.dumps(msg)) request.finish()
def cb(entity_list): if len(entity_list) == 0: msg = "User '%s' is not currently authenticated. No entries removed." % \ (mangled_name) request.write(simplejson.dumps(msg)) request.finish() return for e in entity_list: dpid = datapathid.from_host(e[0]) port = e[1] dladdr = ethernetaddr(e[2]) nwaddr = e[3] hostname = Authenticator.get_unknown_name() username = mangled_name ae = Auth_event(Auth_event.DEAUTHENTICATE, dpid, port, dladdr,nwaddr, False, hostname, username, 0, 0) self.post(ae) msg = "successfully removed %s user entries for '%s'" % \ (len(entity_list), mangled_name) request.write(simplejson.dumps(msg)) request.finish()
from nox.apps.configuration.properties import * from nox.apps.coreui import coreui from nox.apps.coreui.authui import UIResource from nox.apps.directory import directorymanager from nox.apps.storage import TransactionalStorage from nox.apps.user_event_log.pyuser_event_log import pyuser_event_log, LogEntry from nox.ext.apps.http_redirector.pyhttp_redirector import * from nox.ext.apps.redirproxy import redirproxy lg = logging.getLogger("captiveportal") DEV_VERBOSE = False # XXX this should never be True in production DEV_FAKE_FLOW = False # XXX this should never be True in production PROPERTIES_SECTION = "captive_portal_settings" UNKNOWN_HNAME = Authenticator.get_unknown_name() def _file_to_base64(path): f = open(path, 'rb') ret = base64.b64encode(f.read()) f.close() return ret class captiveportal(Component): _static_url_root = '/static/nox/ext/apps/captiveportal/' _web_root = '/cp/' _prop_root = _web_root + 'props/' _banner_image_name = 'cp_banner' _custom_css_name = 'local.css' web_resources = {
from nox.apps.configuration.properties import * from nox.apps.coreui import coreui from nox.apps.coreui.authui import UIResource from nox.apps.directory import directorymanager from nox.apps.storage import TransactionalStorage from nox.apps.user_event_log.pyuser_event_log import pyuser_event_log, LogEntry from nox.ext.apps.http_redirector.pyhttp_redirector import * from nox.ext.apps.redirproxy import redirproxy lg = logging.getLogger("captiveportal") DEV_VERBOSE = False # XXX this should never be True in production DEV_FAKE_FLOW = False # XXX this should never be True in production PROPERTIES_SECTION = "captive_portal_settings" UNKNOWN_HNAME = Authenticator.get_unknown_name() def _file_to_base64(path): f = open(path, 'rb') ret = base64.b64encode(f.read()) f.close() return ret class captiveportal(Component): _static_url_root = '/static/nox/ext/apps/captiveportal/' _web_root = '/cp/' _prop_root = _web_root + 'props/' _banner_image_name = 'cp_banner' _custom_css_name = 'local.css'