Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ocflib/account/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ def validate_calnet_uid(uid):
if not attrs:
raise ValidationError("CalNet UID can't be found in university LDAP.")

# TODO: Uncomment when we get privileged LDAP bind.
# check if user is eligible for an account
affiliations = attrs['berkeleyEduAffiliations']
if not eligible_for_account(affiliations):
raise ValidationWarning(
'Affiliate type not eligible for account: ' + str(affiliations))
# affiliations = attrs['berkeleyEduAffiliations']
# if not eligible_for_account(affiliations):
# raise ValidationWarning(
# 'Affiliate type not eligible for account: ' + str(affiliations))


def eligible_for_account(affiliations):
Expand Down
3 changes: 2 additions & 1 deletion ocflib/vhost/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def eligible_for_vhost(user):
return True
elif 'calnetUid' in attrs:
attrs_ucb = user_attrs_ucb(attrs['calnetUid'])
if attrs_ucb and 'EMPLOYEE-TYPE-ACADEMIC' in attrs_ucb['berkeleyEduAffiliations']:
# TODO: Uncomment when we get a privileged LDAP bind.
if attrs_ucb: # and 'EMPLOYEE-TYPE-ACADEMIC' in attrs_ucb['berkeleyEduAffiliations']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will permit arbitrary members of the OCF to submit vhost requests. You ought to be prepared for that.

return True

return False
1 change: 1 addition & 0 deletions tests/account/creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def test_validate_calnet_uid_error(self, bad_uid):
def test_validate_calnet_uid_success(self, mock_valid_calnet_uid):
validate_calnet_uid(9999999999999)

@pytest.mark.skip(reason='Checking for affiliations temp. patched out (ocflib PR 140)')
def test_validate_calnet_affiliations_failure(self, mock_invalid_calnet_uid):
with pytest.raises(ValidationWarning):
validate_calnet_uid(9999999999999)
Expand Down