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

upcoming, change: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers #9992

Merged

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Dec 12, 2023

Description 📝

New Scope:
Introduce a new OAuth scope named "child_account" for all users, but visible only to "Parent" accounts. As per API spec: its purpose is to allow Parent Account Users with the child_account_access grant to specify a Token with less permission than their User, i.e. a Token that is unable to list and/or create Tokens for the Child Account(s).

Token Configuration:
Default all scopes to none for users. Users should enable scopes as needed, contrary to having the initial state set to read_write.

Changes 🔄

  • In the Create PAT drawer, a new "Child Account Access" scope is visible for parent users.
  • In the View PAT drawer, a new "Child Account Access" scope is visible for parent users.

Preview 📷

Before After
Screenshot 2023-12-13 at 4 01 40 PM Screenshot 2023-12-13 at 4 00 48 PM
Screenshot 2023-12-13 at 4 02 58 PM Screenshot 2023-12-13 at 4 03 14 PM

How to test 🧪

Prerequisites

(How to setup test environment)

  • Check out this PR and yarn dev.
  • In the dev tools:
    • Make sure the Parent/Child Account Switching feature flag is on.
    • Turn mocks on.

Verification steps

(How to verify changes)

  • Go to http://localhost:3000/profile/tokens and click the Create a Personal Access Token button.
  • Observe that "Child Account Access" is visible as a new scope and all scopes default to None.
  • On the tokens landing page, click the View Scope button for any mock PAT.
  • Observe that the "Child Account Access" scope is visible in the table.
  • Toggle the feature flag off and observe that the Child Account Access token is not visible in the Create or View drawers and all scopes default to Read/Write.
  • Toggle the feature flag back on.
  • Go to serverHandler.ts and edit the following request to change the user_type to null, child, or proxy:
  rest.get('*/account/users/:user', (req, res, ctx) => {
    // Parent/Child: switch the `user_type` depending on what account view you need to mock.
    return res(ctx.json(accountUserFactory.build({ user_type: 'parent' })));
  }),
  • Observe that the Child Account Access token is not visible in the Create or View drawers.
  • Verify tests pass:
yarn test utils CreateAPITokenDrawer ViewAPITokenDrawer

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@mjac0bs mjac0bs force-pushed the M3-7411-add-new-oauth-scope-to-new-endpoints branch from 70f1a49 to adb0d02 Compare December 13, 2023 23:38
@mjac0bs mjac0bs changed the title upcoming: [M3-7411] - Add child_account OAuth scope to Create and View PAT drawers upcoming: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers Dec 18, 2023
@mjac0bs mjac0bs added UX/UI Changes for UI/UX to review and removed Work in Progress labels Dec 18, 2023
@mjac0bs mjac0bs marked this pull request as ready for review December 18, 2023 23:05
@mjac0bs mjac0bs requested a review from a team as a code owner December 18, 2023 23:05
@mjac0bs mjac0bs requested review from cpathipa, coliu-akamai and tyler-akamai and removed request for a team December 18, 2023 23:05
Copy link
Contributor

@jaalah-akamai jaalah-akamai left a comment

Choose a reason for hiding this comment

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

Approving pending some revisions - I was able to test everything as listed and the tests passed ✅

@tyler-akamai
Copy link
Contributor

tyler-akamai commented Dec 19, 2023

Verified:

  • The "Child Account Access" is visible as a new scope and all scopes default to None.
  • The "Child Account Access" scope is visible in the table.
  • The Child Account Access token is not visible in the Create or View drawers and all scopes default to Read/Write when feature flag is turned off
  • The Child Account Access token is not visible in the Create or View drawers after making the code change
  • yarn test utils CreateAPITokenDrawer ViewAPITokenDrawer passes
  • General code review

LGTM 🚀

Copy link

github-actions bot commented Dec 19, 2023

Coverage Report:
Base Coverage: 78.07%
Current Coverage: 78.07%

@mjac0bs mjac0bs changed the title upcoming: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers upcoming, changed: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers Dec 19, 2023
@mjac0bs mjac0bs changed the title upcoming, changed: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers upcoming, change: [M3-7524] - Add child_account OAuth scope to Create and View PAT drawers Dec 19, 2023
@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed UX/UI Changes for UI/UX to review labels Dec 20, 2023
@mjac0bs mjac0bs merged commit d5ed30b into linode:develop Dec 20, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Parent / Child Account
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants