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
|
||||
|
||||
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):
|
||||
return {n: b64(rec['layers'][n]) for n in rec['layers']}
|
||||
@@ -267,6 +267,7 @@ def _load_state():
|
||||
USERS.update(data.get('USERS', {}))
|
||||
for rid, r in data.get('RECORDS', {}).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
|
||||
COLLECTIONS.update(data.get('COLLECTIONS', {}))
|
||||
COMMENTS.update(data.get('COMMENTS', {}))
|
||||
@@ -518,7 +519,7 @@ def create_record():
|
||||
return (jsonify(error='source not found'), 404)
|
||||
if srec2['owner'] != user:
|
||||
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:
|
||||
inherit = dict(srec2['layers'])
|
||||
for n, b in inherit.items():
|
||||
@@ -669,7 +670,7 @@ def trailer(rid):
|
||||
expected = trailer_sig(rid, wanted)
|
||||
if not hmac.compare_digest(sig, expected):
|
||||
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)
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user