Access Control

Identity: Entities and Groups

Vault supports multiple authentication methods and also allows enabling the same type of authentication method on different mount paths. Each Vault client may have multiple accounts with various identity providers that are enabled on the Vault server.

Vault clients can be mapped as entities and their corresponding accounts with authentication providers can be mapped as aliases. In essence, each entity is made up of zero or more aliases. Identity secrets engine internally maintains the clients who are recognized by Vault.

There are two types of groups internal and external. Internal groups are manually created in vault while external groups are automatically created when inferred from an auth method.

NOTE: OIDC groups are not automatically created.

Entities

# Create a new entity that we will add aliases to
vault write identity/entity name="Julie Smith" \
    policies="it-management" \
    metadata="organization"="HCVOP, Inc" \
    metadata="team"="management"
Key        Value
---        -----
aliases    <nil>
id         d1b44e30-10c7-8c32-9851-3207c0eb8895 # This is the canonical_id we'd use when creating an alias below
name       Julie Smith

# Add GitHub auth as an alias
vault write identity/entity-alias \
    name="jsmith22" \
    canonical_id=<entity_id> \
    mount_accessor=<github_auth_accessor>

# Add LDAP auth as an alias
vault write identity/entity-alias \
    name="jsmith@hcvop.com" \
    canonical_id=<entity_id> \
    mount_accessor=<ldap_auth_accessor>

# Find accessors for existing auths
vault auth list
Path      Type     Accessor               Description                Version
----      ----     --------               -----------                -------
token/    token    auth_token_0dc86457    token based credentials    n/a

Groups

Vault Policies

Slides 16-40)

Out of the Box Policies

# List all policies
vault policy list
default
root

# Look at the default policy
vault policy read default
# Allow tokens to look up their own properties
path "auth/token/lookup-self" {
    capabilities = ["read"]
}

# Allow tokens to renew themselves
path "auth/token/renew-self" {
    capabilities = ["update"]
    . . .

# NOTE: Cannot read root policy even though it exists
vault policy read root
No policy named: root

# Create or update a policy
vault policy write admin-policy /tmp/admin.hcl
Success! Uploaded policy: admin-policy

vault policy write webapp -<< EOF
path "kv/data/apps/*" {
  capabilities = ["read","create","update","delete"]
}
path "kv/metadata/*" {
  capabilities = ["read","create","update","list"]
}
EOF

# Using the API
curl \
  --header "X-Vault-Token: s.bckf4kdkds9dftk43ld9" \
  --request PUT \
  --data @payload.json \
  http://127.0.0.1:8200/v1/sys/policy/<policy-name>

# A policy that would give users the ability to read, update and delete kv secrets for jenkins
path "kv\data\apps\jenkins" {
    capabilities = ["read","update","delete"]
}

# List of Capabilities
["create","read","update","delete","list","sudo","deny"]

Root-Protected Paths

Vault Polices - Capabilities

Slides 41-47

Most Used

NOTE: Write is not a valid capability

Special

Examples

Requirement:

Solution:

path "database/creds/dev-db01" {
  capabilities = ["read"]
}
path "kv/apps/dev-app01" {
  capabilities = ["create", "read", "update", "delete"]
}

Requirement:

Solution:

path "kv/apps/webapp/*" {
  capabilities = ["read"]
}
path "kv/apps/webapp/super_secret" {
  capabilities = ["deny"]
}

NOTE: The above policy would not allow a user to browse kv/apps/webapp in the Web UI. We would need to grant list to those paths.

Customizing the Path

Slides 48-59

Using the * to Customize the Path

If we wanted to ALSO read from secret/apps/application1, the policy would look like this:

path "secret/apps/application1/*" {
  capabilities = ["read"]
}
path "secret/apps/application1" {
  capabilities = ["read"]
}

Using the + to Customize the Path

Example:

path "secret/+/+/webapp" {
 capabilities = ["read", "list"]
}
path "secret/apps/+/team-*" {
 capabilities = ["create", "read"]
}

ACL Templating

Example: Creates a section of the key/value v2 secret engine to a specific user

path "secret/data//*" {
  capabilities = ["create", "update", "read", "delete"]
}
path "secret/metadata//*" {
  capabilities = ["list"]
}

If my entity.id was 123456 then vault would create a policy for me that allows me to store secrets at secret/data/123456/*

Template Parameters

Parameter Description
identity.entity.id The entity’s ID
identity.entity.name The entity’s name
identity.entity.metadata.<<metadata key>> Metadata associated with the entity for the given key
identity.entity.aliases.<<mount accessor>>.id Entity alias ID for the given mount
identity.entity.aliases.<<mount accessor>>.name Entity alias name for the given mount
identity.entity.aliases.<<mount accessor>>.metadata.<<metadata key>> Metadata associated with the alias for the given mount and metadata key
identity.groups.ids.<<group id>>.name The group name for the given group ID
identity.groups.names.<<group name>>.id The group ID for the given group name
identity.groups.names.<<group id>>.metadata.<<metadata key>> Metadata associated with the group for the given key
identity.groups.names.<<group name>>.metadata.<<metadata key>> Metadata associated with the group for the given key

Working with Policies

Slides 60-64

Testing Policies

Test to make sure the policy fulfills the requirements

Example Requirements:

# Create a token using the new policy
vault token create -policy="web-app"
# Authenticate with the newly generated token
vault login <token>
# Make sure that the token can read
vault read secret/apikey/Google
# This should fail
vault write secret/apikey/Google key="ABCDE12345"
# Request a new AWS credentials 
vault read aws/creds/s3-readonly 

Administrative Policies

Example Administrative Policy

# Configure License
path "sys/license" {
  capabilities = ["read", "list", "create", "update", "delete"]
}
# Initialize Vault
path "sys/init" {
  capabilities = ["read", "update", "create"]
}
# Configure UI in Vault
path "sys/config/ui" {
  capabilities = ["read", "list", "update", "delete", "sudo"]
}
# Allow rekey of unseal keys for Vault
path "sys/rekey/*" {
  capabilities = ["read", "list", "update", "delete"]
}
# Allows rotation of master key
path "sys/rotate" {
  capabilities = ["update", "sudo"]
}
# Allows Vault seal
path "sys/seal" {
  capabilities = ["sudo"]
}

See instructors github for example policies

Sentinel Policies (Enterprise)

Slides 66-80

Control Groups (Enterprise)

Slides 82-92

Multi-Tenancy with Namespaces (Enterprise)

Slides 93-109