If the verification and authentication method provided by the API Gateway cannot meet your requirements, you can use custom verification plugin to verify and authenticate a request.
Custom verification plugin applies during the request process. The API Gateway will forward the request to the verification SCF after receiving it from the Client. Then, the request will be forwarded to the service backend only if it passes the verification by the SCF, otherwise the request will be denied.
Note:
- You need to write the verification SCF. For more information, see Template of Custom Verification SCF.
- Custom verification plugin requires to return the value of api-auth in the Body of the response body that is returned to the gateway. When the value is
true
, it means the verification is passed; when the value isfalse
ornull
, it means the verification is failed.
Parameter | Required | Description |
---|---|---|
Select an SCF | Required | You need to select the namespace, name and version of the verification SCF. |
Backend timeout | Required | This sets the backend timeout that the API Gateway forwards the request to the verification SCF. The maximum time limit is 30 minutes. When no response is returned before the timeout after the API Gateway calls the SCF, the API Gateway will end the call and returns an error message. |
Whether to send Body | Required | When the value is "Yes", the Header, Body and Query requested by the Client will be sent to the SCF; when the value is "No", the Body requested will not be sent. |
Verification parameter | Optional | It sets the request parameters for verification. When caching time is not 0 , this parameter must be set. When caching is enabled, the verification result will be queried with this parameter as the search condition. |
Caching time | Required | It sets the caching time for the verification result. 0 indicates that caching is not enabled. Caching time can be up to 3,600 seconds. |
Note:After caching is enabled, the API Gateway will record the relationship between the value of authentication parameter and the value of api-auth. If there is subsequent request during caching time, and the value of authentication parameter is the same as the value of the first request, the request will not be forwarded to the SCF and will be processed according to the value of api-auth for the first request.
{
"cache_time":10, // Verification result caching duration in seconds. Value range: 0–3600
"endpoint_timeout":15, // Backend timeout period in seconds. Value range: 0–60
"func_name":"test_name", // Custom SCF name
"func_namespace":"test_namespace", // Custom SCF namespace
"func_qualifier":"$LATEST", // Custom SCF version
"is_send_body":true, // Whether to send the request Body to the SCF
"header_auth_parameters":[ // Verification parameter in Header location. The plugin caches the verification result based on the parameter value
"Header1"
],
"query_auth_parameters":[ // Verification parameter in Query location. The plugin caches the verification result based on the parameter value
"Query1"
],
"user_id":1253970226, // appid
"version":"2021-12-26 17:17:49" // Plugin version in the format of `yyyy-MM-dd HH:mm:ss`. When you edit the plugin, the new value passed in will invalidate the result cached in the plugin
}
Was this page helpful?