Auto-Provisioning
Waldur's auto-provisioning feature automatically creates projects and provisions resources for new users based on predefined rules. This capability streamlines user onboarding by eliminating manual setup processes.
Overview
Auto-provisioning works by matching new users against configured rules based on email patterns or affiliations. When a matching rule is found, the system:
- Creates or assigns users to projects
- Grants appropriate project roles
- Optionally provisions marketplace resources
- Processes orders automatically
Core Components
Rule Model
The Rule model (src/waldur_autoprovisioning/models.py:11) defines auto-provisioning configurations with the following key fields:
- customer: Target customer for project creation (optional when using organization mapping)
- plan: Optional marketplace plan to provision
- plan_attributes: Custom attributes for resource provisioning
- plan_limits: Resource limits (e.g.,
{"vcpu": 4, "ram": 8192, "storage": 100}) - project_role: Role assigned to users in created projects
- use_user_organization_as_customer_name: Map user's organization claim to existing customer
- project_name_template: Template for project naming (e.g.,
"{username}_workspace")
User Matching
Rules use the UserDetailsMatchMixin for pattern matching:
- user_email_patterns: Regex patterns for email matching (e.g.,
[".+@example.com"]) - user_affiliations: Organization affiliations for matching
Pattern matching supports standard regex syntax and handles invalid patterns gracefully.
Organization Mapping Feature
Organization Mapping Overview
The organization mapping feature (added in commit 77c31bb25) allows auto-provisioning rules to dynamically resolve customers based on user organization claims from identity providers. This enables multi-tenant scenarios where each organization has its own customer in Waldur.
How It Works
When use_user_organization_as_customer_name is enabled:
- System extracts organization claim from user's identity provider data
- Looks up existing customer with matching name
- Creates project under the resolved customer
- Validates user has protected details flag set
Protected User Details
For security, organization mapping requires users to have protected details:
1 2 3 4 5 6 7 8 9 | |
Customer Resolution Logic
From src/waldur_autoprovisioning/handlers.py:33:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
API Endpoints
Rules Management
Endpoint: /api/autoprovisioning-rules/
Permissions:
- List/Read: Customer role permissions
- Create/Update/Delete: Staff only
Serialization: RuleSerializer provides comprehensive API access with related object details:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Validation Rules
The serializer enforces these validation constraints:
- Either
customeroruse_user_organization_as_customer_name=truemust be specified - Either
project_roleorproject_role_namemust be provided (but not both) - Project role must be valid for project-level permissions
- Email patterns must be valid regex expressions
Processing Flow
Trigger Mechanism
Auto-provisioning activates via Django signal (src/waldur_autoprovisioning/apps.py:13):
1 2 3 4 5 | |
Auto-Provisioning Workflow
- User Creation: New user triggers
handle_new_userhandler - Rule Matching: System finds applicable rules using
Rule.get_objects_by_user_patterns() - Customer Resolution: Either use configured customer or resolve from organization
- Project Creation:
get_or_create_project()creates or assigns project - Resource Provisioning: If plan is specified, creates marketplace order
- Order Processing: Marketplace processes the order asynchronously
Configuration Examples
Basic Project Creation
Create projects without resources:
1 2 3 4 5 6 | |
Resource Provisioning
Auto-provision OpenStack tenants:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Organization-Based Provisioning
Use user's organization for customer assignment:
1 2 3 4 5 6 | |
Multi-Tenant Academic Setup
Support multiple universities with their own customers:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Security and Validation
Protected Users
Organization-based provisioning requires protected user details to ensure organization claims come from trusted identity providers and cannot be manipulated by users.
Input Validation
- Email patterns validated as proper regex
- Project role must be valid project-level role
- Customer or organization requirement enforced
- Plan compatibility verified
- Mutual exclusion of customer specification methods
Permission Controls
- Rules managed by staff users only
- Customer-scoped access for viewing
- Project creation respects customer permissions
Monitoring and Logging
The system provides comprehensive logging for troubleshooting:
- Invalid regex patterns logged and skipped
- Missing organization claims logged
- Multiple customer matches warned
- Order creation and processing tracked
- Protected user validation failures logged
Integration Points
Marketplace Integration
Auto-provisioning integrates with Waldur's marketplace:
- Uses
marketplace_utils.generate_resource_name()for naming - Creates
ResourceandOrderobjects - Triggers
process_order_on_commit()for async processing - Respects marketplace offering types and constraints
User Management Integration
- Hooks into user creation process
- Respects user protection settings
- Leverages organization claims from identity providers
- Integrates with role-based access control
Identity Provider Integration
- Reads organization claims from SAML/OIDC providers
- Validates user registration method for security
- Maps organization names to existing customers
- Supports multi-tenant identity scenarios
Best Practices
- Rule Design: Create specific rules for different user groups
- Organization Mapping: Ensure customer names match organization claims exactly
- Naming Templates: Use descriptive project naming templates
- Resource Limits: Set appropriate defaults for auto-provisioned resources
- Monitoring: Monitor logs for failed provisioning attempts
- Security: Configure protected registration methods for organization-based rules
- Multi-Tenancy: Use organization mapping for SaaS scenarios with multiple customers