Skip to content

Commit

Permalink
token create: add policies
Browse files Browse the repository at this point in the history
to be able to create a token with a list of policies id
  • Loading branch information
cpaillet committed May 23, 2024
1 parent c81f7d2 commit 783a7be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion consul/api/acl/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ def clone(self, accessor_id, token=None, description=""):
data=json.dumps(json_data),
)

def create(self, token=None, accessor_id=None, secret_id=None, description=""):
def create(self, token=None, accessor_id=None, secret_id=None, policies_id=None, description=""):
"""
Create a token (optionally identified by *secret_id* and *accessor_id*).
This is a privileged endpoint, and requires a token with acl:write.
:param token: token with acl:write capability
:param accessor_id: The accessor ID of the token to create
:param secret_id: The secret ID of the token to create
:param description: Optional new token description
:param policies: Optional list of policies id
:return: The cloned token information
"""
params = []
Expand All @@ -89,6 +90,9 @@ def create(self, token=None, accessor_id=None, secret_id=None, description=""):
json_data["SecretID"] = secret_id
if description:
json_data["Description"] = description
if policies_id:
json_data["Policies"] = [{"ID": policy} for policy in policies_id]

return self.agent.http.put(
CB.json(),
"/v1/acl/token",
Expand Down

0 comments on commit 783a7be

Please sign in to comment.