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:Pipeline Steps
- Validate syntax -
oso-cloud validate
- Run policy unit tests -
oso-cloud test
- Run integration tests with updated policies
- 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:Unit Testing
Run policy tests to verify authorization logic works correctly. With Oso Dev Server (Recommended):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.- 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
Version pinning
Version pinning
Pin specific tool versions for consistent CI/CD environments:Oso Cloud CLI:Oso Dev Server:Replace “x.y.z” with your desired version.
Docker-based Dev Server
Docker-based Dev Server
Deploy Dev Server as a container for isolated test environments:
Local Authorization Validation
Local Authorization Validation
Managing Facts in CI
Managing Facts in CI
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
Installation Issues
Installation Issues
CLI installation fails:
- Check internet connectivity and firewall settings
- Verify curl is installed:
curl --version
- Try manual download from Oso Cloud dashboard
- Check port 8080 availability:
lsof -i :8080
- Verify binary permissions:
chmod +x standalone
- Review startup logs for detailed errors
Authentication Problems
Authentication Problems
“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
- Confirm OSO_URL points to correct environment
- Check OSO_AUTH matches the target environment’s key
- Verify environment variables are properly scoped to jobs
Policy and Test Failures
Policy and Test Failures
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
- Check environment variable differences
- Verify Dev Server is fully started before running tests
- Ensure test data is properly seeded
- Check production API key permissions
- Verify policy syntax before deployment
- Review Oso Cloud environment status
Next Steps
- Set up local development tools for policy authoring
- Write comprehensive policies using Polar
- Implement authorization checks in your application
- 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.