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

[ENG-2224] Access Token Edit Scopes #2022

Merged
merged 17 commits into from
Oct 23, 2023

Conversation

chth0n1x
Copy link
Contributor

@chth0n1x chth0n1x commented Oct 9, 2023

Purpose

The purpose of these changes is to have the edit token page and its scopes properly displayed following new access token creation.

Summary of Changes

  • The access token value is now cleared when the 'Edit scopes' button is pressed following token creation

Screenshot(s)

Pasted Graphic 1

Figure 1: Initial access token scope selection

Pasted Graphic 2

Figure 2: Display of a new access token if the token value is present

Pasted Graphic 4

Figure 3: Scopes properly display when clicking the 'Edit scopes' button

Pasted Graphic 5

Figure 4: Saving the changes results in the token's scopes being updated

Pasted Graphic 6

Figure 5: Clicking on the access token within the list view properly displays updated scopes

image

Figure 6: Deletion of token following clicking the 'Edit token' button

Side Effects

There should be no side effects.

QA Notes

  • Upon clicking the 'Edit scopes' button following new access token creation, do the previously-selected scopes properly display?
  • Can you add/remove scopes?
  • Can you save the token?
  • Can you view the token when clicking on its link in the list view?

@chth0n1x chth0n1x changed the title [ENG-2224] Access token Edit Scopes [ENG-2224] Access Token Edit Scopes Oct 9, 2023
@coveralls
Copy link

coveralls commented Oct 9, 2023

Pull Request Test Coverage Report for Build 6584020659

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.005%) to 71.162%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/settings/tokens/-components/edit-form/component.ts 0 2 0.0%
Totals Coverage Status
Change from base Build 6552310919: -0.005%
Covered Lines: 5941
Relevant Lines: 8133

💛 - Coveralls

Copy link
Contributor

@adlius adlius left a comment

Choose a reason for hiding this comment

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

Checked this out locally. When I try to delete the token after hitting Edit scopes the modal freezes and it toasts an error even though the deletion succeeds.
Apart from the buggy behavior when deleting, this fix introduces a security problem. The personal access token should only be viewable once. Setting the tokenValue on the token model to undefined will bring back the edit form for sure, but the model's tokenValue can easily be found by calling rollbackAttributes on the model, therefore revealing the tokenValue again. That is why we need to invoke clearTokenValue() when we go back to edit the scopes to unload the token model from store and reload from the BE.

app/settings/tokens/edit/controller.ts Outdated Show resolved Hide resolved
@chth0n1x chth0n1x force-pushed the access-token-edit-scopes branch from e204f61 to a79e7b0 Compare October 11, 2023 17:19
@chth0n1x
Copy link
Contributor Author

Checked this out locally. When I try to delete the token after hitting Edit scopes the modal freezes and it toasts an error even though the deletion succeeds. Apart from the buggy behavior when deleting, this fix introduces a security problem. The personal access token should only be viewable once. Setting the tokenValue on the token model to undefined will bring back the edit form for sure, but the model's tokenValue can easily be found by calling rollbackAttributes on the model, therefore revealing the tokenValue again. That is why we need to invoke clearTokenValue() when we go back to edit the scopes to unload the token model from store and reload from the BE.

Hi @adlius the changes for the token value are now persisted with save(). The buggy behavior with the delete button has been mitigated but from local testing may still not be fully awaiting. An await has been added to the delete's save which seemed to improve the delete's functionality.

app/settings/tokens/-components/edit-form/component.ts Outdated Show resolved Hide resolved
app/settings/tokens/edit/controller.ts Outdated Show resolved Hide resolved
@chth0n1x chth0n1x force-pushed the access-token-edit-scopes branch from 5a1a713 to 1f43e14 Compare October 12, 2023 17:47
app/settings/tokens/edit/controller.ts Outdated Show resolved Hide resolved
app/settings/tokens/edit/template.hbs Outdated Show resolved Hide resolved
app/settings/tokens/edit/template.hbs Show resolved Hide resolved
Copy link
Contributor

@futa-ikeda futa-ikeda left a comment

Choose a reason for hiding this comment

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

One last minor thing, otherwise, looks good!

app/settings/tokens/edit/controller.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@futa-ikeda futa-ikeda left a comment

Choose a reason for hiding this comment

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

Sorry I'm catching this after an initial approval! It looks like the deleteToken action in the edit-form component should do this.token.deleteRecord(); followed by an await this.token.save();, instead of the await this.token!.destroyRecord(); that's in there right now. Not 100% sure why the delete and save works but the destroy does not, but it was correct in being there 🙇

@chth0n1x
Copy link
Contributor Author

Sorry I'm catching this after an initial approval! It looks like the deleteToken action in the edit-form component should do this.token.deleteRecord(); followed by an await this.token.save();, instead of the await this.token!.destroyRecord(); that's in there right now. Not 100% sure why the delete and save works but the destroy does not, but it was correct in being there 🙇

Thank you and understood. They have been re-added. If you would also like to see validation for the token in an if statement, just let me know. Currently, it is using the ! syntax for the token that was previously in place.

@adlius adlius merged commit 0230115 into CenterForOpenScience:develop Oct 23, 2023
9 checks passed
@futa-ikeda futa-ikeda added this to the 23.13.0 milestone Oct 23, 2023
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.

5 participants