Skip to content

Fix/eng 11829 2 - #11885

Open
Vlad0n20 wants to merge 3 commits into
CenterForOpenScience:feature/pbs-26-15from
Vlad0n20:fix/ENG-11829-2
Open

Fix/eng 11829 2#11885
Vlad0n20 wants to merge 3 commits into
CenterForOpenScience:feature/pbs-26-15from
Vlad0n20:fix/ENG-11829-2

Conversation

@Vlad0n20

Copy link
Copy Markdown
Contributor

Ticket

Purpose

Changes

Side Effects

QE Notes

CE Notes

Documentation

@cslzchen cslzchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

1st pass done

Comment thread framework/auth/cas.py
Comment on lines +276 to +280
sentry.log_message(
f'CAS response ORCID attributes: user=[{user._id}], orcidId=[{orcid_id}], '
f'orcidAccessToken=[{"present" if access_token else "missing"}]',
level=logging.INFO,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only log message to sentry if access token or refresh token are missing, level is warning

Comment thread osf/models/user.py Outdated
# },
# ...
# }
external_identity_access_token = DateTimeAwareJSONField(default=dict, blank=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

external_identity_tokens

Comment thread framework/auth/cas.py Outdated
Comment on lines +315 to +316
access_token = cas_resp.attributes.get('orcidAccessToken', None)
refresh_token = cas_resp.attributes.get('orcidRefreshToken', None)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move into if external_credential:

Comment thread framework/auth/cas.py Outdated
external_credential['id'],
access_token,
refresh_token,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need for this

Comment thread osf/models/user.py Outdated
f'found {len(orcid_tokens)} ORCID token(s) to revoke',
level=logging.INFO,
)
for orcid_id, orcid_token in orcid_tokens.items():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to check if there is an external_identity but there is no matching external_identity_tokens, we need to fail the GDPR delete with relevant error messsage.

Comment thread osf/models/user.py Outdated
'client_secret': website_settings.ORCID_OAUTH_CLIENT_SECRET,
'token': orcid_token,
},
timeout=5,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Future, we probably want a retry just in case

Comment thread osf/models/user.py Outdated
)
sentry.log_message(
f'[GDPR delete] user={self._id}: ORCID id={orcid_id} revoked, '
f'status_code={response.status_code}, response_text={response.text}, response={response}',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we probably don't need the full response

Comment thread osf/models/user.py
f'status_code={response.status_code}, response_text={response.text}, response={response}',
level=logging.INFO,
)
response.raise_for_status()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add unit tests for success, invalid client_id/secret, invalid token, empty token

Comment thread osf/models/user.py Outdated
response.raise_for_status()
except requests.exceptions.RequestException as e:
sentry.log_message(
f'[GDPR delete] Failed to revoke ORCID token for user {self._id}: {e}',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add the orcid id just in case user has mulitple

Comment thread osf/models/user.py Outdated
Comment on lines +2196 to +2197
'Unable to revoke this user\'s ORCID access right now because ORCID\'s '
'service could not be reached. Please try the GDPR delete again later.'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rephrase to a more general message like fail to revoke

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.

2 participants