Creating a Custom Authorizer
Scenario
API Gateway supports custom authentication of both frontend and backend requests.
- Frontend custom authentication: If you already have an authentication system, you can configure it in a function and then create a custom authorizer by using the function to authenticate API requests.
- Backend custom authentication: You can create a custom authorizer to authenticate requests for different backend services, eliminating the need to customize APIs for different authentication systems and simplifying API development. You only need to create a function-based custom authorizer in API Gateway to connect to the backend authentication system.
Custom authentication is implemented using FunctionGraph and not supported if FunctionGraph is unavailable in the selected region.
For details about custom authentication, see Developer Guide.
The following figure shows the process of calling APIs through custom authentication.
Prerequisites
You have created a function in FunctionGraph.
Procedure
- Log in to the management console.
- Click in the upper left corner and choose API Gateway.
- Choose API Publishing > Custom Authorizers, and click Create Custom Authorizer.
- Set the parameters listed in Table 1.
Table 1 Parameters for creating a custom authorizer Parameter
Description
Name
Authorizer name.
Type
- Frontend: Authenticates access to APIs.
- Backend: Authenticates access to backend services.
Function URN
Select a FunctionGraph function.
Identity Sources
Request parameters used for authentication.
This parameter is mandatory only if you set Type to Frontend, and Max. Cache Age (s) is greater than 0. When the cache is used, this parameter is used as a search criterion to query authentication results.
Max. Cache Age (s)
The time for caching authentication results.
Value 0 means that authentication results will not be cached. The maximum value is 3600.
User Data
Customized request parameters to be used together with Identity Sources when API Gateway invokes a function.
- Click OK.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot