Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Implementation Procedure

Updated on 2025-01-16 GMT+08:00

Prerequisites

  1. A custom authentication function has been created. For details, see Creating a Function. The function's return value must have a context field with key-value pairs, where the values are limited to string, boolean, or integer. The key-value pair corresponds to the Parameter Name and Condition Value of the System parameter - Frontend authentication parameter configured in Policy Conditions.
    Figure 1 Custom authentication function
  2. A custom frontend authorizer has been created. If no custom authorizer is available, create one by following the instructions in Custom Authorizer.

Configuring the API Frontend

  1. Log in to the APIG console.
  2. Select a gateway at the top of the navigation pane.
  3. In the navigation pane, choose API Management > APIs.
  4. Click Create API > Create API and configure the frontend.

    Table 1 Frontend configuration

    Parameter

    Description

    API Name

    Enter an API name.

    Group

    Group to which the API belongs. The default value is DEFAULT.

    URL

    • Method: Request method of the API. Default: GET.
    • Protocol: Request protocol of the API. Default: HTTPS.
    • Subdomain Name: The system automatically allocates a subdomain name to each API group for internal testing. The subdomain name can be accessed 1,000 times a day.
    • Path: Path for requesting the API. In this example, enter /1234.

    Gateway Response

    Select a response to be displayed if the gateway fails to process an API request.

    The default gateway response is default.

    Authentication Mode

    API authentication mode. Select Custom.

    Custom Authorizer

    Select the custom authorizer created in Prerequisites.

Configuring the API Backend

  1. After configuring the frontend, click Next.

    Set Backend Type to Mock and enter Default backend in the Response.

  2. Click to add a backend policy based on the following table.

    Table 2 Policy backend configuration

    Parameter

    Description

    Name

    Enter a policy name.

    Backend Type

    Select Mock.

    Response

    Enter Policy backend.

    Policy Conditions

    • Source: Select System parameter - Frontend authentication parameter.
    • Parameter Name: Enter authstatus1 under the context field in the response body of the custom authentication function created in Prerequisites.
    • Condition Type: Select Equal.
    • Condition Value: Enter False under the context field in the response body of the custom authentication function created in Prerequisites.

  3. Click Finish.

Debugging the API

The Mock backend type helps you view the result with a response. For other backend types, you can check whether the backend address is successfully accessed.

  1. On the APIs page, click Debug to debug the created API.

    If 200 OK is displayed in Response, the API is successfully invoked. If the Policy backend is also returned, the configured policy backend condition matches the key-value pair in the context field in the response body of the custom authentication function, and the API invokes the policy backend. Otherwise, rectify the fault by following the instructions provided in Error Codes.

  2. On the APIs page, click Modify. The API configuration page is displayed.
  3. Click Next. On the backend configuration page, change Condition Value of the added policy to True.
  4. Click Finish.
  5. Debug the API again.

    The policy backend parameter and condition value do not match any key-value pair of the frontend custom authentication function. Therefore, the API policy backend cannot be matched based on the frontend authentication parameters. In this case, 200 OK is displayed with the return result of Default backend, indicating that the default backend of the API is invoked. Otherwise, rectify the fault by following the instructions provided in Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback