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

Db encryption #65

Merged
merged 12 commits into from
Nov 4, 2024
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ UPPER_CASE). Environment vars will override any values in the config
file. Per-environment settings in the config file(development, test,
production) will override the shared values for that type.

## Database encryption
The local database can be encrypted, if needed, but requires a bit of setup
and careful retention of a master key. Note that there are performance impacts.

1. First, create encryption keys for the database:
```
rails db:encryption:init
```
Copy the output to your clipboard.

2. Next, create a `credentials.yml.enc` file:
```
EDITOR=vi rails credentials:edit
dave-gantenbein marked this conversation as resolved.
Show resolved Hide resolved
```
Paste the db encryption key data into this file, save, and exit.

NB, the credentials file is decoded by a key placed in
`config/master.key`. Be sure to save this file (it is .gitignored)!

3. Finally, set the following Astral configuration to 'true':
```
db_encryption: true
```

## mTLS connections
Astral can be run as an SSL service and can communicate with Vault via SSL.
Just set the following values in `config/astral.yml` (or environment) to
Expand Down
5 changes: 5 additions & 0 deletions app/models/domain.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
class Domain < ApplicationRecord
validates :fqdn, presence: true

if Config[:db_encryption]
encrypts :fqdn, :users, :groups
end


def groups_array
(groups || "").split(",").sort.uniq
end
Expand Down
3 changes: 3 additions & 0 deletions config/astral.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Astral configuration
# Note that values can be supplied here or as environment vars (UPPER_CASE).
shared:
# Set to true and follow setup guide for encrypted sql database fields
db_encryption: false

vault_token:
vault_addr:
# if VAULT_ADDR is https with self-signed cert, need to provide
Expand Down
1 change: 0 additions & 1 deletion config/credentials.yml.enc

This file was deleted.