Skip to content

Commit

Permalink
feat(usync-emails): populate user email iff email provided or usernam…
Browse files Browse the repository at this point in the history
…e is email (#788)
  • Loading branch information
vpsx committed Jun 23, 2020
1 parent bc081d8 commit 0743817
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import paramiko
from cdislogging import get_logger
from email_validator import validate_email, EmailNotValidError
from gen3authz.client.arborist.client import ArboristError
from gen3users.validation import validate_user_yaml
from paramiko.proxy import ProxyCommand
Expand Down Expand Up @@ -217,12 +218,20 @@ def from_file(cls, filepath, encrypted=True, key=None, logger=None):
resource_permissions[resource] = set(project["privilege"])

user_info[username] = {
"email": details.get("email", username),
"email": details.get("email", ""),
"display_name": details.get("display_name", ""),
"phone_number": details.get("phone_number", ""),
"tags": details.get("tags", {}),
"admin": details.get("admin", False),
}
if not details.get("email"):
try:
valid = validate_email(
username, allow_smtputf8=False, check_deliverability=False
)
user_info[username]["email"] = valid.email
except EmailNotValidError:
pass
projects[username] = privileges
user_abac[username] = resource_permissions

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cdiserrors==0.1.2
cdispyutils==1.0.4
cryptography==2.8
datamodelutils==0.4.5
email_validator==1.1.1
Flask==1.1.1
Flask-CORS==3.0.3
Flask_OAuthlib==0.9.4
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"boto3>=1.5,<1.6",
"cached_property>=1.5.1,<2.0.0",
"cryptography==2.8",
"email_validator~=1.1.1",
"flask-restful>=0.3.6,<1.0.0",
"Flask>=1.1.1,<2.0.0",
"Flask-CORS>=3.0.3,<4.0.0",
Expand Down

0 comments on commit 0743817

Please sign in to comment.