You didn’t mention the kind of token to be verified.
You may be aware of the JWT standard. JWT are tokens that can be verified by any party who has access to the public key, or the shared key if using symmetric encryption.
If your OAuth token dispenser is delivering JWT, then Apigee Edge can simply verify them according to standard JWT practice. EDIT - here is a good example of an API Proxy that verifies JWT. You will need to add in the Java callout policy available on that github repo, and configure it like so:
<JavaCallout name='JWT-Parse-RS256'>
<Properties>
<Property name="algorithm">RS256</Property>
<Property name="jwt">{request.formparam.jwt}</Property>
<!-- public-key used only for algorithm = RS256 -->
<Property name="public-key">
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtxlohiBDbI/jejs5WLKe
Vpb4SCNM9puY+poGkgMkurPRAUROvjCUYm2g9vXiFQl+ZKfZ2BolfnEYIXXVJjUm
zzaX9lBnYK/v9GQz1i2zrxOnSRfhhYEb7F8tvvKWMChK3tArrOXUDdOp2YUZBY2b
sl1iBDkc5ul/UgtjhHntA0r2FcUE4kEj2lwU1di9EzJv7sdE/YKPrPtFoNoxmthI
OvvEC45QxfNJ6OwpqgSOyKFwE230x8UPKmgGDQmED3PNrio3PlcM0XONDtgBewL0
3+OgERo/6JcZbs4CtORrpPxpJd6kvBiDgG07pUxMNKC2EbQGxkXer4bvlyqLiVzt
bwIDAQAB
-----END PUBLIC KEY-----
</Property>
<!-- claims to verify -->
<Property name="claim_iss">http://dinochiesa.net</Property>
<Property name="claim_shoesize">8.5</Property>
</Properties>
<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://jwt-signed-edge-callout.jar</ResourceURL>
</JavaCallout>
Note: To verify an externally-generated JWT, you do not need to import client_ids or client_secrets into Apigee Edge. JWT are self-verifiable. There is no need for Apigee Edge to “know” the client_id you used when your client app contacted the external token issuer. If you want to use Apigee Edge to verify an externally-generated token that is not a JWT, then you DO need to import the client_id and client_secret.
There are some options for configuring this policy. For example if the public key changes, and is available at an external HTTP URL, then you will need to augment this policy with a ServiceCallout to retrieve the public key, then specify the variable that holds the PKCS8-PEM encoded public key like so:
<Property name="public-key">{variable_holding_public_key}</Property>
If the JWT uses HS256, then you need to specify the secret key instead of the public key.
Also you will want to modify the claims you are verifying. The policy automatically verifies the issued-at time and the not-before-time (if it exists) and the expiry time.
There is more information in the Readme on that github repo.
On the other hand if the token is an opaque token, then you will need one of the following:
- contact the token issuer for each verification of the token, probably via ServiceCallout
- “import” the token into Apigee Edge at issue time and use the standard VerifyAccessToken OAuth2 policy.
Which option you choose depends on your requirements.