Skip to content

Commit d9176cb

Browse files
authored
feat(approle): add an optional profile config mount_point (#27)
as-is: cannot change the default approle mount point `approle` to-be: change the mount point of approle profile if it is given
2 parents 92af8db + 3c6e8ec commit d9176cb

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

CHANGES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 2.1.0
4+
5+
- Support mount_point parameter for profiles config.
6+
37
## 2.0.0
48

59
- Add action to generate secrets.
@@ -48,4 +52,4 @@ The next version will be 1.0.0 and "2" will be dropped from python_versions.
4852

4953
## 0.1.0
5054

51-
- First release
55+
- First release

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 mount point (method=approle)"
67+
type: "string"
68+
secret: false
69+
required: false

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ref: vault
33
name: vault
44
description: StackStorm pack integration with HashiCorp Vault
5-
version: 2.0.0
5+
version: 2.1.0
66
python_versions:
77
- "3"
88
author: steve.neuharth

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)