def generate_key(identifier): from brave.core.application.model import Application key = SigningKey.generate(NIST256p, hashfunc=sha256) Application.objects( id=identifier, key__private=None # Make sure we don't override an existing one. ).update(set__key__private=hexlify(key.to_string()))
def index(self): records = Application.objects(development__in=[False, None]) # TODO: This needs to be ACL-filtered! devRecords = Application.objects(development=True) return 'brave.core.application.template.list_apps', dict( area = 'apps', records = records, devRecords = devRecords )
def generate_key(identifier): from brave.core.application.model import Application key = SigningKey.generate(NIST256p, hashfunc=sha256) Application.objects( id = identifier, key__private = None # Make sure we don't override an existing one. ).update( set__key__private = hexlify(key.to_string()) )
def merge(self, other): """Consumes other and takes its children.""" other.credentials.update(set__owner=self) other.characters.update(set__owner=self) LoginHistory.objects(user=other).update(set__user=self) from brave.core.group.model import Group from brave.core.application.model import Application, ApplicationGrant Group.objects(creator=other).update(set__creator=self) Application.objects(owner=other).update(set__owner=self) ApplicationGrant.objects(user=other).update(set__user=self) other.delete()
def get(self): if user.admin: adminRecords = {record for record in Application.objects() if record.owner != user._current_obj()} else: adminRecords = {} records = Application.objects(owner=user._current_obj()) if request.is_xhr: return 'brave.core.template.form', dict( kind = _("Application"), form = manage_form(), data = None, ) return 'brave.core.application.template.manage_apps', dict( area = 'apps', records = records, adminRecords = adminRecords )
def get(self): if user.admin: adminRecords = { record for record in Application.objects() if record.owner != user._current_obj() } else: adminRecords = {} records = Application.objects(owner=user._current_obj()) if request.is_xhr: return 'brave.core.template.form', dict( kind=_("Application"), form=manage_form(), data=None, ) return 'brave.core.application.template.manage_apps', dict( area='apps', records=records, adminRecords=adminRecords)
def post(self, **kw): if not request.is_xhr: raise HTTPNotFound() u = user._current_obj() valid, invalid = manage_form().native(kw) app = Application(owner=u, **{ k: v for k, v in valid.iteritems() if k in ('name', 'description', 'groups', 'site', 'contact') }) app.key.public = valid['key']['public'] app.mask.required = valid['required'] or 0 app.mask.optional = valid['optional'] or 0 if valid['development'] == "true" or valid['development'] == "True": app.development = True else: app.development = False app.save() return 'json:', dict(success=True, location='/application/manage/')
def post(self, **kw): if not request.is_xhr: raise HTTPNotFound() u = user._current_obj() valid, invalid = manage_form().native(kw) app = Application(owner=u, **{k: v for k, v in valid.iteritems() if k in ('name', 'description', 'groups', 'site', 'contact')}) app.key.public = valid['key']['public'] app.mask.required = valid['required'] or 0 app.mask.optional = valid['optional'] or 0 if valid['development'] == "true" or valid['development'] == "True": app.development = True else: app.development = False app.save() return 'json:', dict( success = True, location = '/application/manage/' )