Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Normalize OSF Verification Key [#OSF-6560] #5964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c1bf666
Add verification_key_v2 which contains key, username and expiration t…
cslzchen Jul 12, 2016
16bab4f
Add generate_verification_key_v2().
cslzchen Jul 12, 2016
01c28f7
Reorder imports order for auth core.
cslzchen Jul 12, 2016
9a6b2ba
Forgot and reset password now use verfication key version 2.
cslzchen Jul 12, 2016
7437496
Remove username from verification_key_v2, invalid verification_key_v2…
cslzchen Jul 12, 2016
ae0c145
Add expiration check for user unclaimed_records.
cslzchen Jul 13, 2016
7ecf373
Add `expires` to contributor claim.
cslzchen Jul 15, 2016
b1a6581
Temporarily remove `expires` check for unclaimed_records. [skip ci]
cslzchen Jul 15, 2016
c9dc259
Renew email verifications token when resending confirmation. [skip ci]
cslzchen Jul 15, 2016
c8a0fac
Add empty claim_user_form_get and claim_user_form_post. [skip ci]
cslzchen Jul 17, 2016
f46c8a0
Add expiration time to settings and enable contributor claim check. […
cslzchen Jul 19, 2016
d459d8f
Revert "Add empty claim_user_form_get and claim_user_form_post. [skip…
cslzchen Jul 19, 2016
2e4ea05
Fix web_url_for('reset_password_get') in conference views.
cslzchen Jul 20, 2016
617d2eb
Update tests for forgot and reset password, add attribute and key che…
cslzchen Jul 20, 2016
6be7705
Raise ValueError in get_claim_url if no record on a given project.
cslzchen Jul 20, 2016
e538758
Merge remote-tracking branch 'upstream/develop' into feature/verifica…
cslzchen Jul 20, 2016
93d947e
Fix conflicts and merge remote-tracking branch 'upstream/develop' int…
cslzchen Aug 4, 2016
d6e09ab
Minor improvement and fixes after fixing conflicts.
cslzchen Aug 4, 2016
a3114d4
start from longze's base
chennan47 Aug 8, 2016
9ceb096
fix the unclaimed contributor reset passowrd
chennan47 Aug 8, 2016
7968675
Merge remote-tracking branch 'upstream' into feature/verification-key.
cslzchen Aug 8, 2016
810abe3
merge
chennan47 Aug 8, 2016
12d1308
merge
chennan47 Aug 8, 2016
9f3b5c5
Merge remote-tracking branch 'upstream/develop' into feature/verifica…
cslzchen Aug 8, 2016
28f8f83
merge from longze
chennan47 Aug 8, 2016
52836d8
Merge pull request #11 from chennan47/feature/reset_password.
cslzchen Aug 8, 2016
96b0c5e
Fix conflicts and merge remote-tracking branch 'upstream/develop' int…
cslzchen Aug 31, 2016
1311351
Use email instead of username in `get_user()`. [skip ci]
cslzchen Aug 31, 2016
f627c6b
Normalize verification key generation based on type.
cslzchen Sep 1, 2016
8ad4a94
Forgot/Reset password use normalized verification key: [skip ci]
cslzchen Sep 1, 2016
042e2ca
Improve comment and logic for claim contributor-ship:
cslzchen Sep 1, 2016
6dd18d2
Claim contributor-ship uses normalized verification key.
cslzchen Sep 1, 2016
0ca06e0
Send/Resend confirmation uses normalized verification key. [skip ci]
cslzchen Sep 1, 2016
d9a5d64
Remove deprecated code.
cslzchen Sep 2, 2016
7e862d9
Update unit tests.
cslzchen Sep 2, 2016
576afb0
Temporary fix for #OSF-6673.
cslzchen Sep 2, 2016
ffc82ec
Minor sytle fix.
cslzchen Sep 6, 2016
6a95638
Merge remote-tracking branch 'upstream/develop' into feature/verifica…
cslzchen Sep 6, 2016
3385da7
Remove deprecated api call to `reset_password_post`.
cslzchen Sep 6, 2016
bb65649
Remove duplicated code for pushing status message.
cslzchen Sep 6, 2016
31d08eb
Improve error message with product.
cslzchen Sep 6, 2016
f357253
Remove `#TODO`.
cslzchen Sep 7, 2016
474c1a2
Fix conflicts and merge remote-tracking branch 'upstream/develop' int…
cslzchen Sep 20, 2016
d589f24
Remove unnecessary use of `generate_verification_key()`.
cslzchen Sep 20, 2016
c8bb69b
Update verification key generation in `auth.get_or_create_user()`.
cslzchen Sep 20, 2016
e3a4137
Update `auth.get_or_create_user()`:
cslzchen Sep 20, 2016
10419b7
Minor fixes.
cslzchen Sep 21, 2016
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
2 changes: 1 addition & 1 deletion api/base/authentication/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class ODMBackend(object):

def authenticate(self, username=None, password=None):
return get_user(username=username, password=password) or None
return get_user(email=username, password=password) or None

def get_user(self, user_id):
return User.load(user_id)
2 changes: 1 addition & 1 deletion api/institutions/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def authenticate(self, request):
username = provider['user']['username']
fullname = provider['user']['fullname']

user, created = get_or_create_user(fullname, username)
user, created = get_or_create_user(fullname, username, reset_password=False)

if created:
user.given_name = provider['user'].get('givenName')
Expand Down
17 changes: 10 additions & 7 deletions framework/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,24 @@ def register_unconfirmed(username, password, fullname, campaign=None):
return user


def get_or_create_user(fullname, address, is_spam=False):
"""Get or create user by email address.
def get_or_create_user(fullname, address, reset_password=True, is_spam=False):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add reset_password:

  1. for new user from institution login, no need to ask user to reset password after creation, thus no verification key
  2. for conference add_poster_by_email, create user and send user confirmation email to reset password, generate reset password verification key

"""
Get or create user by fullname and email address.

:param str fullname: User full name
:param str address: User email address
:param bool is_spam: User flagged as potential spam
:return: Tuple of (user, created)
:param str fullname: user full name
:param str address: user email address
:param boolean reset_password: ask user to reset their password
:param bool is_spam: user flagged as potential spam
:return: tuple of (user, created)
"""
user = get_user(email=address)
if user:
return user, False
else:
password = str(uuid.uuid4())
user = User.create_confirmed(address, password, fullname)
user.verification_key = generate_verification_key()
if password:
user.verification_key_v2 = generate_verification_key(verification_type='password')
if is_spam:
user.system_tags.append('is_spam')
return user, True
Loading