The Terraform Provider for Pocket-ID enables you to manage OIDC clients, users, and groups in your Pocket-ID instance using Infrastructure as Code.
Pocket-ID is a simple, self-hosted OpenID Connect (OIDC) provider that uses passkeys for authentication instead of passwords. This makes it more secure and user-friendly than traditional authentication methods.
- 🔐 OIDC Client Management: Create and manage OAuth2/OIDC client applications
- 👥 User Management: Manage user accounts (passkey registration via UI)
- 👨👩👦👦 Group Management: Organize users and control access with groups
- 🔑 Secure Authentication: API token-based provider authentication
- 🚀 Easy to Use: Simple, intuitive resource definitions
- 📚 Well Documented: Comprehensive documentation and examples
- Terraform >= 1.0
- Go >= 1.20 (for development)
- A running Pocket-ID instance
- An API token from your Pocket-ID instance
terraform {
required_providers {
pocketid = {
source = "trozz/pocketid"
version = "~> 1.0"
}
}
}- Download the latest release from the releases page
- Extract the archive
- Move the binary to
~/.terraform.d/plugins/registry.terraform.io/trozz/pocketid/${VERSION}/${OS_ARCH}/
All release artifacts include build attestations for supply chain security. To verify the authenticity of a release:
# Using GitHub CLI
gh attestation verify terraform-provider-pocketid_v1.0.0_darwin_amd64.zip \
--owner Trozz \
--repo terraform-provider-pocketidFor more information about attestations, see our attestations documentation.
# Using provider configuration
provider "pocketid" {
base_url = "https://auth.example.com"
api_token = var.pocketid_api_token
}
# Or using environment variables
# export POCKETID_BASE_URL="https://auth.example.com"
# export POCKETID_API_TOKEN="your-api-token"resource "pocketid_client" "web_app" {
name = "My Web Application"
callback_urls = [
"https://app.example.com/callback",
"http://localhost:3000/callback"
]
is_public = false
pkce_enabled = true
}
output "client_id" {
value = pocketid_client.web_app.id
}
output "client_secret" {
value = pocketid_client.web_app.client_secret
sensitive = true
}# Create a group
resource "pocketid_group" "developers" {
name = "developers"
friendly_name = "Development Team"
}
# Create a user
resource "pocketid_user" "john_doe" {
username = "johndoe"
email = "[email protected]"
first_name = "John"
last_name = "Doe"
groups = [pocketid_group.developers.id]
}pocketid_client- Manages OIDC client applicationspocketid_user- Manages user accountspocketid_group- Manages user groups
pocketid_client- Queries a single OIDC clientpocketid_clients- Lists all OIDC clientspocketid_user- Queries a single user by ID or usernamepocketid_users- Lists users with optional filtering
Full documentation is available on the Terraform Registry.
See the examples directory for complete working examples:
- Basic Provider Setup
- Complete Example - Full setup with clients, users, and groups
- Resource Examples - Individual resource examples
- Go 1.20+
- Terraform 1.0+
- A Pocket-ID instance for testing
# Clone the repository
git clone https://github.com/Trozz/terraform-provider-pocketid.git
cd terraform-provider-pocketid
# Install dependencies
make deps
# Build the provider
make build
# Install locally for testing
make installImportant Note: Due to Pocket-ID's security model, acceptance tests cannot be run in CI/CD pipelines. Pocket-ID requires:
- Manual passkey registration through the web UI
- Manual API key generation through the admin interface
- No programmatic way to bootstrap an instance
# Run unit tests - these run in CI
make testAcceptance tests require a manually configured Pocket-ID instance:
-
Start a Pocket-ID instance
-
Register a user with a passkey through the web UI
-
Generate an API key in the admin interface
-
Set environment variables:
export POCKETID_BASE_URL="https://your-pocket-id-instance.com" export POCKETID_API_TOKEN="your-api-token"
-
Run acceptance tests:
make test-acc
See TESTING.md for detailed testing instructions and strategies.
This project uses Codecov for code coverage and test analytics:
- Code Coverage: Track test coverage across all packages
- Test Analytics: Monitor test performance and identify flaky tests
- Failed Test Reporting: Get detailed reports on test failures
- PR Comments: Automatic coverage reports on pull requests
For detailed test reporting, use gotestsum:
# Install gotestsum if not already installed
go install gotest.tools/gotestsum@latest
# Run tests with JUnit XML output
make test-junit
# Or run in CI format
make test-ciThis generates:
coverage.out- Code coverage reportjunit.xml- JUnit format test results for test analytics
Generate an HTML coverage report:
make test-coverage
# Opens coverage.html in your default browser-
Start a local Pocket-ID instance:
make pocket-id-start
-
Build and install the provider:
make dev
-
Use the provider in your Terraform configuration
Enable debug logging:
export TF_LOG=DEBUG
terraform applyContributions are welcome! Please see our Contributing Guidelines for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write tests for your changes
- Ensure all tests pass (
make test-all) - Update documentation as needed
- Follow the existing code style
- Add yourself to the CONTRIBUTORS file
- Support for webhook resources
- Bulk user import functionality
- Enhanced policy management
- Session management features
- Automated passkey registration (when/if API supports it)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Pocket-ID: Pocket-ID Repository
Please report security vulnerabilities to [email protected]. Do not open public issues for security problems.
- Never commit API tokens to version control
- Use environment variables or secure secret management
- Enable TLS verification in production
- Regularly rotate API tokens
- Follow the principle of least privilege for API tokens
This project is licensed under the MIT License - see the LICENSE file for details.
- The Pocket-ID team for creating an awesome OIDC provider
- The Terraform Plugin Framework team
- All contributors who have helped improve this provider
Made with ❤️ by the Terraform Pocket-ID Provider community