Skip to main content

GitHub Actions Example

Get started with this complete workflow:
  • Change policy/*.polar to your file paths.
  • Add your production API key as OSO_CLOUD_PRODUCTION_KEY in GitHub Secrets.

Local Development Integration

Catch policy errors before they reach your CI pipeline with pre-commit validation.

Set Up Pre-Commit Hook

Validate Polar syntax before committing:
Make the hook executable:

Pipeline Steps

  1. Validate syntax - oso-cloud validate
  2. Run policy unit tests - oso-cloud test
  3. Run integration tests with updated policies
  4. Deploy to target environment

Testing Configurations

Run fast validation and unit tests on every push to catch errors early.

Syntax Validation

Ensure your Polar policies are syntactically correct:
For multiple policy files: Pass all files in one command - the CLI validates consistency across files.

Unit Testing

Run policy tests to verify authorization logic works correctly. With Oso Dev Server (Recommended):
With Oso Cloud:
Dev Server removes external dependencies for faster CI runs.

Application Testing

Run integration tests to ensure your application works correctly with updated authorization policies.

Shared Test Environment

Queue PR jobs to avoid policy conflicts.

Isolated Environments (Dev Server)

Production Deployment

Deploy validated policies to production safely.
Best practices:
  • Use separate API keys for test and production
  • Store keys as encrypted secrets, never in plaintext
  • Use read-only keys for tests, read-write for deploys

Advanced Configuration

Pin specific tool versions for consistent CI/CD environments:Oso Cloud CLI:
Oso Dev Server:
Replace “x.y.z” with your desired version.
Deploy the Oso Dev Server as a container for isolated test environments:
Validate Local Authorization configuration against your database schema:
Requirements: Database access needed to validate queries against current schema.
Best practices for handling authorization data in CI/CD:Seed Essential Data:
Recommendations:
  • Let applications generate facts naturally during tests
  • Only seed data that’s required on startup (roles, permissions)
  • Keep fact seeding scripts in sync with database seeding

Troubleshooting

CLI installation fails:
  • Check internet connectivity and firewall settings
  • Verify curl is installed: curl --version
Dev Server won’t start:
  • Check port 8080 availability: lsof -i :8080
  • Verify binary permissions: chmod +x standalone
  • Review startup logs for detailed errors
“Authentication failed” errors:
  • Verify API key is set correctly in environment
  • Check key has appropriate permissions (read-only vs read-write)
  • Ensure no extra whitespace in secret values
Wrong environment targeted:
  • Confirm OSO_URL points to correct environment
  • Check OSO_AUTH matches the target environment’s key
  • Verify environment variables are properly scoped to jobs
Syntax validation fails:
  • Check policy files for syntax errors locally first
  • Ensure all referenced policy files are included
  • Verify file paths are correct in CI configuration
Tests fail in CI but pass locally:
  • Check environment variable differences
  • Verify Dev Server is fully started before running tests
  • Ensure test data is properly seeded
Deployment fails:
  • Check production API key permissions
  • Verify policy syntax before deployment
  • Review Oso Cloud environment status

Next Steps

  1. Set up local development tools for policy authoring
  2. Write comprehensive policies using Polar
  3. Implement authorization checks in your application
  4. Monitor and debug authorization in production

Need help setting up your CI/CD pipeline? Schedule a call with an Oso engineer - we’re happy to help.