Skip to content

Commit 56d9925

Browse files
committed
feat(approle): add an optional profile config mount_point
Signed-off-by: flavono123 <[email protected]>
1 parent 92af8db commit 56d9925

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

actions/lib/action.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class VaultBaseAction(Action):
77
Base Action includes st2 profile and vault client functions
88
for child classes.
99
"""
10+
1011
def __init__(self, config):
1112
super().__init__(config)
1213
self.config = config
@@ -19,7 +20,9 @@ def run(self, profile_name=None):
1920
if profile_name is None:
2021
profile_name = self.config.get("default_profile")
2122
if profile_name is None:
22-
raise ValueError("No default profile found, check the pack configuration.")
23+
raise ValueError(
24+
"No default profile found, check the pack configuration."
25+
)
2326

2427
for profile in self.config.get("profiles", []):
2528
if profile_name == profile["name"]:
@@ -78,7 +81,18 @@ def _auth_approle(self, profile):
7881
"""
7982
Authenticate using a vault app role to acquire the vault token.
8083
"""
81-
self.vault.auth.approle.login(
82-
role_id=profile["role_id"],
83-
secret_id=profile["secret_id"],
84-
)
84+
# Check if mount_point is provided in the profile
85+
mount_point = profile.get("mount_point")
86+
87+
# Prepare login arguments
88+
login_kwargs = {
89+
"role_id": profile["role_id"],
90+
"secret_id": profile["secret_id"],
91+
}
92+
93+
# Add mount_point to kwargs if it exists in the profile
94+
if mount_point:
95+
login_kwargs["mount_point"] = mount_point
96+
97+
# Replace the direct login call with kwargs-based call
98+
self.vault.auth.approle.login(**login_kwargs)

config.schema.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ profiles:
6262
type: "string"
6363
secret: true
6464
required: false
65+
mount_point:
66+
description: "Authentication approle secret-id (method=approle)"
67+
type: "string"
68+
secret: false
69+
required: false

vault.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ profiles:
99
auth_method: approle
1010
role_id: '00000000-0000-0000-0000-000000000000'
1111
secret_id: '00000000-0000-0000-0000-000000000000'
12+
mount_point: 'my-approle'
1213
- name: development
1314
url: 'https://127.0.0.1:8200'
1415
verify: false

0 commit comments

Comments
 (0)