Skip to content

Commit

Permalink
Ruff and Docs update.
Browse files Browse the repository at this point in the history
  • Loading branch information
smk4664 committed Oct 12, 2024
1 parent 28d44ba commit 015be06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
14 changes: 9 additions & 5 deletions docs/admin/providers/onepassword_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Requires a minimum of Python3.9

## Prerequisites

You must create a Service Account for the 1Password vault/vaults you are trying to access. You can follow the [Getting Started with Service Accounts](https://developer.1password.com/docs/service-accounts/get-started/) to assist setting this up.

!!! note
The Service Account token needs to have access to the Vault that it is configured for. Per 1Password policy "You can't grant a service account access to your built-in Personal, Private, or Employee vault, or your default Shared vault."

## Configuration

You must provide a mapping in `PLUGINS_CONFIG` within your `nautobot_config.py`, for example:
Expand All @@ -21,10 +28,7 @@ PLUGINS_CONFIG = {
}
```

- `token` - (required) The 1Password Service Account Token to be used when it is not specified by a vault.
- `token` - (required) The 1Password Service Account Token to be used globally when it is not specified by a vault.
- `vaults` (required) Each 1Password Vault that is supported by this app will be listed inside this dictionary.
- `<vault_name>` (required) The name of the vault needs to be placed as a key inside the `vaults` dictionary.
- `token` (optional) The 1Password Service Account Token to be used by the above vault.

!!! note
The Service Account token needs to have access to the Vault that it is configured for. Per 1Password policy "You can't grant a service account access to your built-in Personal, Private, or Employee vault, or your default Shared vault."
- `token` (optional) The 1Password Service Account Token to be used by the above vault, if overriding the global `token`.
13 changes: 7 additions & 6 deletions nautobot_secrets_providers/providers/one_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

__all__ = ("OnePasswordSecretsProvider",)


@async_to_sync
async def get_secret_from_vault(vault, item, field, token, section=None):
"""Get a secret from a 1Password vault.
Expand Down Expand Up @@ -100,9 +101,9 @@ def get_value_for_secret(cls, secret, obj=None, **kwargs): # pylint: disable=to
vault = parameters["vault"]

return get_secret_from_vault(
vault=vault,
item=parameters["item"],
field=parameters["field"],
token=cls.get_token(secret, vault=vault),
section=parameters.get("section", None),
)
vault=vault,
item=parameters["item"],
field=parameters["field"],
token=cls.get_token(secret, vault=vault),
section=parameters.get("section", None),
)

0 comments on commit 015be06

Please sign in to comment.