Skip to content

Latest commit

 

History

History
263 lines (212 loc) · 19.9 KB

File metadata and controls

263 lines (212 loc) · 19.9 KB
description
This page details the usage and configuration parameters of the default APIM resources.

Resources

Overview

Every API Management installation includes several default resources that are commonly used in standard APIM implementations and can be configured during the API design phase. The recommended configuration method employs the Policy Studio.

The following sections summarize resource descriptions, configuration parameters, and configuration examples.

Resource descriptions

APIM includes several default resources, each of which is described in more detail below.

  • Cache: Maintains a cache linked to the API lifecycle, i.e., the cache is initialized when the API starts and released when the API stops. It is responsible for storing HTTP responses to avoid subsequent calls to the backend.
  • Cache Redis: Same as Cache (above), but the current implementation is based on Redis. The Cache Redis resource can be configured standalone or as part of the Redis Sentinel monitoring solution.
  • OAuth2 - Gravitee AM Authorization Server: Introspects an access_token generated by a Gravitee AM instance.
  • OAuth2 - Generic Authorization Server: Introspects an access_token generated by a generic OAuth2 authorization server. This resource provides a comprehensive configuration for how token introspection is applied in to accommodate common authorization servers.
  • Confluent Schema Registry: Fetches serialization/deserialization data from a Confluent schema registry.
  • Keycloak Adapter: Introspects an access token.
  • HTTP Authentication Provider: Validates user credentials against an HTTP server.
  • Inline Authentication Provider: Authenticates a user in memory.
  • LDAP Authentication Provider: Authenticates a user in LDAP.

{% hint style="warning" %} The Cache Redis plugin is not included in the default APIM distribution, but you can download and deploy it. For information on configuring cache in APIM, see Configure cache. For information on configuring the rate limit repository plugin for Redis, see Redis. {% endhint %}

OAuth2 APIM compatibility

APIM versionGravitee Access Management plugin versionGeneric Authorization Server plugin version
3.18.x to latest2.x and upper2.x and upper
3.10.x to 3.17.x1.14.x and upper1.16.x and upper
Up to 3.9.xUp to 1.13.xUp to 1.15.x

How to create a resource

To create a resource:

  1. Log in to APIM Management Console.

  2. Click APIs in the left sidebar.

  3. Select the API you want to add the resource to.

  4. Click Resources in the inner left sidebar.

  5. Select the resource you want to configure:

    Add a resource

  6. In the CREATE RESOURCE form, configure the resource per the Configuration options section.

Configuration options

Each resource can be customized with a unique set of configuration options.

Cache resources

{% tabs %} {% tab title="Cache" %}

Create a Cache resource

Config paramDescriptionDefault
Cache nameName of the cachemy-cache
Time to idleMaximum number of seconds an element can exist in the cache without being accessed. When this threshold is reached, the element expires and will no longer be returned from the cache. The default value is 0, i.e., no timeToIdle (TTI) eviction takes place (infinite lifetime).0
Time to liveMaximum number of seconds an element can exist in the cache, regardless of usage. When this threshold is reached, the element expires and will no longer be returned from the cache. The default value is 0, i.e., no timeToLive (TTL) eviction takes place (infinite lifetime).0
Max entries on heapMaximum number of objects to be held in local heap memory (0 = no limit)1000
{% endtab %}

{% tab title="Cache Redis" %}

Create a Cache Redis resource

The Cache Redis resource can operate standalone or with the Redis Sentinel monitoring solution. The majority of Cache Redis configuration options are common to both modes of operation, but several are exclusive to either standalone or Sentinel as indicated with a bold asterisk (*).

Config paramDescriptionDefault
Cache nameName of the cachemy-redis-cache
Release cache

Enabled: The resource will release the cache when the API is stopped

Disabled: The cache must be managed manually on the Redis server

false
Max totalMaximum number of connections supported by the pool8
PasswordThe password for the instance-
Time to liveMaximum number of seconds an element can exist in the cache, regardless of usage. When this threshold is reached, the element expires and will no longer be returned from the cache. The default value is 0, i.e., no timeToLive (TTL) eviction takes place (infinite lifetime).0
TimeoutSpecifies the connection timeout and the read/write timeout2000
Use SSLToggle to use SSL connectionstrue
Use standalone modeToggle to use standalone modetrue
HostThe host of the instance
*Standalone config only
localhost
PortThe port of the instance
*Standalone config only
6379
Use sentinel modeToggle to use sentinel mode. Sentinel provides high availability for Redis (effectively, the Redis deployment persists without human intervention, barring certain kinds of failures)false
MasterSentinel master ID
*Sentinel config only
sentinel-master
Sentinel passwordSentinel password
*Sentinel config only
-
Sentinel nodesArray of sentinel nodes
*Sentinel config only
-
{% endtab %} {% endtabs %}

