Skip to content

Pyfsense Client is a Python API client for pfSense API endpoints provided by the package at https://github.com/jaredhendrickson13/pfsense-api.

License

Notifications You must be signed in to change notification settings

devinbarry/pyfsense-client

Repository files navigation

PythonSupport License: GPL v3

Pyfsense Client

Pyfsense Client is a Python API client for pfSense API endpoints provided by the package at https://github.com/jaredhendrickson13/pfsense-api.

This repository is a rewrite of the code at https://github.com/yaleman/pfsense-api-client.

This code is currently being tested against pfSense 24.03 and the v1.7.6 API endpoints.

Project Status

Project is under development and likely will not have working methods for all endpoints.

All the integration tests copied from yaleman don't work, and many endpoints that I don't personally use have not been tested. Writing mocked tests for all the endpoints is a large task and is unlikely to be finished considering the API has been recently upgraded to version 2. It makes more sense to transition this project to using version 2 endpoints and write tests for those instead.

Configuring authentication

Technically this library supports all authentication methods, but we are only testing with API token.

config_data = {
    "hostname": "example.com",
    "mode": "api_token",
    "client_id": "3490580384",
    "client_token": "3495739084",
    "verify_ssl": False,
}

config = ClientConfig(**config_data)
client = PFSenseAPIClient(config=config)

Support exists for passing credentials as a JSON file.

{
    "username" : "me",
    "password" : "mysupersecretpassword",
    "hostname" : "example.com",
    "port" : 8443
}

Ignoring Certificate validation

Pass verify_ssl=False into the config to disable SSL checking.

Development

You can build a docker image of the source code using docker compose. This will install all the dependencies from the requirements file and volume mount the code for development.

docker compose -f local.yml build

You can run the unit tests with:

docker compose -f local.yml up

About

Pyfsense Client is a Python API client for pfSense API endpoints provided by the package at https://github.com/jaredhendrickson13/pfsense-api.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •