Oracle Backend as a Service for Spring Cloud and Microservices includes HashiCorp Vault to secure, store and tightly control
access to tokens, passwords, certificates, encryption keys for protecting secrets, and other sensitive data using a user interface (UI),
command-line interface (CLI), or Hypertext Transfer Protocol (HTTP) API.
The Vault can be deployed in two different ways. See the Setup:
Development mode
Production mode
Warning
Never run a Development mode server in production. It is insecure and will lose data on every restart (since it stores data
in-memory). It is only intended for development or experimentation.
Vault uses the following Oracle Cloud Infrastructure (OCI) services when running in Production mode. When running in Development mode,
only the OCI Container Engine for Kubernetes (OKE) is used.
When running in Production mode, the Vault is unsealed using the
OCI Key Management Service (KMS) key. The root token can be accessed using the kubectl command-line interface. The root token
in Development mode is root.
The following Vault services are enabled during deployment. Other services can be enabled using the vault command and the web user interface:
Token Authentication Method. The token authentication method is built-in and automatically available. It allows users to authenticate using a token, as well as create new tokens, revoke secrets by token, and more.
AppRole Authentication Method. The approle authentication method allows machines or applications to authenticate with Vault-defined roles.
Kubernetes Authentication Method. The kubernetes authentication method can be used to authenticate with Vault using a Kubernetes service account token. This method of authentication makes it easy to introduce a Vault token into a Kubernetes Pod.
Userpass Authentication Method. The userpass authentication method allows users to authenticate with Vault with a user name and password combination.
Key/Value Secrets Engine. The non-versioned Key/Value secrets engine is a generic Key/Value store used to store arbitrary secrets.
root tokens have the root policy attached to them. root tokens can do anything in Vault and are useful in Development mode but should be restricted in Production mode. In fact, the Vault team recommends that root tokens only be used for the initial setup. Be sure to save the initial root token in a secure way. For example:
It is very important that the token is saved in multiple places. Losing the token can result in loss of access to the Vault.
Accessing the root Token Development Mode
The root token is set to root in Development mode. There are no recovery keys when running in Development mode.
Accessing Vault Recovery Keys Production Mode
Vault is configured to automatically unseal (auto unseal) using OCI Vault. Initializing with auto unseal creates five recovery keys that are stored in K8s Secrets. They MUST be retrieved and stored in a second location.
Warning
It is very important that recovery keys are saved in multiple places. Losing the recovery keys can result in loss of Vault.
To extract the five recovery keys, use the following commands:
To access the Vault using the kubectl command-line interface, you need to set up Access Kubernetes Cluster.
Test access to the Vault.
Vault Documentation contains all of the commands that you can use with the Vault CLI. For example, this command returns the current status of Vault on one of the pods:
kubectl exec pod/vault-0 -n vault -it -- vault status
The output looks similar to this:
Key Value
--- -----
Recovery Seal Type shamir
Initialized true
Sealed false
Total Recovery Shares 5
Threshold 3
Version 1.11.3
Build Date 2022-08-26T10:27:10Z
Storage Type oci
Cluster Name vault-cluster-28535f69
Cluster ID 993662ee-b3ee-2a13-3354-97adae01e1ca
HA Enabled true
HA Cluster https://vault-0.vault-internal:8201
HA Mode active
Active Since 2023-01-26T16:14:32.628291153Z
Get the token and log in to the Vault.
To interact with the Vault in Production mode, you need to log in using a token that is stored in a K8s Secret. Get the token by running the following command. The output is the root token. It is very important that the token is saved in multiple places. Losing the token can result in loss of access to the Vault. In Development mode, the root token is root.
The following is sample output from logging in as the root user which should only be done during the initial set up. As an administrator, you must generate separate tokens and access control lists (ACLs) for the users that need access to the Vault. See Vault Documentation. For example:
To display the enabled secret engines, process this command:
kubectl exec pod/vault-0 -n vault -it -- vault secrets list
The output looks similar to this:
Path Type Accessor Description
---- ---- -------- -----------
cubbyhole/ cubbyhole cubbyhole_a07a59ec per-token private secret storage
identity/ identity identity_8b1e1a80 identity store
kv-v2/ kv kv_06acc397 n/a
sys/ system system_df5c39a8 system endpoints used for control, policy and debugging
To display the enabled authentication methods, process this command:
kubectl exec pod/vault-0 -n vault -it -- vault auth list
Expose the Vault web user interface (UI) using this command:
kubectl port-forward -n vault svc/vault 8200
Get the root token.
To interact with the Vault in Production mode, you need to log in using a token that is stored in a K8s Secret. Get the token by running the following command. The output is the root token. It is very important that the token is saved in multiple places. Losing the token can result in loss of access to the Vault. In Development mode, the root token is root. For example:
Log in using the root token. As an administrator, you must generate separate tokens and access control lists (ACLs) for the users that need access to the Vault. See Vault Documentation.
You are presented with the Home screen:
Audit logs
Important
Audit logging is blocking, if the file is bigger than allowed space HashiCorp Vault will stop taking requests.
If you deployed Oracle Backend for Microservices and AI using STANDARD edition, HashiCorp Vault will be deployed in production mode and you have the option of turing on audit logs. Note, you must be authenticated to turn on audit logs.
To turn on audit logs execute the following command: