def enroll(self, username): if username not in self.users: self.users[username] = {} user = self.users[username] devices = map(DeviceRegistration.wrap, user.get('_u2f_devices_', [])) enroll = start_register(self.app_id, devices) user['_u2f_enroll_'] = enroll.json return enroll.json
def __enable_u2f(self, user): if user.uuid not in self.__settings: self.__settings[user.uuid] = {} user_settings = self.__settings[user.uuid] devices = [DeviceRegistration.wrap(device) for device in user_settings.get('_u2f_devices_', [])] enroll = start_register(self.app_id, devices) user_settings['_u2f_enroll_'] = enroll.json self.__save_settings() return enroll.json
def get_context_data(self, **kwargs): ctx = super().get_context_data() ctx['device'] = self.device devices = [DeviceRegistration.wrap(device.json_data) for device in U2FDevice.objects.filter(confirmed=True, user=self.request.user)] enroll = u2f.start_register(self.app_id, devices) self.request.session['_u2f_enroll'] = enroll.json ctx['jsondata'] = enroll.json return ctx
def __enable_u2f(self, user): if user.uuid not in self.__settings: self.__settings[user.uuid] = {} user_settings = self.__settings[user.uuid] devices = [ DeviceRegistration.wrap(device) for device in user_settings.get('_u2f_devices_', []) ] enroll = start_register(self.app_id, devices) user_settings['_u2f_enroll_'] = enroll.json self.__save_settings() return enroll.json
def get_context_data(self, **kwargs): ctx = super().get_context_data() ctx['device'] = self.device devices = [ DeviceRegistration.wrap(device.json_data) for device in U2FDevice.objects.filter(confirmed=True, user=self.request.user) ] enroll = u2f.start_register(self.app_id, devices) self.request.session['_u2f_enroll'] = enroll.json ctx['jsondata'] = enroll.json return ctx
def userEnroll(id): try: user = User().getObjectsByKey("_id", id)[0] except Exception as e: return abort(404) try: devices = map(DeviceRegistration.wrap, user.u2f_devices) except: devices = [] app_id = "http://127.0.0.1" print app_id enroll = start_register(app_id, devices) user.u2f_enroll = enroll.json return enroll.json
def start_enrollment(self): return dict(u2f.start_register(self.u2f_app_id, self.get_u2f_devices()))
def register_token(devices=[]): token = SoftU2FDevice() request_data = u2f.start_register(APP_ID, devices) response = token.register(request_data.registerRequests[0].json, FACET) device, cert = u2f.complete_register(request_data, response) return device, token
def generate_new_config(self): return { 'enrollment': dict(u2f.start_register(self.u2f_app_id, [])), }