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] ORCID login [#OSF-5162, 6881, 6885] #6192

Merged
merged 49 commits into from
Aug 26, 2016
Merged

Conversation

mfraezz
Copy link
Member

@mfraezz mfraezz commented Aug 23, 2016

Purpose

Allow users to login via ORCID's OAuth.

Changes

  • New DictionaryField on User to store external auth ID's
  • Custom login flow
  • Login template changes
  • Tests
  • Email templates for this auth process
  • Update keys from CAS

Sample CAS Response:

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>OrcidProfile#8733-8493-5068-5235</cas:user>
        <cas:attributes>
            <cas:given-names>Carolynn</cas:given-names>
            <cas:isFromNewLogin>true</cas:isFromNewLogin>
            <cas:authenticationDate>Tue Aug 23 00:09:02 EDT 2016</cas:authenticationDate>
            <cas:longTermAuthenticationRequestTokenUsed>false</cas:longTermAuthenticationRequestTokenUsed>
            <cas:accessToken>AT-1-0838eb2b58f4b6b0ecfdf7bd63f521447e3ef141a987f64c27df7beb4ba11341</cas:accessToken>
            <cas:family-name>Emmerich</cas:family-name>
        </cas:attributes>
    </cas:authenticationSuccess>
</cas:serviceResponse>

Side effects

None expected

Ticket

OSF-6885
OSF-6881
OSF-5162

cslzchen and others added 13 commits August 19, 2016 12:59
    - add `oauth` dictionary field
    - update `get_user()` to retrieve user based on oauth provider and id
    - add `get_user_from_cas_response(cas_resp)` to recognize oauth credential
    - add `oauth_first_time_authenticate(oauth_user, response)` to
        - create a unauthenticated session to store user oauth credentials
        - redirect to a new view where user is asked to enter email
    - if user exists (either fromm user id or oauth credential), go to `authenticate(user, access_token, response)`
    - if oauth credential exists but no user found, go to user `oauth_first_time_authenticate(oauth_user, response)`
    - otherwise, unauthorized
… create or link OSF accounts. Part 1.

    - general struture guide
    - update routes, makos, and forms
    - add `Session.is_oauth_first_time_login` and only allow the views to be reached by oauth first login
    - both link and create requires user verify email
    - session and cookie should be removed after done
    - create user, send confirmation email, verify email
    - use ${oauth_provider} in `get_oauth_email.mako`
    - add push notifications
    - `User.oauth` -> `User.external_identity`
    - update related mehtods, views, routes, makos change
    - 'VERIFIED', 'CREATE', 'LINK'
    - update `get_user` to check `status` and only return verified user
    - `send_confirm_email` takes extra parameter `external_identity` and use dedicated email templates
    - `exteranl_login_email_post()`: return a warn message if user is already associated with another external idp
    - update mail templates and messsages
…ccount creation.

    - add new routes `/confirm/external/<uid>/<token>` for confirmation link
    - add new view  `external_login_confirm_email_get` to simplify account creation and linking
    - update `add_unconfirmed_email`, `send_confirm_email`,`get_confirmation_email` and `create_unconfirmed`
    - update TODO list and comments
@@ -19,6 +19,7 @@
'get_user',
'check_password',
'authenticate',
'oauth_first_time_authenticate',
Copy link
Member Author

Choose a reason for hiding this comment

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

This probably needs to be updated.


return {
'form': form,
'external_id_provider': external_id_provider.upper()
Copy link
Member Author

Choose a reason for hiding this comment

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

This shouldn't be calling .upper()

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. external_id_provider used to be all lower-case and this .upper() is only for ORCID . With the new PR, it becomes what they should be in default settings for different external identity providers. There are other places that I used .upper() and I will fix all.

@mfraezz mfraezz changed the title [Hold][Feature] ORCID login [#OSF-5162, 6881, 6885] [Feature] ORCID login [#OSF-5162, 6881, 6885] Aug 23, 2016
@cslzchen
Copy link
Contributor

Related CAS PR: CenterForOpenScience/cas-overlay#22.

@sloria sloria merged commit 442cf3c into develop Aug 26, 2016
@sloria sloria deleted the feature/orcid-login branch August 26, 2016 17:00
@@ -264,7 +264,7 @@ def make_response_from_ticket(ticket, service_url):
user = {
'external_id_provider': external_credential['provider'],
'external_id': external_credential['id'],
'fullname': cas_resp.attributes['given-names'] + ' ' + cas_resp.attributes['family-name'],
'fullname': '{} {}'.format(cas_resp.attributes.get('given-names'), cas_resp.attributes.get('family-name')),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI: If both names are empty, use the ORCiD id instead. (HotFixed)

Copy link
Member Author

Choose a reason for hiding this comment

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

When testing on the ORCiD website, they seemed to disallow an empty given-names.

Copy link
Contributor

@cslzchen cslzchen Sep 2, 2016

Choose a reason for hiding this comment

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

User can make their profile private and only ORCiD is returned. This is a very rare case we happened to run into. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants