Skip to content

[WIP] feat(enterprise): encrypt external access tokens (oidc, git auth) in the database #9339

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

Closed
wants to merge 67 commits into from

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Aug 25, 2023

Encrypt exernal access tokens

Note: this PR has gotten rather big, so I am breaking it up into smaller chunks. Keeping this around for reference.
#9421
#9433

This PR adds enterprise-only functionality to encrypt external database access tokens. This builds upon @kylecarbs' previous work in #7959.

  • Adds a new table dbcrypt_sentinel which is used as a litmus test for database encryption status.
  • Adds package enterprise/dbcrypt which handles encryption/decryption for the following fields:
    • dbcrypt_sentinel.value
    • user_links.oauth_access_token
    • user_links.oauth_refresh_token
    • git_auth_links.oauth_access_token
    • git_auth_links.oauth_refresh_token
  • Adds support for specifying EXTERNAL_TOKEN_ENCRYPTION_KEYS to enterprise server cmd.
    • When specified, the database.Store will be wrapped by dbcrypt.Store.
    • At present, we only allow max. 2 keys; this is to force people to complete key rotation in a timely manner instead of continuously appending old keys.
  • Adds a dbcrypt-rotate enterprise subcommand (and associated test) to perform key rotation and re-encryption of affected rows.

Suggested attention:

  • enterprise/dbcrypt - this is the most important piece
  • enterprise/cli - specifically the rotation command
  • enterprise/coderd - specifically the misc. plumbing

Checklist

  • No experimental flags needed
  • Testing:
    • Unit tests have been added
    • Manual testing has been performed using ./scripts/dev-oidc.sh
  • User-facing changes:
    • Add documentation under ./docs (in progress)

kylecarbs and others added 30 commits May 30, 2023 16:26
- add external token encryption key to YAML excludes
- ensure that secret external token encryption key is
  scrubbed from deployment values
@johnstcn johnstcn changed the title [WIP] encrypt external access tokens feat(enterprise): encrypt external access tokens (oidc, git auth) in the database Aug 29, 2023
@johnstcn johnstcn changed the title feat(enterprise): encrypt external access tokens (oidc, git auth) in the database [WIP] feat(enterprise): encrypt external access tokens (oidc, git auth) in the database Aug 30, 2023
@johnstcn johnstcn closed this Aug 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2023
@johnstcn johnstcn deleted the cj/dbcrypt branch October 13, 2023 12:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants