This repository manages Tailscale Access Control Lists (ACLs) using GitOps principles, enabling infrastructure-as-code for network security policies.
- Tailscale Account: You need admin access to your Tailscale tailnet
- GitHub Repository Secrets: Configure the required secrets
- Tailscale API Key: Generate an API key or OAuth credentials
-
Clone this repository to your GitHub account
-
Configure GitHub Secrets in your repository settings:
TS_API_KEY
: Your Tailscale API keyTS_TAILNET
: Your tailnet name (e.g.,yourcompany.com
)
-
Edit the policy file: Modify
policy.hujson
with your ACL rules -
Test your changes: Create a pull request to validate ACL syntax
-
Deploy: Merge to main branch to apply changes to your tailnet
βββ policy.hujson # Main Tailscale ACL policy file
βββ .github/
β βββ workflows/tailscale.yml # GitHub Actions for ACL sync
βββ .cursor # Cursor IDE configuration
β βββ rules/tailscale-acl.mdc # Cursor IDE rules configuration
βββ .clinerules # Cline agent configuration
βββ AGENTS.md # General AI agent instructions
βββ CLAUDE.md # Claude AI configuration
βββ GEMINI_RULES.md # Gemini AI configuration
βββ .aider.conf.yml # Aider configuration
βββ .vscode/settings.json # VS Code settings
βββ .yamllint # YAML linting rules
βββ .prettierrc # Code formatting rules
βββ .pre-commit-config.yaml # Pre-commit hooks
βββ .editorconfig # Editor configuration
βββ .gitignore # Git ignore patterns
βββ README.md # This file
You can use either an API key or OAuth credentials:
- Go to Tailscale Admin Console β Keys
- Generate a new API key
- Add
TS_API_KEY
secret to your GitHub repository
- Go to Tailscale Admin Console β OAuth Clients
- Create new OAuth client with
acl
scope - Add
TS_OAUTH_ID
andTS_OAUTH_SECRET
secrets to GitHub
Configure these secrets in your GitHub repository settings:
Secret Name | Description | Example |
---|---|---|
TS_API_KEY |
Tailscale API key | tskey-api-... |
TS_TAILNET |
Your tailnet name | yourcompany.com |
TS_OAUTH_ID |
OAuth client ID (if using OAuth) | k1a2b3c... |
TS_OAUTH_SECRET |
OAuth client secret (if using OAuth) | ts_oauth_secret_... |
The policy.hujson
file uses HuJSON (Human JSON) format, which allows:
- Comments: Use
//
for inline comments - Trailing commas: More git-friendly formatting
- Multi-line strings: Better readability
{
// Define user groups
"groups": {
"group:admins": ["admin@company.com"],
"group:engineering": ["dev1@company.com", "dev2@company.com"]
},
// Define who can assign device tags
"tagOwners": {
"tag:server": ["group:admins"],
"tag:workstation": ["group:engineering"]
},
// Access control rules
"acls": [
{
"action": "accept",
"src": ["group:engineering"],
"dst": ["tag:server:22", "tag:server:80"]
}
],
// Test cases for validation
"tests": [
{
"src": "dev1@company.com",
"accept": ["tag:server:22"]
}
]
}
-
Create a feature branch:
git checkout -b feature/add-qa-team-access
-
Edit the policy file:
# Edit policy.hujson with your changes
-
Create a pull request:
- The GitHub Action will validate your ACL syntax
- Review the changes with your team
- Merge when approved
-
Automatic deployment:
- Merging to main automatically applies changes to Tailscale
- Monitor the GitHub Actions log for deployment status
This repository includes configuration for multiple AI coding assistants:
- Cursor IDE:
.cursorrules
file for Cursor AI - Cline:
.clinerules
for Cline agent - GitHub Copilot: Multiple instruction files
- Claude:
CLAUDE.md
for Claude AI - Gemini:
GEMINI_RULES.md
for Gemini - Aider:
.aider.conf.yml
configuration
Install pre-commit hooks for automatic validation:
pip install pre-commit
pre-commit install
This will automatically:
- Validate HuJSON syntax
- Check for security issues
- Format code consistently
- Run linting tools
Test your ACL policy before deployment:
# If you have Tailscale CLI installed
tailscale debug policy-file policy.hujson
- Use groups instead of individual emails for easier management
- Apply least privilege principles - grant minimum necessary access
- Tag devices appropriately for granular access control
- Include comprehensive test cases for all access rules
- Regular audits of access patterns and permissions
- Never commit secrets - use GitHub repository secrets
- Require pull request reviews for all policy changes
- Enable branch protection on the main branch
- Monitor GitHub Actions logs for deployment issues
- Regularly rotate API keys and OAuth credentials
- Check repository secrets are configured correctly
- Validate HuJSON syntax in policy.hujson
- Review GitHub Actions logs for specific errors
- Ensure GitHub Action completed successfully
- Check Tailscale admin console for policy conflicts
- Verify API key has sufficient permissions
- Use a JSON validator that supports comments
- Check for missing commas or brackets
- Validate against Tailscale ACL schema
- GitHub Issues: Create an issue in this repository
- Tailscale Documentation: Official ACL docs
- Tailscale Community: Community forum
- Tailscale ACL Syntax Reference
- GitOps for Tailscale with GitHub Actions
- Tailscale Best Practices
- Zero Trust Networking
- Fork the repository
- Create a feature branch
- Make your changes with appropriate test cases
- Submit a pull request with a clear description
- Wait for review and approval
This repository is licensed under the MIT License. See LICENSE file for details.