DEV Community

Carrie
Carrie

Posted on

Open API Usage Tutorial for Open Source WAF SafeLine

The new version of SafeLine WAF supports API Token authentication.

Usage Requirements

  • You must log in using the default admin user to see this feature.
  • The version must be >= 6.6.0.

How to Use

  • Create an API TOKEN in System Management

Image description

  • Make a Request Add an extra parameter in the request header as follows:
"X-SLCE-API-TOKEN": "API Token generated by SafeLine management terminal"
Enter fullscreen mode Exit fullscreen mode

Example Reference

Python Example for Adding a Site Using API Token

import requests
import json

header = {
    "X-SLCE-API-TOKEN": "API Token generated by the Thunder Pool management terminal"
}

# URL for adding a site
url = 'https://ThunderPoolIP:9443/api/open/site'

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

payload = json.dumps(payload)
requests.post(url=url, headers=header, data=payload, verify=False)
Enter fullscreen mode Exit fullscreen mode

Other API Interfaces

  • Get the System Version
https://10.10.10.18:9443/api/open/system
Enter fullscreen mode Exit fullscreen mode
  • Get Daily Access Statistics
https://10.10.10.18:9443/api/dashboard/requests
Enter fullscreen mode Exit fullscreen mode
  • Get Attack Detection Information
https://10.10.10.18:9443/api/open/events?page=1&page_size=20
Enter fullscreen mode Exit fullscreen mode
  • Get Blocking Information
https://115.238.109.74:9443/api/open/records/acl?page=1&page_size=20
Enter fullscreen mode Exit fullscreen mode
  • Get Real-time QPS (Queries Per Second)
https://10.10.10.18:9443/api/stat/qps
Enter fullscreen mode Exit fullscreen mode
  • Get Access Statistics for Each Province
https://10.10.10.18:9443/api/dashboard/map/counts
Enter fullscreen mode Exit fullscreen mode
  • Daily Interception Statistics
https://10.10.10.18:9443/api/dashboard/intercepts
Enter fullscreen mode Exit fullscreen mode
  • Same-day Interception Statistics
https://10.10.10.18:9443/api/stat/basic/access
Enter fullscreen mode Exit fullscreen mode
  • Webpage 4xx and 5xx Statistics
https://10.10.10.18:9443/api/dashboard/counts
Enter fullscreen mode Exit fullscreen mode
  • Human Verification Access Statistics
https://10.10.10.18:9443/api/open/records/challenge?page=1&page_size=20
Enter fullscreen mode Exit fullscreen mode
  • Authentication Access Statistics
https://10.10.10.18:9443/api/open/records/auth_defense?page=1&page_size=20
Enter fullscreen mode Exit fullscreen mode
  • Rate Limiting
https://10.10.10.18:9443/api/open/global/acl
Enter fullscreen mode Exit fullscreen mode
  • Custom Rules
https://10.10.10.18:9443/api/open/policy?page=1&page_size=20&action=-1
Enter fullscreen mode Exit fullscreen mode
  • Protection Modules
https://10.10.10.18:9443/api/open/global/mode
Enter fullscreen mode Exit fullscreen mode
  • Enhanced Rules
https://10.10.10.18:9443/api/open/skynet/rule
Enter fullscreen mode Exit fullscreen mode
  • General Configuration
https://10.10.10.18:9443/api/open/ipgroup?top=20
Enter fullscreen mode Exit fullscreen mode
  • System Settings
https://10.10.10.18:9443/api/open/users
Enter fullscreen mode Exit fullscreen mode

Top comments (0)