Authentication & Authorization
Comprehensive guide to configuring authentication and authorization for Elsa Workflows, covering OIDC providers, API keys, custom authentication, and security best practices.
Overview
Table of Contents
Prerequisites
No Authentication (Development Only)
Disabling API Security
Disabling Studio Authorization
Using Elsa.Identity
1. Install NuGet Packages
2. Configure Services
3. Configure Default Admin User
4. Create Additional Users
5. Obtain Authentication Token
OIDC Configuration
General OIDC Setup
Azure AD Integration
Step 1: Register Application in Azure Portal
Step 2: Create Client Secret
Step 3: Configure API Permissions
Step 4: Install NuGet Packages
Step 5: Configure Services in Program.cs
Step 6: Add Configuration to appsettings.json
Step 7: Configure Studio for Azure AD
Auth0 Integration
Step 1: Create Auth0 Application
Step 2: Configure Application Settings
Step 3: Create API in Auth0 (Optional)
Step 4: Install NuGet Packages
Step 5: Configure Services in Program.cs
Step 6: Add Configuration to appsettings.json
Step 7: Obtaining and Using Tokens
Generic OIDC Provider
Step 1: Install NuGet Packages
Step 2: Configure Services in Program.cs
Step 3: Add Configuration to appsettings.json
Example: Keycloak Configuration
API Key Authentication
Implementation Approach
Step 1: Create API Key Model
Step 2: Create API Key Store
Step 3: Create Authentication Handler
Step 4: Register Services
Step 5: Create API Management Endpoints
Step 6: Using API Keys
Persistent API Key Storage
Custom Authentication Provider
Example: Header-Based Authentication
Step 1: Create Custom Authentication Handler
Step 2: Create User Service Interface
Step 3: Register Custom Authentication
Step 4: Using Custom Authentication
Multiple Authentication Schemes
Studio Authentication Configuration
Studio with JWT Bearer Tokens
Studio with OIDC
Studio with API Keys
Studio WASM Configuration
Troubleshooting
401 Unauthorized Errors
404 Not Found Errors
CORS Issues with Studio
Token Expiration Issues
HTTPS/SSL Certificate Issues
Debugging Authentication Flow
Security Best Practices
1. Use HTTPS Everywhere
2. Secure Signing Keys
3. Implement Token Expiration
4. Use Role-Based Access Control
5. Implement Rate Limiting
6. Validate Redirect URIs
7. Implement Logging and Monitoring
8. Rotate API Keys Regularly
9. Protect Against CSRF
10. Security Headers
Production Considerations
1. Distributed Caching for Tokens
2. Database-Backed User Store
3. Load Balancer Configuration
4. Health Checks with Authentication
5. Environment-Specific Configuration
6. Monitoring and Alerting
7. Backup Authentication Method
8. Regular Security Audits
9. Disaster Recovery
10. Documentation
Summary
Last updated