DEV Community

Carrie
Carrie

Posted on

OpenAPI Tutorial for SafeLine WAF

SafeLine WAF supports API Token-based authentication.

Note: API documentation is not provided, but you can get it by yourself if needed.

Requirements

  • You must be logged in as the default admin user to access this feature.
  • Version must be >= 6.6.0.

Usage Instructions

  1. Create an API Token in the System Management section.

  1. Send a Request: Include the following additional parameter in the request header:
   "X-SLCE-API-TOKEN": "API Token generated in SafeLine"

### Example

Below is a Python example of using an API Token to add a site.

Enter fullscreen mode Exit fullscreen mode

import requests
import json

header = {
"X-SLCE-API-TOKEN": "Your API Token generated in SafeLine""
}

url = 'https://IP:9443/api/open/site'

request_playload = {
"ports":["80"],"server_names":["*"],
"upstreams":["http://127.0.0.1:9443"],"comment":"",
"load_balance":{"balance_type":1}
}

request_playload = json.dumps(request_playload)
requests.post(url=url,headers=header,data=request_playload,verify=False)


Enter fullscreen mode Exit fullscreen mode

Top comments (0)