GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Can we look into making ACL operations really nice for users? · Issue #351 · googleapis/google-cloud-node

Can we look into making ACL operations really nice for users? #351

New issue
Copy link
New issue
Copy link
Closed
#360
Closed
Can we look into making ACL operations really nice for users?#351
#360
Copy link
Assignees
stephenplusplus
Labels
🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.
Milestone
Storage Stable

Description

@jgeewax
jgeewax
opened on Jan 15, 2015
Issue body actions

** revised proposal: #351 (comment) **

Hi guys,

In gcloud-node, the ACL methods are very closely tied to the API specification, for example:

myBucket.acl.add({
  scope: '[email protected]',
  permission: Storage.acl.OWNER_ROLE
}, function(err, aclObject) {});

There are definitely times where I want to do low level operations, but other times I want to first-class citizen methods for the different options... Additionally, I now have to know a few things about this API:

  1. the name of the scope parameter
  2. the name of the permission parameter
  3. the fact that user's need to be prefixed with user-
  4. the constant for the name of the role (OWNER_ROLE... is it READER_ROLE or READ_ROLE ?) and where to look for those constants when I inevitably forget them...

Can take a stab at making this more friendly? For example, it might be cool to have:

myBucket.acl.owners.addUser('[email protected]', function(err, aclObject) {});
myBucket.acl.readers.removeDomain('example.com', function(err, aclObject) {});
myBucket.acl.writers.addAllUsers(function(err, aclObject) {});
myBucket.acl.readers.addAllAuthenticatedUsers(function(err, aclObject) {});

Or we could go the same route that gcloud-python went with the grant_* and revoke_* directives acting as the "commit" operation, so the code would look like:

myBucket.acl.user('[email protected]').grantOwner(function(err, aclObject) {})
myBucket.acl.domain('example.com').revokeRead(function(err, aclObject) {})
myBucket.acl.allUsers().grantWrite(function(err, aclObject) {})
myBucket.acl.allAuthenticatedUsers().grantRead(function(err, aclObject) {})

Ideally you could chain this stuff together:

myBucket.acl.user('[email protected]').user('[email protected]').grantOwner(function(err, aclObject) {})

Thoughts?

/cc @ryanseys @stephenplusplus

Activity

