Configuring Apigee for PingAuthorize integration
In order for Apigee to use PingAuthorize as an external policy runtime service, you must install the PingAuth Shared Flow and configure Apigee.
Adding the PingAuthorize Shared Flow to Apigee
About this task
To install the PingAuth Shared Flow bundle in Apigee and configure it to integrate with PingAuthorize:
Steps
-
Create a new bundle:
Choose from:
-
For Apigee X, go to Develop → Shared Flows and click Upload Bundle.
-
For Apigee Edge and Apigee Private Cloud, click +Shared Flow and then click Upload Bundle.
-
-
Upload the PingAuth Shared Flow bundle
.zip
file and name the shared flowPingAuth
. -
Configure the connection to PingAuthorize:
Choose from:
-
Apigee X
Apigee X doesn’t support managing the configuration values stored in key value maps through the Apigee UI. You must add these configuration values to the key value map policy. The key value map is created and the configuration values are added the first time the PingAuth Shared Flow executes at runtime.
-
Go to Develop → Shared Flows → PingAuth.
-
On the Develop tab, select the latest revision in the Revisions list.
-
In the Policies list, select the Load KVM Config policy.
-
Remove the comment characters above and below the
InitialEntries
element in the policy editor panel. -
Edit the value for
service_host_port
to match the host name of your PingAuthorize server and the port of the HTTPS connection handler.For example,
pingauthorize:8443
.You can find the HTTPS connection handler port from the Configuration page of the PingAuthorize administrative console by going to System → Connection Handlers.
-
Edit the value of
shared_secret
to match the value of the shared secret that you created in PingAuthorize. -
Click Save.
Your finished configuration should look like this:
-
-
Apigee Edge and Apigee Private Cloud
Apigee Edge stores environment-specific configuration values in key value maps so that the same policies can be used across multiple deployment environments without any changes to the policies.
-
Go to Environment → Key Value Maps and click +Key Value Map.
-
Edit the key value map and click Add Entry.
-
Use the key name
service_host_port
and set the value to match the host name of your PingAuthorize server and the port of the HTTPS connection handler. For example,pingauthorize:8443
. -
Add a key called
shared_secret
and set the value to the shared secret that you created in PingAuthorize. -
Click Save.
Your finished configuration should look like this:
-
-
-
Optional: Configure HTTPS trust for PingAuthorize.
By default, the PingAuth Shared Flow is configured to only trust the PingAuthorize HTTPS connection handler certificate if it is issued from a well-known certificate authority. To enable Apigee to trust specific HTTPS certificates from PingAuthorize servers:
-
Go to Environment → TLS Keystores and click +Keystore.
-
Give the keystore a name that helps you identify your PingAuthorize environment. For example,
PingAuthorize-dev-truststore
. -
Click the button to add a certificate. Enter a certificate alias and upload the certificate that is configured for the HTTPS connection handler in PingAuthorize. Click Save.
-
Go to Environment → References and click +Reference.
-
Name the new reference
PingAuthTrust
. Select the keystore that you created previously, and then click Save. -
Go to Develop → Shared Flows → PingAuth.
-
On the Develop tab, select the latest revision in the Revisions list.
-
In the Policies list, select the Sideband Call policy.
-
Remove the comment characters surrounding the
TrustStore
element in the policy editor panel, and then click Save.
-
-
Go to Develop → Shared Flows → PingAuth and deploy the most recent revision to your environment.
Adding an API proxy in Apigee
About this task
To configure the API proxy in Apigee to point to the target endpoint that you want to reach:
Steps
-
Go to API Proxies → Create Proxy and click the Reverse proxy tile.
-
On the Proxy details page, complete the Name, Base path, and Target (Existing API) fields.
-
On the Common policies page, click Pass through (no authorization).
If you need to add an OAuth flow to your API proxy, complete these steps, and then see Configuring an OAuth flow in Apigee (optional).
-
Select your deployment environment.
-
Click Create and Deploy.
Configuring an OAuth flow in Apigee (optional)
Before you begin
You must add an API proxy in Apigee.
About this task
This task only applies if you want to add OAuth authentication to the API proxy in Apigee. If you don’t want to add an OAuth flow, proceed to Attaching the PingAuthorize Shared Flow to API proxies.
These steps reference the Apigee Edge documentation. As you proceed, use values that correspond to you and your Apigee environment instead of the suggested example values. If needed, consult the Apigee X documentation. |
Steps
-
Create an API product:
-
Optional: Add scopes to the Allowed OAuth scopes field.
-
-
Create a developer and an app.
You can ignore the steps referring to the Key and Secret.
-
Create an API proxy to generate an access token:
-
Go to API Proxies → Create Proxy and click the No target tile.
-
On the Proxy details page, enter
/token
in the Base path field. -
On the Common policies page, click Pass through (no authorization).
You will configure the OAuth authentication in another step.
-
-
Add the OAuth policy to the token proxy:
-
In the Policies list on the Develop tab of the token proxy, click the icon to add a policy.
-
In the Security section, select the OAuthV2 policy.
-
In the policy editor panel, add and define at least one custom attribute for your access token using the
<Attribute>
element inside of the<Attributes>
element.Example:
You must use one of the custom attributes added in this step to provide a value to the
sub
attribute in the PingAuth Shared Flow. The following example specifies theusername
attribute, but you can specify any custom attribute defined in this step.
-
-
Map a custom attribute value to the value of the
sub
attribute:-
Open the PingAuth Shared Flow in Apigee.
-
In the Resources list, select the
Prepare-Request.js
file. -
Uncomment this line:
validated_access_token_values["sub"] = context.getVariable('accesstoken.{custom_attribute}')
-
Replace
{custom_attribute}
with the value of a previously defined custom attribute.Example:
-
-
Configure Apigee to validate the access token:
-
Read the
oauth_flow/Readme
document in the Ping Identity GitLab repository. -
Download the
VerifyAccessToken
andGetOAuthInfo
files. -
In the API proxy hosting the PingAuth Shared Flow, add GetOAuthv2Info and VerifyAccessToken as policies.
-
Select PreFlow in the Proxy Endpoints list.
-
In the policy editor, before the PingAuth Shared Flow call, add a step for the GetOAuthv2Info policy.
-
In the policy editor, before the GetOAuthv2Info policy call, add a step for the VerifyAccessToken policy.
After configuration, the API proxy should look like the following:
-
Result
Apigee issues and verifies the OAuth access token before launching the API proxy flow containing the PingAuth Shared Flow. The PingAuth Shared Flow is configured to pass the access token, when present, in the payload of the sideband request to PingAuthorize.
Passing the access token to the sideband endpoint using the request payload takes precedence over passing the token using the authorization header. |
Attaching the PingAuthorize Shared Flow to API proxies
About this task
To attach the PingAuth Shared Flow to the API proxies where you want to use PingAuthorize as the external authorization policy runtime service:
Steps
-
Add a Flow Callout policy:
-
Go to one of your APIs in Develop → API Proxies and click the Develop tab.
Ensure you are on the latest revision of the proxy.
-
Click the icon to add a policy to the Policies list.
-
In the Extension section, click Flow Callout.
-
Select PingAuth from the Shared Flow list. Enter a policy name and then click Add.
-
-
Attach the Flow Callout policy to flows.
Because PingAuthorize typically provides fine-grained authorization, you should integrate PingAuthorize late in the PreFlow of the request to the proxy endpoint, after the coarse-grained authentication and authorization functions. See the Apigee documentation for more information on integrating PingAuthorize.
-
In the Proxy Endpoints list on the left navigation pane, select PreFlow, and then click +Step in the Request section to add a flow step to the request.
-
On the Existing tab of Policy instance, select the Flow Callout policy that you created previously and click Add.
-
In the Target Endpoints list on the left navigation pane, select PreFlow, and then click +Step in the Response section to add a flow step to the response.
This allows PingAuthorize to process the API response from the target API before it is processed by Apigee.
-
On the Existing tab of the Policy instance, select and add the previously created Flow Callout policy.
-
-
Save and deploy the updated proxy.
Next steps
Configure fine-grained authorization policies in your PingAuthorize Policy Editor. To understand how to target specific API requests and extract other HTTP metadata to use in your policies, see Sideband API policy requests.