Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
version 20200709.2, restapi masks passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Jul 10, 2020
1 parent 61c14cb commit 168c172
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pydal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "20200709.1"
__version__ = "20200709.2"

from .base import DAL
from .objects import Field
Expand Down
12 changes: 10 additions & 2 deletions pydal/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,17 @@ def filter_fieldnames(table, fieldnames):
queries.append(table)

query = functools.reduce(lambda a, b: a & b, queries)
tfields = [table[tfieldname] for tfieldname in tfieldnames]
tfields = [table[tfieldname] for tfieldname in tfieldnames if
table[tfieldname].type != 'password']
passwords = [tfieldname for tfieldname in tfieldnames if
table[tfieldname].type == 'password']
rows = db(query).select(
*tfields, limitby=(offset, limit + offset), orderby=orderby
)
if passwords:
dpass = {password: '******' for password in passwords}
for row in rows:
row.update(dpass)

lookup_map = {}
for key in list(lookup.keys()):
Expand All @@ -455,7 +462,8 @@ def filter_fieldnames(table, fieldnames):
tfieldnames = filter_fieldnames(ref_table, tfieldnames)
check_table_lookup_permission(ref_tablename)
ids = [row[key] for row in rows]
tfields = [ref_table[tfieldname] for tfieldname in tfieldnames]
tfields = [ref_table[tfieldname] for tfieldname in tfieldnames if
ref_table[tfieldname].type == 'password']
if not "id" in tfieldnames:
tfields.append(ref_table["id"])
drows = db(ref_table._id.belongs(ids)).select(*tfields).as_dict()
Expand Down

0 comments on commit 168c172

Please sign in to comment.