Skip to content
Snippets Groups Projects

Create new policies for read, destroy, and create tokens

Merged Serena Fang requested to merge sfang-token-read-write-permissions into master
All threads resolved!

What does this MR do?

There are a few places in our codebase where can?(:admin_resource_access_tokens) is too broad, for example in the project access token API GET method where the user only needs token read permissions or when group admins want to (WIP) disable the creation of project access tokens but should still be able to read and destroy existing tokens. This MR breaks down the can?(:admin_resource_access_tokens) permission into create_*, read_*, and destroy_*.

It also introduces a column to namespace_settings called resource_access_token_creation_allowed, and introduces a policy called resource_access_token_creation_allowed? to add meaningful specs for the new create_*, read_*, and destroy_* policies, and to facilitate future work on disabling project access tokens.

Migration output:

Up:

% rails db:migrate
== 20210312193532 AddResourceAccessTokenCreationAllowedToNamespaceSettings: migrating 
-- add_column(:namespace_settings, :resource_access_token_creation_allowed, :boolean, {:default=>true, :null=>false})
   -> 0.0030s
== 20210312193532 AddResourceAccessTokenCreationAllowedToNamespaceSettings: migrated (0.0178s) 

Down:

% rails db:rollback STEP=1
== 20210312193532 AddResourceAccessTokenCreationAllowedToNamespaceSettings: reverting 
-- remove_column(:namespace_settings, :resource_access_token_creation_allowed)
   -> 0.0013s
