Skip to content

Commit

Permalink
chore: Grant enableSharding permission to admin and default (#503)
Browse files Browse the repository at this point in the history
## Issue

 * Remote user needs enableSharding permission

## Solution

 * Give it
  • Loading branch information
Gu1nness authored Oct 4, 2024
1 parent c8e621c commit 1296f7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/charms/mongodb/v0/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NotReadyError(PyMongoError):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 1
LIBPATCH = 2

ADMIN_AUTH_SOURCE = "authSource=admin"
SYSTEM_DBS = ("admin", "local", "config")
Expand All @@ -40,6 +40,7 @@ class NotReadyError(PyMongoError):
{"role": "userAdminAnyDatabase", "db": "admin"},
{"role": "readWriteAnyDatabase", "db": "admin"},
{"role": "userAdmin", "db": "admin"},
{"role": "enableSharding", "db": "admin"},
],
"monitor": [
{"role": "explainRole", "db": "admin"},
Expand Down Expand Up @@ -127,7 +128,12 @@ def uri(self):

def supported_roles(config: MongoConfiguration):
"""Return the supported roles for the given configuration."""
return REGULAR_ROLES | {"default": [{"db": config.database, "role": "readWrite"}]}
return REGULAR_ROLES | {
"default": [
{"db": config.database, "role": "readWrite"},
{"db": config.database, "role": "enableSharding"},
]
}


class MongoConnection:
Expand Down

0 comments on commit 1296f7e

Please sign in to comment.