Grant/Revoke/Create roles with PyMongo?

138 views
Skip to first unread message

S. Frazier

unread,
Feb 24, 2018, 3:37:43 AM2/24/18
to mongodb-user
Hi,

  I'm relatively new to Mongo & PyMongo.   I've read the PyMongo docs and I'm a little confused on the syntax for creating, granting and revoking roles.   I'm assuming based on the docs that this has to be done by passing a document into the db.command() method but I'm having difficulty figuring out what the proper syntax is for each use case.   Assuming I'm correct and db.command() is the way to go:

1.  What would the syntax be to add myCustomRole  to user Foo in database Bar?

2.  What would be the syntax to revoke myCustomRole from user Foo in database Bar?

3.  If I'm totally off-base and there's a better way to do it with pyMongo,  what would it be?

   Thanks very much for any help/advice you're able to offer.

Cheers,
S.

Bernie Hackett

unread,
Feb 26, 2018, 12:03:24 PM2/26/18
to mongodb-user
The docs for the createRole command provide most of the syntax:


There is an example of how to use it in PyMongo's test suite:

S. Frazier

unread,
Mar 2, 2018, 8:02:03 AM3/2/18
to mongodb-user
Hey Bernie,

   This was immensely helpful.  Thanks!
Reply all
Reply to author
Forward
0 new messages