== 20210312193532 AddResourceAccessTokenCreationAllowedToNamespaceSettings: reverted (0.0084s) 

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Serena Fang

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Manoj M J
  • Manoj M J
  • Manoj M J
  • Manoj M J
  • Manoj M J
  • Manoj M J
  • Manoj M J
  • Alina Mihaila
  • Alina Mihaila approved this merge request

    approved this merge request

  • assigned to @toon

  • Alina Mihaila requested review from @toon

    requested review from @toon

  • Alexander Turinske approved this merge request

    approved this merge request

  • Alexander Turinske requested review from @mrincon

    requested review from @mrincon

  • Serena Fang added 1 commit

    added 1 commit

    Compare with previous version

  • Serena Fang added 1 commit

    added 1 commit

    • 402b1a1e - Rename resource access token available

    Compare with previous version

  • Serena Fang added 3 commits

    added 3 commits

    • c6af9043 - Revert "Address MR review comments"
    • 6a9a9ad2 - Revert "Rename resource access token available"
    • f3801164 - Add before checks to controller

    Compare with previous version

  • Serena Fang added 1 commit

    added 1 commit

    • b8601b56 - Render create token form if can create token

    Compare with previous version

  • Manoj M J
  • Manoj M J approved this merge request

    approved this merge request

  • Miguel Rincon marked the checklist item Label as security and @ mention @gitlab-com/gl-security/appsec as completed

    marked the checklist item Label as security and @ mention @gitlab-com/gl-security/appsec as completed

  • added security label

  • Toon Claes approved this merge request

    approved this merge request

  • added databaseapproved label and removed databasereviewed label

  • unassigned @toon

  • Serena Fang added 1 commit

    added 1 commit

    • 4331ffa0 - Add case for check permissions

    Compare with previous version

  • Serena Fang changed title from Create new policies for read and destroy tokens to Create new policies for read, destroy, and create tokens

    changed title from Create new policies for read and destroy tokens to Create new policies for read, destroy, and create tokens

  • Serena Fang added 1 commit

    added 1 commit

    Compare with previous version

  • Serena Fang requested review from @ebaque

    requested review from @ebaque

  • Serena Fang added 1468 commits

    added 1468 commits

    • f5f5a101...78c22ade - 1460 commits from branch master
    • 19feb4d9 - Create new policies for read and destroy tokens
    • 62bab8a5 - Add specs for read and destroy tokens
    • c505e3e6 - Add resource access token creation enabled to table
    • 1a2a81e4 - Fix read token usage
    • be46d649 - Add changelog entry
    • aba9635d - Render create token form if can create token
    • ccbbd7c4 - Add case for check permissions
    • 918e746c - Modify changelog entry

    Compare with previous version

  • Bundle size analysis [beta]

    This compares changes in bundle size for entry points between the commits b4bf4e7a and 22b99a52

    :sparkles: Special assets

    Entrypoint / Name Size before Size after Diff Diff in percent
    average 3.04 MB 3.04 MB - 0.0 %
    mainChunk 1.87 MB 1.87 MB - 0.0 %

    Note: We do not have exact data for b4bf4e7a. So we have used data from: c73795c6.
    The intended commit has no webpack pipeline, so we chose the last commit with one before it.

    Please look at the full report for more details


    Read more about how this report works.

    Generated by :no_entry_sign: Danger

    Edited by 🤖 GitLab Bot 🤖
  • Serena Fang added 12 commits

    added 12 commits

    • 918e746c...761a8b63 - 4 commits from branch master
    • 907cc6b0 - Create new policies for read and destroy tokens
    • 915c1588 - Add specs for read and destroy tokens
    • 754f3c40 - Add resource access token creation enabled to table
    • 851c6c35 - Fix read token usage
    • efdaeb7e - Add changelog entry
    • 4e1e0514 - Render create token form if can create token
    • b53f605e - Add case for check permissions
    • be41d8f7 - Modify changelog entry

    Compare with previous version

  • Manoj M J
  • Serena Fang added 1 commit

    added 1 commit

    • 76c501e0 - Simplify check permissions method

    Compare with previous version

  • Andrew Kelly requested review from @ankelly

    requested review from @ankelly

  • Andrew Kelly approved this merge request

    approved this merge request

  • Sanad Liaquat approved this merge request

    approved this merge request

  • Miguel Rincon approved this merge request

    approved this merge request

  • Sanad Liaquat removed review request for @sliaquat

    removed review request for @sliaquat

  • Etienne Baqué
  • Serena Fang added 1 commit

    added 1 commit

    • 79f7d5ce - Change return super to return true

    Compare with previous version

  • Serena Fang added 487 commits

    added 487 commits

    • 79f7d5ce...82da9ec1 - 477 commits from branch master
    • e0426202 - Create new policies for read and destroy tokens
    • 3d336c75 - Add specs for read and destroy tokens
    • 7ad926ff - Add resource access token creation enabled to table
    • 8f4591ca - Fix read token usage
    • 88b2fe69 - Add changelog entry
    • 7ceec68d - Render create token form if can create token
    • 8df9d4ed - Add case for check permissions
    • 4ca6508f - Modify changelog entry
    • be8586b4 - Simplify check permissions method
    • ef9e97a3 - Change return super to return true

    Compare with previous version

  • Serena Fang added 1 commit

    added 1 commit

    • 00b62cf9 - Change group and policy to return super

    Compare with previous version

  • Serena Fang added 246 commits

    added 246 commits

    • 00b62cf9...bb2bcbd3 - 235 commits from branch master
    • 11d2b257 - Create new policies for read and destroy tokens
    • c70a6991 - Add specs for read and destroy tokens
    • 2ec1bf43 - Add resource access token creation enabled to table
    • e5b48982 - Fix read token usage
    • 8e4db7c6 - Add changelog entry
    • 0bab2291 - Render create token form if can create token
    • 2d5788db - Add case for check permissions
    • 2826c64f - Modify changelog entry
    • e418a0d0 - Simplify check permissions method
    • 9b563145 - Change return super to return true
    • 22b99a52 - Change group and policy to return super

    Compare with previous version

  • Alex Kalderimis resolved all threads

    resolved all threads

  • Alex Kalderimis approved this merge request

    approved this merge request

  • Alex Kalderimis enabled an automatic merge when the pipeline for cf25a5ce succeeds

    enabled an automatic merge when the pipeline for cf25a5ce succeeds

  • Alex Kalderimis mentioned in commit 8d8c1e2e

    mentioned in commit 8d8c1e2e

  • Serena Fang mentioned in merge request !53783 (closed)

    mentioned in merge request !53783 (closed)

  • Serena Fang mentioned in merge request !57756 (merged)

    mentioned in merge request !57756 (merged)

  • added workflowproduction label and removed workflowstaging label

  • Congratulations :tada: @serenafang, your Issue/Merge Request has been awarded! (Learn more about the Security Awards Program)

  • Jason Goodman mentioned in merge request !62731 (merged)

    mentioned in merge request !62731 (merged)

  • Please register or sign in to reply
    Loading