OAuth2 resources

{% tabs %} {% tab title="Generic Authorization Server" %}

Create an OAuth2 Generic Authorization Server resource

Config paramDescriptionDefault
Resource nameName of the resource-
Authorization server URLURL of the authorization serverhttps://authorization_server
Token introspect endpointURL the resource uses to introspect an incoming access token/oauth/check_token
System proxyToggle to use system proxyfalse
Token introspect methodHTTP method to introspect the access tokenGET
Client IDClient identifier-
Client secretClient secret-
Use HTTP header for client authorizationTo prevent token scanning attacks, the endpoint MUST require access authorization. Gravitee uses an HTTP header for client authentication.true
Authorization headerAuthorization headerAuthorization
Authorization schemeAuthorization schemeBasic
Use a query parameter to supply access tokenAccess token is passed to the introspection endpoint using a query parametertrue
Token query param nameQuery parameter that supplies access tokentoken
Use an HTTP header to supply access tokenAccess token is passed to the introspection endpoint using an HTTP headerfalse
HTTP header nameHTTP header used to supply access token-
Use application/x-www-form-urlencoded form to send access tokenSend access token in application/x-www-form-urlencoded formfalse
Form param nameForm parameter nametoken
User claimUser claim field to store end user in log analyticssub
{% endtab %}

{% tab title="Gravitee AM Authorization Server" %}

Create an OAuth2 Gravitee AM Authorization Server resource

Config paramDescriptionDefault
Resource nameName of the resource-
Server URLURL of the Gravitee Access Management server-
System proxyToggle to use system proxyfalse
VersionVersion of the Access Management serverV3_X
Security domainSecurity domain (realm) from which the token has been generated and must be introspected-
Client IDClient identifier-
Client secretClient secret-
User claimUser claim field to store end user in log analyticssub
{% endtab %} {% endtabs %}

Authentication Provider resources

{% tabs %} {% tab title="HTTP" %}

Create an HTTP Authentication Provider resource

