Authentication overview
Apigee, a Google Cloud API management platform, provides mechanisms to authenticate client applications accessing APIs deployed through its proxies. Authentication in Apigee is typically handled by policies configured within API proxies, which enforce security requirements before requests reach backend services. This system allows API providers to control who can access their APIs and under what conditions, integrating with various identity providers and security standards (Apigee security overview). The platform supports both inbound authentication (securing API access for client applications) and outbound authentication (securing Apigee's access to backend services).
The core of Apigee's authentication capabilities lies in its policy framework. Developers configure policies such as VerifyAPIKey, OAuthV2, or JSONWebToken within an API proxy's flow. These policies execute at runtime, validating credentials and ensuring that requests meet defined security criteria before being forwarded to the target endpoint. This approach decouples authentication logic from backend services, centralizing security management within the API gateway layer (Apigee developer documentation).
Supported authentication methods
Apigee supports a comprehensive range of authentication methods, catering to different security requirements and integration scenarios. The choice of method depends on factors such as the sensitivity of the data, the type of client application, and compliance needs.
| Method | When to Use | Security Level |
|---|---|---|
| API Keys | Simple identification for public or low-risk APIs, rate limiting. | Basic (identification, not true authentication) |
| OAuth 2.0 | Delegated authorization for third-party applications accessing user data; widely adopted for web and mobile apps. | High (authorization framework, often combined with OpenID Connect for authentication) |
| JSON Web Tokens (JWT) | Stateless authentication for microservices, single sign-on (SSO), and passing verifiable claims between parties. | High (cryptographically signed, verifiable claims) |
| Basic Authentication | Legacy systems or internal APIs where simplicity is prioritized and transport-level security (TLS) is enforced. | Moderate (requires TLS for security) |
| Mutual TLS (mTLS) | High-security applications requiring client certificate validation, ensuring both client and server authenticate each other. | Very High (two-way authentication, strong identity verification) |
| SAML | Enterprise single sign-on (SSO) for integrating with corporate identity providers. | High (federated identity management) |
Each method offers distinct advantages. API keys are straightforward for identifying client applications and enforcing quotas (Apigee API key documentation). OAuth 2.0 is a robust framework for delegated authorization, allowing users to grant third-party applications limited access to their resources without sharing credentials (OAuth 2.0 specification overview). JWTs provide a compact, URL-safe means of representing claims to be transferred between two parties, often used for authentication and information exchange (JSON Web Token RFC 7519). Mutual TLS (mTLS) adds an extra layer of security by requiring both the client and server to present and validate cryptographic certificates, ensuring that only trusted parties can communicate.
Getting your credentials
The process of obtaining credentials in Apigee depends on the authentication method chosen and the role of the entity (API provider or API consumer).
For API Providers (configuring Apigee API proxies):
- API Keys: API providers generate API keys within the Apigee platform or an integrated developer portal. These keys are then associated with specific developer apps.
- OAuth 2.0: Apigee can act as an OAuth 2.0 authorization server, issuing client IDs and secrets for developer applications. The platform also provides policies to validate access tokens issued by external OAuth providers (Apigee OAuth 2.0 overview).
- JWT: Providers configure Apigee policies to verify JWTs issued by trusted identity providers. This involves specifying the public key or certificate used to sign the JWT. Apigee can also generate JWTs for outbound calls to backend services.
- mTLS: Configuring mTLS involves setting up keystores and truststores in Apigee to store client certificates and trusted certificate authorities, respectively (Apigee mTLS configuration guide).
For API Consumers (client applications):
- API Keys: Developers typically register their applications through an Apigee-powered developer portal. Upon registration, they receive an API key to include in their API requests.
- OAuth 2.0: Client applications obtain a client ID and client secret from the API provider (via the developer portal). They then use these credentials to initiate the OAuth 2.0 flow, obtaining an access token that grants them permission to call protected APIs.
- JWT: Client applications acquire a JWT from an identity provider (IdP) after successful authentication. This JWT is then passed to Apigee in the API request's authorization header.
- Basic Authentication: Clients are provided with a username and password, which are then base64-encoded and sent in the
Authorizationheader of HTTP requests. - mTLS: Client applications must be configured with a valid client certificate issued by a certificate authority trusted by Apigee. This certificate is presented during the TLS handshake.
Authenticated request example
Here's an example of an authenticated API request using an OAuth 2.0 access token, a common method for securing APIs with Apigee. This assumes the client has already obtained an access token from Apigee acting as an OAuth provider or an external IdP.
curl -X GET \
"https://your-apigee-domain.com/your-api-proxy/resource" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Accept: application/json"
In this example:
your-apigee-domain.comis the hostname where your Apigee API proxy is deployed.your-api-proxy/resourceis the specific path to the API resource being accessed.YOUR_ACCESS_TOKENis the OAuth 2.0 access token obtained by the client application. Apigee'sOAuthV2policy would validate this token against its internal store or an external IdP.
For API key authentication, the request would typically include the API key as a query parameter or a custom header:
curl -X GET \
"https://your-apigee-domain.com/your-api-proxy/resource?apikey=YOUR_API_KEY" \
-H "Accept: application/json"
Or, with a custom header:
curl -X GET \
"https://your-apigee-domain.com/your-api-proxy/resource" \
-H "x-api-key: YOUR_API_KEY" \
-H "Accept: application/json"
Security best practices
Implementing robust authentication in Apigee requires adherence to several security best practices to protect APIs and underlying data.
- Use OAuth 2.0 for user-facing APIs: For applications accessing user-specific data, OAuth 2.0 is the recommended standard for delegated authorization. Combine it with OpenID Connect for user authentication (Apigee OAuth 2.0 best practices).
- Prefer JWTs for microservices and stateless APIs: JWTs are efficient for secure, stateless communication between services, reducing the need for session management. Ensure proper signature validation in Apigee policies.
- Implement mTLS for sensitive internal APIs: For highly sensitive internal API communications, mutual TLS provides strong, two-way authentication, verifying both the client and server identities.
- Rotate API Keys and OAuth Secrets Regularly: Periodically rotate API keys and OAuth client secrets to minimize the risk of compromise. Apigee provides mechanisms for key management and rotation.
- Enforce Strong Credential Policies: For Basic Authentication, ensure strong password policies and always transmit credentials over TLS/SSL. Consider moving away from Basic Auth to more modern methods where possible.
- Limit API Key Permissions: API keys should be granted the minimum necessary permissions. Avoid using a single API key for all API access; instead, create specific keys for different applications or use cases.
- Secure Developer Portals: If using an Apigee Developer Portal, ensure it is secured with strong authentication mechanisms for developers, such as multi-factor authentication (MFA).
- Monitor Authentication Failures: Implement logging and monitoring for authentication failures. Repeated failed attempts can indicate brute-force attacks or credential stuffing. Use Apigee's analytics capabilities for this purpose (Apigee analytics documentation).
- Validate All Inputs: Beyond authentication, ensure all API inputs are validated to prevent injection attacks and other vulnerabilities. This is often handled by Apigee policies like
JSONThreatProtectionorXMLThreatProtection. - Use Environment-Specific Credentials: Never reuse production credentials in development or staging environments. Maintain separate sets of credentials for each environment.