Frank
Frank

Reputation: 298

How to set up an endpoint security using wso2 api manager rest apis (NOT Publisher web portal)

I am using wso2 apim 4.0.0. I would like to create and publish an api. According to the documentation, besides publisher web portal, one can do this by using rest api. I think, to fulfill this task followings should be done:

  1. Create the api by using https://{apimhost}/api/am/publisher/v2/apis
  2. Create a revision for the api using https://{apimhost}/api/am/publisher/v2/apis/{apiId}/revisions
  3. Deploy the revision using https://{apimhost}/api/am/publisher/v2/apis/{apiId}/deploy-revision
  4. Publish the api using https://{apimhost}/api/am/publisher/v2/apis/change-lifecycle

There might be situations where endpoints are secured. Let's say it is secured with basic auth. One can easily set this up on publisher web portal using endpoint security configurations as depicted below:

Endpoint security configuration

The question is how I can set up security parameters endpoints using publisher(or another) rest api? Is there any api to specify security parameters for endpoints?

Upvotes: 0

Views: 281

Answers (1)

Athiththan
Athiththan

Reputation: 2218

Adding Endpoint Security configurations can be achieved via the WSO2 API Manager Publisher REST API by introducing the endpoint_security block to the API creation request body as defined below

...
"endpointConfig": {
    "endpoint_type": "http",
    "sandbox_endpoints": {
        "url": "http://backendurl"
    },
    "production_endpoints": {
        "url": "http://backendurl"
    },
    "endpoint_security": {
        "sandbox": {
            "password": null,
            "tokenUrl": null,
            "clientId": null,
            "clientSecret": null,
            "customParameters": {},
            "type": null,
            "grantType": null,
            "enabled": false,
            "username": null
        },
        "production": {
            "password": null,
            "tokenUrl": "http://tokenendpoint",
            "clientId": "clientID",
            "clientSecret": "clientSecret",
            "customParameters": {},
            "type": "OAUTH",
            "grantType": "CLIENT_CREDENTIALS",
            "enabled": true,
            "username": null
        }
    }
},
...

Upvotes: 4

Related Questions