Config paramDescriptionDefault
Resource nameThe name of the resource-
HTTP methodHTTP method to invoke the endpointPOST
Use system proxyToggle to use the system proxy configured by your administratorfalse
URLServer URL-
Request bodyThe body of the HTTP request. Supports the Gravitee Expression Language.-
Authentication conditionThe condition to be verified to validate that the authentication is successful. Supports the Gravitee Expression Language.{#authResponse.status == 200}
{% endtab %}

{% tab title="Inline" %}

Create an Inline Authentication Provider resource

Config param Description Default
Resource name The name of the resource -
Inline users List of inline users -
{% endtab %}

{% tab title="LDAP" %}

Create an LDAP Authentication Provider resource

Config paramDescriptionDefault
Resource nameThe name of the resource-
LDAP URLThe URL of the LDAP server, e.g., ldap://myserver.example.com:389. For SSL access, use the LDAPs protocol and the appropriate port, e.g., ldaps://myserver.example.com:636. For failover functionality, specify multiple URLs separated by commas (,).-
Use StartTLSToggle to use StartTLSfalse
Base DNThe base DN. Once configured, all Distinguished Names supplied to and received from LDAP operations are relative to the specified LDAP path.-
UsernameThe username (principal) to use when authenticating with the LDAP server. Usually the DN of an admin user (e.g., Administrator), but may differ depending on server and authentication method.-
PasswordThe password (credentials) to authenticate with the LDAP server-
User search filterFilter by user IDuid={0}
User search baseIf user search base isn't supplied, the search will be performed from the rootou=users
Cache - maximum number of elementsMaximum number of cache elements used to store successful authentications100
Cache - time to liveMaximum time to live of cache elements used to store successful authentications60000
Connect timeoutDuration of time (milliseconds) that connections will block5000
Response timeoutDuration of time (milliseconds) to wait for responses5000
Min pool sizeMinimum pool of initialized connections5
Max pool sizeMaximum pool of initialized connections15
{% endtab %} {% endtabs %}

Confluent and Keycloak resources

{% tabs %} {% tab title="Confluent Schema Registry" %} {% hint style="warning" %} Enterprise only

As of Gravitee 4.0, the ability to use Confluent Schema Registry as a resource is an Enterprise Edition capability. To learn more about Gravitee Enterprise, and what's included in various enterprise packages, please:

Create a Confluent Schema Registry resource

Config paramDescriptionDefault
Resource nameName of the resource-
Registry URLURL of the schema registry-
Use proxyToggle to use proxy to fetch schemafalse
Proxy typeThe type of the proxyHTTP CONNECT proxy
Use system proxyToggle to use proxy configured at system levelfalse
Proxy hostProxy host to connect to-
Proxy portProxy port to connect to-
Proxy usernameOptional proxy username-
Proxy passwordOptional proxy password-
Authentication modeThe authentication mode used to connect to Schema RegistryBasic
Authentication usernameAuthentication username-
Authentication passwordAuthentication password-
Verify hostToggle to enable host name verificationtrue
Trust allToggle to force the Gateway to trust any origin certificates. Use with caution over the Internet. The connection will be encrypted but this mode is vulnerable to 'man in the middle' attacks.false
Trust store typeThe type of the trust storeNone
Key store typeThe type of the key storeNone
{% endtab %}

{% tab title="Keycloak Adapter" %}

Create a Keycloak Adapter resource

Config param Description Default
Resource name The name of the resource -
Keycloak client configuration The configuration of the Keycloak client -
Local token validation Toggle to use local token validation true
User claim User claim field to store end user in log analytics sub
Verify host Verify certificate on SSL connection to Keycloak host false
Trust all Trust all certificates, including self-signed true
{% endtab %}
{% endtabs %}

Examples

Below are example JSON configuration files for several of the default resources.

{% tabs %} {% tab title="Cache" %}

{
    "name": "cache",
    "type": "cache",
    "enabled": true,
    "configuration": {
        "name": "my-cache",
        "timeToIdleSeconds":0,
        "timeToLiveSeconds":0,
        "maxEntriesLocalHeap":1000
    }
}

{% endtab %}

{% tab title="Cache Redis" %} Standalone configuration example:

{
    "name": "my-redis-cache",
    "type": "cache-redis",
    "enabled": true,
    "configuration": {
        "name": "my-redis-cache",
        "releaseCache": false,
        "maxTotal": 8,
        "password": "secret",
        "timeToLiveSeconds": 600,
        "timeout": 2000,
        "useSsl": true,
        "sentinelMode" : false,
        "standalone": {
            "host": "localhost",
            "port": 6379
        }
    }
}

Sentinel configuration example:

{
    "name" : "my-redis-cache",
    "type" : "cache-redis",
    "enabled" : true,
    "configuration" : {
        "name" : "my-redis-cache",
        "releaseCache": false,
        "maxTotal" : 8,
        "password" : "secret",
        "timeToLiveSeconds" : 600,
        "timeout" : 2000,
        "useSsl" : true,
        "sentinelMode" : true,
        "sentinel" : {
            "masterId" : "sentinel-master",
            "password" : "secret",
            "nodes": [
              {
                "host" : "localhost",
                "port" : 26379
              },
              {
                "host" : "localhost",
                "port" : 26380
              },
              {
                "host" : "localhost",
                "port" : 26381
              }
            ]
        }
    }
}

{% endtab %}

{% tab title="OAuth2 - Gravitee AM" %}

{
    "configuration": {
        "clientId": "my-client",
        "clientSecret": "f2ddb55e-30b5-4a45-9db5-5e30b52a4574",
        "securityDomain": "my-security",
        "serverURL": "https://graviteeio_access_management",
        "userClaim": "sub"
    }
}

{% endtab %}

{% tab title="OAuth2 - Generic Auth Server" %}

{
    "configuration": {
        "introspectionEndpoint": "https://my_authorization_server/oauth/check_token",
        "introspectionEndpointMethod": "POST",
        "clientAuthorizationHeaderName": "Authorization",
        "clientAuthorizationHeaderScheme": "Basic",
        "clientId": "my-client",
        "clientSecret": "f2ddb55e-30b5-4a45-9db5-5e30b52a4574",
        "tokenIsSuppliedByHttpHeader": false,
        "tokenIsSuppliedByQueryParam": true,
        "tokenQueryParamName": "token",
        "useClientAuthorizationHeader": true
    }
}

{% endtab %} {% endtabs %}