Lock braindance private channels
This commit is contained in:
1 parent
d1ae79a5f7
commit
ce5eb09db3
1 file changed
+4
-3
@@ -106,7 +106,7 @@ def json_object():
|
|||||||
return data if isinstance(data, dict) else None
|
return data if isinstance(data, dict) else None
|
||||||
|
|
||||||
def record_public(rec):
|
def record_public(rec):
|
||||||
return {n: b64(rec['layers'][n]) for n in rec['public'] if n in rec['layers']}
|
return {n: b64(rec['layers'][n]) for n in PUBLIC_LAYERS if n in rec['layers']}
|
||||||
|
|
||||||
def record_full(rec):
|
def record_full(rec):
|
||||||
return {n: b64(rec['layers'][n]) for n in rec['layers']}
|
return {n: b64(rec['layers'][n]) for n in rec['layers']}
|
||||||
@@ -267,6 +267,7 @@ def _load_state():
|
|||||||
USERS.update(data.get('USERS', {}))
|
USERS.update(data.get('USERS', {}))
|
||||||
for rid, r in data.get('RECORDS', {}).items():
|
for rid, r in data.get('RECORDS', {}).items():
|
||||||
r['layers'] = {n: base64.b64decode(v) for n, v in r.get('layers', {}).items()}
|
r['layers'] = {n: base64.b64decode(v) for n, v in r.get('layers', {}).items()}
|
||||||
|
r['public'] = [n for n in PUBLIC_LAYERS if n in r.get('public', PUBLIC_LAYERS)]
|
||||||
RECORDS[rid] = r
|
RECORDS[rid] = r
|
||||||
COLLECTIONS.update(data.get('COLLECTIONS', {}))
|
COLLECTIONS.update(data.get('COLLECTIONS', {}))
|
||||||
COMMENTS.update(data.get('COMMENTS', {}))
|
COMMENTS.update(data.get('COMMENTS', {}))
|
||||||
@@ -518,7 +519,7 @@ def create_record():
|
|||||||
return (jsonify(error='source not found'), 404)
|
return (jsonify(error='source not found'), 404)
|
||||||
if srec2['owner'] != user:
|
if srec2['owner'] != user:
|
||||||
inherit = {n: srec2['layers'][n]
|
inherit = {n: srec2['layers'][n]
|
||||||
for n in srec2['public'] if n in srec2['layers']}
|
for n in PUBLIC_LAYERS if n in srec2['layers']}
|
||||||
else:
|
else:
|
||||||
inherit = dict(srec2['layers'])
|
inherit = dict(srec2['layers'])
|
||||||
for n, b in inherit.items():
|
for n, b in inherit.items():
|
||||||
@@ -669,7 +670,7 @@ def trailer(rid):
|
|||||||
expected = trailer_sig(rid, wanted)
|
expected = trailer_sig(rid, wanted)
|
||||||
if not hmac.compare_digest(sig, expected):
|
if not hmac.compare_digest(sig, expected):
|
||||||
return (jsonify(error='bad signature'), 403)
|
return (jsonify(error='bad signature'), 403)
|
||||||
if rec['owner'] != user and any(name not in rec['public'] for name in wanted):
|
if rec['owner'] != user and any(name not in PUBLIC_LAYERS for name in wanted):
|
||||||
return (jsonify(error='forbidden'), 403)
|
return (jsonify(error='forbidden'), 403)
|
||||||
out = {n: b64(rec['layers'][n]) for n in wanted if n in KNOWN_LAYERS and n in rec['layers']}
|
out = {n: b64(rec['layers'][n]) for n in wanted if n in KNOWN_LAYERS and n in rec['layers']}
|
||||||
return jsonify(id=rid, layers=out)
|
return jsonify(id=rid, layers=out)
|
||||||
|
|||||||
Reference in new issue
Block a user