-
Notifications
You must be signed in to change notification settings - Fork 101
Move secrets to Azure Key Vault #738
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
Conversation
643ddbd
to
22a910a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! This is already looking great, my only remaining concern is how to ensure that the secret values are masked in the log output (in case future tired me adds set -x
for debugging, for example). Once this is resolved, I think this is good to go!
4e81bc4
to
030b28a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I could imagine that the resulting workflow definition would be even nicer to read if the convention was introduced that in addition to setting outputs via NAME => OUTPUT
, secrets could also be downloaded via NAME ENCODING> FILENAME
(e.g. ${{ secrets.LINUX_GPG_PUBLIC_SECRET_NAME }} base64> msft-git-public.asc
or ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} ascii> .sig/codesign.pass
).
This would probably make even more sense in the context of using the same Action also in other workflow definitions.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like where this is going!
4354a3f
to
4af03aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I am a bit embarrassed to ask for yet more changes, but I am confident that this is the last round!
env: | ||
DO_WIN_CODESIGN: ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME != '' && secrets.WIN_CODESIGN_PASS_SECRET_NAME != '' }} | ||
DO_WIN_GPGSIGN: ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME != '' && secrets.WIN_GPG_PRIVATE_SECRET_NAME != '' && secrets.WIN_GPG_PASSPHRASE_SECRET_NAME != '' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very, very nice!
Add a new JavaScript GitHub Action to download secrets from Azure Key Vault using the `az` CLI, mask the secret values, and store them as: * outputs, * environment variables, or * files; Values are all masked for safe consumption by other steps in a workflow. Callers of this action can optionally perform base64 decoding of secret values using the syntax: `INPUT base64> OUTPUT`. It is assumed that the `az login` command has already been run prior to this action being invoked. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Migrate secrets to Azure Key Vault. Names of the secrets in the AKV, and the AKV and Managed Identity IDs themselves are stored in GitHub environment secrets. This indirection allows for an easy way to re-point these to different Key Vault secrets without modifying the workflow file itself. In forks, this would allow others to use their own AKV and sercrets with the same workflow. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Continue to migrate secrets to AKV for the macOS build steps. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Continue to migrate secrets to AKV for the Debian package build steps. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Use the `akv-secret` action rather than `az keyvault secret show | base64 -d` for downloading the Debian package public GPG key. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for indulging me!
There are several issues that have been uncovered with the changes made in #738. Let's fix them! * Check out `akv-secret` action before it is used. * Log in to Azure before accessing the Key Vault. * Don't mask empty lines. * Use a buffer to fix encoding issues when writing binary data. * Correctly mask multi-line secret values. * Add missing `require('path')` statement.
We should standardise on a location (and naming convention) to store secrets used as part of the build process for
microsoft/git
. Azure Key Vault is an approved store for secrets inside of Microsoft, and so we should migrate any existing secrets from GitHub environment secrets to AKV. Access to the AKV is via Managed Identity and federated authentication through GitHub Actions.The names of the secrets, and other configuration for accessing the Key Vault, remain in GitHub environment secrets. Forks of the project can therefore define the same set of environment secrets pointing at their own AKV to utilise the same build process.
For reference, the set of secrets that must be defined for the workflow are as follows:
AZURE_VAULT
AZURE_CLIENT_ID
AZURE_TENANT_ID
AZURE_SUBSCRIPTION_ID
WIN_CODESIGN_CERT_SECRET_NAME
WIN_CODESIGN_PASS_SECRET_NAME
WIN_GPG_PRIVATE_SECRET_NAME
WIN_GPG_KEYGRIP_SECRET_NAME
WIN_GPG_PASSPHRASE_SECRET_NAME
APPLE_APPCERT_SECRET_NAME
APPLE_APPCERT_PASS_SECRET_NAME
APPLE_INSTCERT_SECRET_NAME
APPLE_INSTCERT_PASS_SECRET_NAME
APPLE_TEAM_ID_SECRET_NAME
APPLE_DEVELOPER_ID_SECRET_NAME
APPLE_DEVELOPER_PASSWORD_SECRET_NAME
APPLE_APPSIGN_ID_SECRET_NAME
APPLE_INSTSIGN_ID_SECRET_NAME
LINUX_GPG_PUBLIC_SECRET_NAME
LINUX_GPG_PRIVATE_SECRET_NAME
LINUX_GPG_PASSPHRASE_SECRET_NAME
LINUX_GPG_KEYGRIP_SECRET_NAME