Continuous Integration
Validating policies in your CI workflows allows you to check for potential policy issues each time a change is made to your policy source code. Common Fate policy validation can be run in CI platforms such as GitHub Actions, GitLab, and BuildKite.
If you use GitHub Actions, our Cedar Policy Validation Action will show annotations on Pull Requests, indicating where issues are in your policy source code.
Prerequisites
If you’re running a BYOC (“Bring-Your-Own-Cloud”) deployment of Common Fate in your own AWS account, you’ll need to be on v1.31.0
or later of the common-fate/common-fate-deployment/aws
Terraform module.
Policy validation in CI
Choose a tab below based on your CI provider.
To validate policies using GitHub Actions, you can use the Download Cedar Schema Action to download the latest Cedar schema, and use the Validate Cedar Policies Action to validate against the schema.
Here’s an example workflow.
name: Test
on: push:
jobs: cedar: name: Cedar runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4
- name: Download Cedar Schema uses: common-fate/download-cedar-schema-action@v1 with: deployment-url: https://commonfate.example.com # replace this with your Common Fate API URL oidc-client-id: abcdefGHIJKL12345678 # replace this with your Client ID oidc-client-secret: ${{ secrets.CF_OIDC_CLIENT_SECRET }} oidc-issuer: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH # replace this with your Issuer save-schema-file-to: common-fate.cedarschema.json
- name: Validate Policies uses: common-fate/cedar-validate-action@v1 with: schema-file: common-fate.cedarschema.json policy-files: "**/*.cedar"
As shown above, the workflow requires a few configuration variables to tell the CLI where Common Fate is running (api-url
), and how to authenticate to it (oidc-client-id
, oidc-client-secret
, oidc-issuer
). You can obtain api-url and oidc-issuer from your Terraform provider configuration block:
provider "commonfate" { api_url = "https://commonfate.example.com" # corresponds to 'deployment-url' in the workflow oidc_issuer = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH" # corresponds to 'oidc-issuer' in the workflow}
You can look up the Read-Only client credentials for oidc-client-id and oidc-client-secret by finding it in the deployment outputs following our guide here. Save the OIDC client secret as a GitHub Actions Secret with the name CF_OIDC_CLIENT_SECRET
to keep it out of your source code.
The Read-Only client has read access to the policy and configuration APIs but cannot be used for destructive actions.
Copy the script and signing key into your repository:
KEY_FPATH=common-fate-signing-key.asc
# import the Common Fate signing key
gpg --import $KEY_FPATH
# extract the public key ID
KEY_ID=$(gpg --list-packets <"$KEY_FPATH" | awk '$1=="keyid:"{print$2;exit}')
# mark the key as trusted
(echo 5; echo y; echo save) |gpg --command-fd 0 --no-tty --no-greeting -q --edit-key "$KEY_ID" trust
curl -OL releases.commonfate.io/cf/v${CLI_VERSION}/cf_${CLI_VERSION}\_linux_x86_64.tar.gz
# verify the CLI signature (see: https://docs.commonfate.io/granted/security)
curl -OL releases.commonfate.io/cf/v${CLI_VERSION}/checksums.txtcurl -OL releases.commonfate.io/cf/v${CLI_VERSION}/checksums.txt.sigshasum -a 256 -c checksums.txt --ignore-missing
gpg --verify ./checksums.txt.sig
sudo tar -zxvf ./cf\_${CLI_VERSION}\_linux_x86_64.tar.gz -C /usr/local/bin/
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGCb9UABEADcK6S4PPSDZRcgR4ToKvljghmL3m8v9A32CvHOTBpWumhfmHoi9zDq/fB/vzhMcxGKrD4D64Rna3T2L2NGVEYTxwm4iwTNBNxKb1VFRlXKZtqXsYk6JCplGLinkSROoZhhGFbJjUE5GGbnuhWgAZbJRd937rumHgA9RNXy2lV0APQo9qvRTkOfqS8LgKNQDY7ljYcGsNgj1uWTqshsYzqm7D/QLy9L+9zR9nD7oO7yoJAmbeyORayAXcZZafw/SXHHZDeiuQgJwsuAP+Xgg63TGyAZgB/k73tAvw+CfNKejlan0r2uI7JvP9RZI+q+UXVKtiWYCadvmMD6TnXpwlDguR1wF9O8I00UjSm9Uv8I4IHVlaO4cX1NOfA4LaHEgH+43Zefkcl0kq1gkHOq34JjHf1DNAaxT4BDx8GZPIw14dXw3PLuCF1xAjqTA5KuAH6A91ZeIkaYAWmZJeZo7HyLXhrN9oMeFY0EyAXBcnHLapHcqwlq32eECjN1k6wgeiygNjOLvGx5n3UG5lTg3EJ3CIAwxnWROGQDnZ3u3ibxJi80saV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jDPIPwsDu1s5gf37WwalrX68cbovoDJvO11VSLFy6cqDWfc25k1TYjDClb2pVwyL+kyoreBeSVDSLI5aEgK22q5BxznLzbWnCgXi0+VdrbmRXi8LRepns5mfgWD/kOJgTAZRfQNb1G5vLx+gxOv0h8m1aIXSPHlk1NQRBumpd4CgEsWaod5q7LhYOeP0hys8k//hWU2XWsyv45jBAcDO6XR37uys5CE7w9e+q0cQDSx7xmuy+DW9oI65+RKcK3muGesBnoAf9BEYsQkg6/cijiPwda3IDhptHm5R3pfqZPDlziTeEKx/TBoQHNWmwI3AYH1v1aFsWeU+f82Cw/9HWMFl3zo3KbWI4tdHTIOgD6UpeInXs45gXMDs/iw4mNQWnCcLDngwI82o0AZHX25WKmHSg6LEAoQgE/GpSBo4tzOcDftsUa8/zDpW88faNTKTcaxjVUuixsxxTgRF2hAwLYDZ/UcOT0hMrM2FN4K/2QpZQLOCQOSU8hdSPHIW/Kop7F/Horwt4SlyyWehBH4CRy6WXokoa2kBGchfTQ2h8ROuIAF45ODvwzfBxzpl4FnTZVbsv1Sh+9nh8PQfjcBoH6o/c5Ti5iBmUKWIlGcnTceaT4quOVy7dYOueO89phVfh12EX1fOifnzZtx5pHGGT9atgCcXY0CAgmzR1oFfge6+wZX9DAOYPicl8gnWSBnwYzOLEu7+5dfOmbADgOWDYwSxtaWdoXnQzizUYHcRerwVGsuqhb7CcQ5FiZgOX6EIpCitlz9gznGPPsVpxOVETwcARmwLAo+yfL4Ci5ArNaauisxGO4ioDZvTuUgzFfMDVDINizwa8tG0BSfD7EHeCs6pRA6HbHfSsBQ+gdCI0LnT0b+S8G5C4YCaGIGhvnHG8sCYan44ZNo47Ez4Z1hPjgVwo2I+grqvRStnRs8i8O18z5xLwx9g5o6FUjXm3ez/MylV/UoL3zBarzOaipAdOuTFwxC95aansKixfjvulqFbbJWRzx96Ipr3NoSP+g==DqSH-----END PGP PUBLIC KEY BLOCK-----
You can then install the CLI in your CI workflow by running:
CLI_VERSION=1.12.0 ./install-common-fate-cli.sh
The CLI requires a few configuration variables to tell the CLI where Common Fate is running, and how to authenticate to it. You can obtain these from your Terraform provider configuration block:
provider "commonfate" { api_url = "https://commonfate.example.com" # corresponds to 'CF_API_URL' environment variable oidc_client_id = "7qf6ncnf0qudvpgp93l96397uk" # corresponds to 'CF_OIDC_CLIENT_ID' environment variable oidc_issuer = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH" # corresponds to 'CF_OIDC_ISSUER' environment variable}
You can look up the Terraform OIDC client secret by finding it in the deployment outputs following our guide here.
To use the CLI, you’ll need to export some environment variables:
export CF_API_URL=https://commonfate.example.com # replace this with your API URLexport CF_OIDC_CLIENT_ID=abcdefGHIJKL12345678 # replace this with your Client IDexport CF_OIDC_CLIENT_SECRET=XXXXXXXXXXXXXXXX # replace this with your Client Secretexport CF_OIDC_ISSUER=https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH # replace this with your Issuerexport CF_CONFIG_SOURCES=env # tell the Common Fate CLI to only source config variables from the environment, rather than looking in ~/.cf/config
To install the cedar policy CLI, copy the following script into your repository:
echo "Building Cedar..."cargo install cedar-policy-cli
You can then install the CLI in your CI workflow by running:
./install-cedar-cli.sh
Then, you can run the validation command:
cedar validate --schema entities/common-fate.cedarschema.json --schema-format json --policies default_policy_for_testing.cedar
If you want to validate all *.cedar
policies instead, run:
find . -type f -name '*.cedar' | xargs -n1 cedar validate --schema common-fate.cedarschema.json --schema-format json --policies
Access testing in CI
Choose a tab below based on your CI provider.
To run access tests using GitHub Actions, you can use the Install Common Fate CLI Action to install the cf
CLI, and then run cf tests run -f tests.yml
.
You’ll need to add an access test file into your Common Fate configuration repository first.
Here’s an example workflow.
name: Test
on: push:
jobs: access: name: Access Testing runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4
- name: Install Common Fate CLI uses: common-fate/install-cli-action@v1 with: oidc-client-id: abcdefGHIJKL12345678 # replace this with your Client ID oidc-client-secret: ${{ secrets.CF_OIDC_CLIENT_SECRET }} oidc-issuer: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH # replace this with your Issuer api-url: https://commonfate.example.com # replace this with your Common Fate API URL
- name: Run Access Tests run: cf tests run -f tests.yml
As shown above, the workflow requires a few configuration variables to tell the CLI where Common Fate is running (api-url
), and how to authenticate to it (oidc-client-id
, oidc-client-secret
, oidc-issuer
). You can obtain api-url and oidc-issuer from your Terraform provider configuration block:
provider "commonfate" { api_url = "https://commonfate.example.com" # corresponds to 'deployment-url' in the workflow oidc_issuer = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH" # corresponds to 'oidc-issuer' in the workflow}
You can look up the Read-Only client credentials for oidc-client-id and oidc-client-secret by finding it in the deployment outputs following our guide here. Save the OIDC client secret as a GitHub Actions Secret with the name CF_OIDC_CLIENT_SECRET
to keep it out of your source code.
The Read-Only client has read access to the policy and configuration APIs but cannot be used for destructive actions.
After completing this guide, you should see access tests being executed in GitHub Actions as shown below.
To run access tests using another CI provider, you can install the cf
CLI, and then run cf tests run -f tests.yml
.
You’ll need to add an access test file into your Common Fate configuration repository first.
Copy the script and signing key into your repository:
KEY_FPATH=common-fate-signing-key.asc
# import the Common Fate signing key
gpg --import $KEY_FPATH
# extract the public key ID
KEY_ID=$(gpg --list-packets <"$KEY_FPATH" | awk '$1=="keyid:"{print$2;exit}')
# mark the key as trusted
(echo 5; echo y; echo save) |gpg --command-fd 0 --no-tty --no-greeting -q --edit-key "$KEY_ID" trust
curl -OL releases.commonfate.io/cf/v${CLI_VERSION}/cf_${CLI_VERSION}\_linux_x86_64.tar.gz
# verify the CLI signature (see: https://docs.commonfate.io/granted/security)
curl -OL releases.commonfate.io/cf/v${CLI_VERSION}/checksums.txtcurl -OL releases.commonfate.io/cf/v${CLI_VERSION}/checksums.txt.sigshasum -a 256 -c checksums.txt --ignore-missing
gpg --verify ./checksums.txt.sig
sudo tar -zxvf ./cf\_${CLI_VERSION}\_linux_x86_64.tar.gz -C /usr/local/bin/
-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QpZQLOCQOSU8hdSPHIW/Kop7F/Horwt4SlyyWehBH4CRy6WXokoa2kBGchfTQ2h8ROuIAF45ODvwzfBxzpl4FnTZVbsv1Sh+9nh8PQfjcBoH6o/c5Ti5iBmUKWIlGcnTceaT4quOVy7dYOueO89phVfh12EX1fOifnzZtx5pHGGT9atgCcXY0CAgmzR1oFfge6+wZX9DAOYPicl8gnWSBnwYzOLEu7+5dfOmbADgOWDYwSxtaWdoXnQzizUYHcRerwVGsuqhb7CcQ5FiZgOX6EIpCitlz9gznGPPsVpxOVETwcARmwLAo+yfL4Ci5ArNaauisxGO4ioDZvTuUgzFfMDVDINizwa8tG0BSfD7EHeCs6pRA6HbHfSsBQ+gdCI0LnT0b+S8G5C4YCaGIGhvnHG8sCYan44ZNo47Ez4Z1hPjgVwo2I+grqvRStnRs8i8O18z5xLwx9g5o6FUjXm3ez/MylV/UoL3zBarzOaipAdOuTFwxC95aansKixfjvulqFbbJWRzx96Ipr3NoSP+g==DqSH-----END PGP PUBLIC KEY BLOCK-----
You can then install the CLI in your CI workflow by running:
CLI_VERSION=1.15.1 ./install-common-fate-cli.sh
The CLI requires a few configuration variables to tell the CLI where Common Fate is running, and how to authenticate to it. You can obtain these from your Terraform provider configuration block:
provider "commonfate" { api_url = "https://commonfate.example.com" # corresponds to 'CF_API_URL' environment variable oidc_client_id = "7qf6ncnf0qudvpgp93l96397uk" # corresponds to 'CF_OIDC_CLIENT_ID' environment variable oidc_issuer = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH" # corresponds to 'CF_OIDC_ISSUER' environment variable}
You can look up the Terraform OIDC client secret by finding it in the deployment outputs following our guide here.
To use the CLI, you’ll need to export some environment variables:
export CF_API_URL=https://commonfate.example.com # replace this with your API URLexport CF_OIDC_CLIENT_ID=abcdefGHIJKL12345678 # replace this with your Client IDexport CF_OIDC_CLIENT_SECRET=XXXXXXXXXXXXXXXX # replace this with your Client Secretexport CF_OIDC_ISSUER=https://cognito-idp.us-east-1.amazonaws.com/us-east-1_abcdeFGH # replace this with your Issuerexport CF_CONFIG_SOURCES=env # tell the Common Fate CLI to only source config variables from the environment, rather than looking in ~/.cf/config
To install the cedar policy CLI, copy the following script into your repository:
echo "Building Cedar..."cargo install cedar-policy-cli
You can then install the CLI in your CI workflow by running:
./install-cedar-cli.sh
Then, you can add the testing command to your CI pipeline:
cf tests run -f tests.yml
You should see output similar to the following when your CI pipeline runs:
retrieving users for email address lookups...retrieved 126 users-------------- ACCESS TESTS --------------running 2 access tests...
[PASS] chris@commonfate.io requires-approval to Sandbox-1 with role ViewOnlyAccess
[FAIL] chris@commonfate.io auto-approved to Sandbox-2 with role ViewOnlyAccess: got requires-approval policies contributing to requesting access: [basic.policy0] policies contributing to activating access: []
-------------- GROUP MEMBERSHIP TESTS --------------running 2 group membership tests...
[PASS] chris@commonfate.io is member of c9bed4d8-d091-7057-4ed7-6d60bcf1e8bf
[PASS] chris@commonfate.io is not member of 790e94a8-2071-7016-a43c-86e66212a43d
1 Access Tests failedAll Group Membership Tests passed