Next
  1. jgeewax
    added
    enhancement
    opinions wanted
    on Jan 15, 2015
  2. ryanseys commented on Jan 18, 2015

    @ryanseys
    ryanseys
    on Jan 18, 2015
    Contributor
    More actions

    I like the idea of having predefined bucket objects like .owners, .readers, .writers that we can add/remove users/domains, all users and such like the first example. The last chain example is weird because an operation on a user should not be another user, and might be better expressed as:

    myBucket.acl.user(['[email protected]', '[email protected]']).grantOwner(function(){});

    Additionally you should not be able to run a grant or revoke or whatever after a grant/revoke operation such as .grantOwner(function(){}).revokeReader(function(){}). That would be hard to understand again wouldn't make sense.
    The abstraction might be a little deep here though, e.g. many layers and objects to understand to do an operation with a simple email address.

  3. stephenplusplus commented on Jan 20, 2015

    @stephenplusplus
    stephenplusplus
    on Jan 20, 2015
    Contributor
    More actions

    I prefer the first example to the second, and here's another suggestion:

    var gcloud = require("gcloud")({ /*credentials*/ })
    var ACL = gcloud.storage.acl
    var myBucket = gcloud.storage.bucket("my-bucket")
    
    var user = ACL.user("[email protected]")
    var domain = ACL.domain("domain.com")
    
    myBucket.acl.owners.add([user, domain], function(err) {})
    myBucket.acl.writers.remove(user, function(err) {})
    
    myBucket.acl.writers.add(ACL.ALL_USERS, function(err) {})
    myBucket.acl.owners.add(ACL.AUTHENTICATED_USERS, function(err) {})

    This way a dev only needs to know two methods (add/remove), and the rest should be logical.

  4. jgeewax commented on Jan 20, 2015

    @jgeewax
    jgeewax
    on Jan 20, 2015
    ContributorAuthor
    More actions

    I'm down with the owners/writers/readers and add/remove.

    I'm not a fan of var user = ACL.user('...') -- it's more typing when we can figure out what people mean here, right?

    I also am not a huge fan of the ACL.ALL_USERS thing because it's a second import that we could handle with a method...

    I also think we should keep the shortcut for making public/private. So:

    var bucket = gcloud.storage.bucket('...');
    bucket.acl.owners.add('[email protected]', function(err) { });
    bucket.acl.readers.remove('domain.com', function(err) { });
    
    // Then the magic methods: addAll(), addAllAuthenticated(), makePublic(), makePrivate()
    bucket.acl.writers.addAll(); 
    bucket.acl.writers.addAllAuthenticated();
    bucket.acl.makePublic();
    bucket.acl.makePrivate();

    Thoughts?

  5. stephenplusplus commented on Jan 20, 2015

    @stephenplusplus
    stephenplusplus
    on Jan 20, 2015
    Contributor
    More actions

    I'm not a fan of var user = ACL.user('...') -- it's more typing when we can figure out what people mean here, right?

    https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls There are many types of "entities" that the API expects in string format matching the following conventions:

    user-userId
    user-email
    group-groupId
    group-email
    domain-domain
    project-team-projectId
    allUsers
    allAuthenticatedUsers
    

    I'm not sure parsing a string is going to be able to handle detecting what's a projectId vs a domain vs a groupId, etc. It would be easier to have methods for these, user, group, domain, team.

    I still think the way the library is now, adding permissions to a scope through methods like add and remove, is the most straight-forward this can be. Better documentation to explain scope is expected in the format of the JSON API's entity property would definitely help, however.

    Just to sum up my thoughts:

    • Keep the API the same as it is now
    • Document scope being the format of the entity property: https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls
    • Add helper methods:
      • (file || bucket).acl.makePublic(function(err) {})
      • (file || bucket).acl.makePrivate(function(err) {})
  6. stephenplusplus
    added
    api: storageIssues related to the Cloud Storage API.
    on Jan 20, 2015
  7. jgeewax commented on Jan 20, 2015

    @jgeewax
    jgeewax
    on Jan 20, 2015
    ContributorAuthor
    More actions

    I'm hugely -1 on scope and permission being the primary ways we do this, however I can see the concern regarding parsing strings.

    To be clear: I still think the current way we do it (with .add({scope: ...})) should still exist -- I just want these in addition to that way. I cannot see myself ever wanting to type scope: 'user-' + someUsername, and very much see myself wanting to type .addUser(someUsername). I also recognize that Google might add "newCategory-something" to the list, so it makes sense to keep this syntax around.

    Revised proposal

    1. Keep acl.add() (and acl.remove()?)
    2. Add owners/readers/writers that can be added/removed from.
    3. Add methods for the "all's": .addAll(), .addAllAuthenticated(), .removeAll(), .removeAllAuthenticated()
    4. Add methods for add/remove User/Domain/Project: .addUser(), .removeDomain(), etc
    5. Add shortcut methods for private/public: .makePrivate(), .makePublic()

    Example

    var bucket = gcloud.storage.bucket('...');
    bucket.acl.owners.addUser('[email protected]', function(err) { });
    bucket.acl.readers.removeDomain('domain.com', function(err) { });
    
    // Then the magic methods: addAll(), addAllAuthenticated(), makePublic(), makePrivate()
    bucket.acl.writers.addAll(function(err) { ... }); 
    bucket.acl.writers.addAllAuthenticated(function(err) { ... });
    bucket.acl.makePublic(function(err) { ... });
    bucket.acl.makePrivate(function(err) { ... });
  8. ryanseys commented on Jan 20, 2015

    @ryanseys
    ryanseys
    on Jan 20, 2015
    Contributor
    More actions

    If we make the helper methods for user, group, domain, project, allusers, allAuthenticated we will fit more closely with the gcloud-python library as well. Personally it's a little more verbose but it's easy to understand and I don't need to know prefixes at all! I'm really fond of stephen's suggestion earlier:

    var gcloud = require("gcloud")({ /*credentials*/ })
    var ACL = gcloud.storage.acl
    var myBucket = gcloud.storage.bucket("my-bucket")
    
    var user = ACL.user("[email protected]")
    var domain = ACL.domain("domain.com")
    
    myBucket.acl.owners.add([user, domain], function(err) {})
    myBucket.acl.writers.remove(user, function(err) {})
    
    myBucket.acl.writers.add(ACL.ALL_USERS, function(err) {})
    myBucket.acl.owners.add(ACL.AUTHENTICATED_USERS, function(err) {})
  9. jgeewax commented on Jan 20, 2015

    @jgeewax
    jgeewax
    on Jan 20, 2015
    ContributorAuthor
    More actions

    Are we all -1 to the .add<type>() methods? (acl.writers.addUser('[email protected]'))

    If so -- why is that? gcloud-python's syntax is slightly different, but along these lines (acl.user('[email protected]').grant_write())

  10. ryanseys commented on Jan 20, 2015

    @ryanseys
    ryanseys
    on Jan 20, 2015
    Contributor
    More actions

    Sorry @jgeewax, missed your most recent comment. I'm happy with that suggestion as well with the added benefit that we don't have magic constants for all users and all authenticated users! 👍

  11. ryanseys commented on Jan 20, 2015

    @ryanseys
    ryanseys
    on Jan 20, 2015
    Contributor
    More actions

    I'm not -1 for addUser and removeDomain etc... in fact, I like those. We can keep generic add and remove for backward compatibility and more "to the book" users.

  12. stephenplusplus
    self-assigned this
    on Jan 20, 2015
  13. stephenplusplus commented on Jan 20, 2015

    @stephenplusplus
    stephenplusplus
    on Jan 20, 2015
    Contributor
    More actions

    I'll start implementing #351 (comment) 👍

  14. jgeewax commented on Jan 20, 2015

    @jgeewax
    jgeewax
    on Jan 20, 2015
    ContributorAuthor
    More actions

    Cool 👍 ! Thanks guys !

  15. 44 remaining items

  16. sofisl
    added a commit that references this issue on Feb 5, 2026

    fix: include types in package (#351)

    7e18a42
  17. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    chore: do not run CI on grpc-js (#351)

    e6e965c
  18. sofisl
    added a commit that references this issue on Feb 17, 2026

    fix: include types in package (#351)

    3db892a
  19. GautamSharda
    added a commit that references this issue on Feb 23, 2026

    chore: do not run CI on grpc-js (#351)

    6716793
  20. sofisl
    added a commit that references this issue on Feb 25, 2026

    Add synth script and run it (#351)

    546b030
  21. GautamSharda
    added 2 commits that reference this issue on Feb 25, 2026

    build: add extra test for Node 20, update windows tests (#351)

    c4a7c93

    chore: do not run CI on grpc-js (#351)

    4e49c0b
  22. sofisl
    added a commit that references this issue on Feb 26, 2026

    chore(deps): update dependency eslint-plugin-prettier to v3 (#351)

    f65032c
  23. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    chore: update nyc and eslint configs (#351)

    deabd65
  24. sofisl
    added a commit that references this issue on Mar 5, 2026

    chore: migrate code from googleapis/gcp-metadata (#53)

    fa9a454
  25. GautamSharda
    added 4 commits that reference this issue on Mar 11, 2026

    refactor(ts): added ts style fix for src/index.ts (#351)

    805fbf4

    chore: update links in github issue templates (#351)

    0f5f34a

    chore: update links in github issue templates (#351)

    2cc4fb9

    build: ignore googleapis.com in doc link check (#351)

    f06cc4e
  26. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    Add synth script and run it (googleapis#351)

    add1003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    • Storage Stable

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.