- Overview
- Getting Started
- Framework Components
- Policies
- Shared Flows
- Naming Conventions
- Best Practices
- Examples
- Deployment
- Troubleshooting
The Apigee Development Framework provides a comprehensive set of reusable policies and shared flows for building robust API proxies in Google Apigee. This framework follows industry best practices and provides consistent patterns for common API development scenarios.
- Security Policies: CORS, OAuth2, API Key validation
- Traffic Management: Rate limiting, spike arrest
- Data Transformation: JSON/XML conversion
- Monitoring: Response caching, logging
- Error Handling: Standardized error responses
- Logging: Comprehensive audit logging with sensitive data masking
- Google Apigee Edge account
- Apigee CLI tools installed
- Basic understanding of Apigee concepts
- Clone or download the framework
- Import shared flows into your Apigee organization
- Copy policies to your API proxy projects
- Reference the components in your proxy configurations
<!-- In your proxy endpoint -->
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>security-cors-v1</Name>
<Condition>request.verb == "OPTIONS"</Condition>
</Step>
<Step>
<Name>authentication-oauth2-v1</Name>
</Step>
<Step>
<Name>logging-audit-v1</Name>
</Step>
</Request>
</PreFlow>framework/
├── policies/ # Reusable policies
│ ├── security/ # Security-related policies
│ ├── traffic/ # Traffic management policies
│ ├── transformation/ # Data transformation policies
│ └── monitoring/ # Monitoring and analytics policies
├── shared-flows/ # Reusable shared flows
│ ├── logging/ # Logging and audit flows
│ ├── error-handling/ # Error handling flows
│ ├── authentication/ # Authentication flows
│ └── utilities/ # Utility flows
├── examples/ # Example implementations
├── templates/ # API proxy templates
└── docs/ # Documentation
Handles Cross-Origin Resource Sharing for web applications.
Usage:
<Step>
<Name>security-cors-v1</Name>
<Condition>request.verb == "OPTIONS"</Condition>
</Step>Configuration:
- Allowed origins: Configurable via policy
- Allowed methods: GET, POST, PUT, DELETE, OPTIONS
- Allowed headers: Content-Type, Authorization, X-Requested-With, X-API-Key
- Exposed headers: X-Request-ID, X-Response-Time
Validates OAuth2 access tokens.
Usage:
<Step>
<Name>security-oauth2-v1</Name>
</Step>Supported Grant Types:
- client_credentials
- authorization_code
- refresh_token
Validates API keys from request headers.
Usage:
<Step>
<Name>security-api-key-v1</Name>
</Step>Implements quota-based rate limiting.
Configuration:
- Default: 1000 requests per hour
- Identifier: client_id
- Distributed: true
Prevents traffic spikes.
Configuration:
- Rate: 10 requests per second
- Identifier: client_id
Converts JSON responses to XML format.
Usage:
<Step>
<Name>transformation-json-to-xml-v1</Name>
<Condition>request.header.accept == "application/xml"</Condition>
</Step>Converts XML responses to JSON format.
Caches responses for performance optimization.
Configuration:
- Cache key: URI + query parameters
- Timeout: 300 seconds
- Scope: Global
Comprehensive logging with sensitive data masking.
Features:
- Request/response logging
- Sensitive data masking
- Structured log format
- External system integration
Usage:
<Step>
<Name>logging-audit-v1</Name>
</Step>Sensitive Data Masking:
- Passwords, tokens, API keys
- Credit card numbers
- Social Security Numbers
- Email addresses
- Phone numbers
Standardized error responses.
Features:
- Consistent error format
- Proper HTTP status codes
- Error logging
- Standard headers
Usage:
<FaultRule name="ErrorHandling">
<Step>
<Name>error-handling-standard-v1</Name>
<Condition>fault.name != "error-handling-standard-v1"</Condition>
</Step>
</FaultRule>OAuth2 authentication flow.
Features:
- Token extraction
- Token validation
- Context setting
Request validation utilities.
Features:
- Header validation
- Parameter validation
- JSON schema validation
Format: {category}-{function}-{version}
- Example:
security-cors-v1 - Example:
traffic-rate-limit-v1
Format: {purpose}-{function}-{version}
- Example:
logging-audit-v1 - Example:
error-handling-standard-v1
Format: {scope}.{category}.{name}
- Example:
request.header.authorization - Example:
response.status.code
- Policies:
{policy-name}.xml - Shared Flows:
{shared-flow-name}.xml - JavaScript:
{function-name}.js
- Group related policies in folders
- Use consistent naming conventions
- Document policy purposes and configurations
- Always implement fault rules
- Use standardized error responses
- Log errors for monitoring
- Implement authentication for all endpoints
- Use HTTPS for all communications
- Mask sensitive data in logs
- Use response caching where appropriate
- Implement rate limiting
- Monitor response times
- Log all requests and responses
- Mask sensitive data
- Use structured log formats
See examples/sample-api-proxy/ for a complete example demonstrating:
- CORS handling
- OAuth2 authentication
- Rate limiting
- Request validation
- Comprehensive logging
- Error handling
<!-- Custom rate limiting -->
<Step>
<Name>traffic-rate-limit-v1</Name>
<Condition>request.header.x-client-tier == "premium"</Condition>
</Step># Deploy shared flows
apigeetool deploySharedFlow -o {org} -e {env} -n logging-audit-v1 -d framework/shared-flows/logging/
# Deploy API proxy
apigeetool deployProxy -o {org} -e {env} -n sample-api-proxy -d framework/examples/sample-api-proxy/<plugin>
<groupId>com.apigee.edge</groupId>
<artifactId>apigee-edge-maven-plugin</artifactId>
<version>1.1.0</version>
</plugin>- Check policy names and references
- Verify policy configurations
- Review error logs
- Verify OAuth2 configuration
- Check token format
- Validate client credentials
- Check external system connectivity
- Verify log format
- Review sensitive data masking
- Monitor response times
- Check cache configurations
- Review rate limiting settings
- Enable debug logging
- Use trace tool in Apigee Edge
- Check policy execution order
- Verify variable assignments
For issues and questions:
- Check the documentation
- Review example implementations
- Consult Apigee Edge documentation
- Contact the framework maintainers
- Initial framework release
- Core policies and shared flows
- Comprehensive logging with data masking
- Example implementations
- Complete documentation