Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kubernetes Auth Method #21

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 1.1.0

- Added `kuberentes` auth method.

## 1.0.0

* Drop Python 2.7 support
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ It should contain:
* `cert` - Path to client-side certificate
* `verify` - Whether to verify the SSL certificate or not
* `auth_method` - Which authentication method to use.
Only `token` (the default) and `approle` are implemented so far.
Only `token` (the default), `approle` and `kubernetes` are implemented so far.
hreeder marked this conversation as resolved.
Show resolved Hide resolved

Also include the relevant auth_method-specific config:

* `token` - Authentication token for `auth_method=token`. If not specified,
also tries using the `VAULT_TOKEN` env var or the `~/.vault-token` file.
* `role_id` - Authentication role_id for `auth_method=approle`.
* `secret_id` - Authentication secret_id for `auth_method=approle`.
* `role` - Authentication role for `auth_method=kubernetes`

You can also use dynamic values from the datastore. See the
[docs](https://docs.stackstorm.com/reference/pack_configs.html) for more info.
Expand Down
6 changes: 6 additions & 0 deletions actions/lib/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def _get_client(self):
role_id=self.config["role_id"],
secret_id=self.config["secret_id"],
)
elif auth_method == "kubernetes":
with open("/var/run/secrets/kubernetes.io/serviceaccount/token") as sa_token:
client.auth.kubernetes.login(
self.config["role"],
sa_token.read(),
)
else:
raise NotImplementedError(
"The {} auth method has a typo or has not been implemented (yet).".format(
Expand Down
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ref: vault
name: vault
description: HashiCorp Vault
version: 1.0.0
version: 1.1.0
python_versions:
- "3"
author: steve.neuharth
Expand Down