Skip to content

Commit 10ec3e3

Browse files
docs: enhance mkdocs pages
1 parent 62e24c6 commit 10ec3e3

10 files changed

Lines changed: 83 additions & 12 deletions

docs/BUILDING_CUSTOM_AUTH_CLASSES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Building Custom Authentication Classes
22

3+
!!! Danger
4+
This feature is intended for advanced use cases only. Incorrectly implemented custom authentication classes can lead to
5+
significant security vulnerabilities.
6+
37
For advanced users, the REST API's framework allows for custom authentication methods to be added using PHP. To add a custom
48
authentication method, extend the `\RESTAPI\Core\Auth` class and implement the `_authenticate` method. This method simply
59
needs to return a boolean value indicating if the user is authenticated or not. Below is an example of a custom Auth class:

docs/CONTENT_AND_ACCEPT_TYPES.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Content and Accept Types
2+
3+
The REST API has been designed to support multiple content and accept types to allow for flexibility in the data being sent and received. This document outlines the content and accept types supported by the REST API.
4+
5+
## Content Types
6+
7+
Content types are used to specify the format of the data being sent in your request. You must specify the content type in the `Content-Type` header of your request. The REST API supports the following content types:
8+
9+
### application/json
10+
- MIME Type: `application/json`
11+
- Description: Use this content type to send JSON data in the body of your request. The data should be formatted as a JSON object or array.
12+
- Example: ```{"key": "value"}```
13+
14+
### application/x-www-form-urlencoded
15+
- MIME Type: `application/x-www-form-urlencoded`
16+
- Description: Use this content type to send form data in the URL of the request. The data is sent as key-value pairs separated by an ampersand `&`.
17+
- Example: ```https://pfsense.example.com?key=value&key2=value2```
18+
19+
!!! Warning
20+
The `application/x-www-form-urlencoded` content-type is not fully suitable for requests other than `GET` and `DELETE` requests. It is recommended to use `application/json` for all other request types.
21+
22+
## Accept Types
23+
24+
Accept types are used to specify the format of the data you would like to receive in the response. You can specify the accept type in the `Accept` header of your request, or the response will default to `application/json`. The REST API supports the following accept types:
25+
26+
### application/json
27+
- MIME Type: `application/json`
28+
- Description: Use this accept type to receive JSON data in the response. The data will be formatted as a JSON object or array.
29+
- Example: ```{"key": "value"}```

docs/CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ The project utilizes PHP namespaces to organize its codebase.
3333

3434
Below is a brief overview of the project's structure:
3535

36-
Certainly! Here is the content separated into distinct sections:
37-
3836
### RESTAPI/
3937

4038
The main namespace for the REST API package. All classes and interfaces are organized under this namespace or a child

docs/DISPATCHERS_AND_CACHING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ to wait for the operation to complete. A list of all current Dispatcher classes
1414
[PHP reference](https://pfrest.org/php-docs/namespaces/restapi-dispatchers.html).
1515

1616
!!! Note
17-
You can bypass the Dispatcher spawning processes in the background by setting the ['async' control parameter](https://pfrest.org/COMMON_CONTROL_PARAMETERS/#async)
17+
You can bypass the Dispatcher process spawning in the background in your API calls by setting the ['async' control parameter](https://pfrest.org/COMMON_CONTROL_PARAMETERS/#async)
1818
to `false`. This will cause the Dispatcher to execute the operation within the main process and wait for the operation to
1919
complete before returning a response.
2020

docs/INSTALL_AND_CONFIG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Overall, the REST API package is designed to be as lightweight as possible and s
88
run pfSense. It's recommended to follow Netgate's [minimum hardware requirements](https://docs.netgate.com/pfsense/en/latest/hardware/minimum-requirements.html).
99

1010
!!! Warning
11-
While the package should behave identically on architectures other than amd64, it has only been tested on amd64
11+
While the package should behave identically on architectures other than amd64, automated testing only covers amd64
1212
builds of pfSense. Support on other architectures is not guaranteed.
1313

1414
### Supported pfSense versions
1515

16-
- pfSense CE 2.7.2 (amd64)
17-
- pfSense Plus 24.03 (amd64)
16+
- pfSense CE 2.7.2
17+
- pfSense Plus 24.03
1818

1919
!!! Tip
2020
Don't see your version of pfSense? Older versions of pfSense may be supported by older versions of this package.
@@ -36,11 +36,11 @@ pkg-static -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/re
3636

3737
!!! Important
3838
When updating pfSense, **you must reinstall this package afterward** as pfSense removes unofficial packages during
39-
system updates.
39+
system updates and has no way to automatically reinstall them.
4040

4141
## Configuring the package
4242

43-
The REST API is designed to be used out of the box. However, there are a number of configuration options available to
43+
The REST API is designed to be ready to use out of the box. However, there are a number of configuration options available to
4444
you to customize the API to your needs. The REST API settings can be configured in pfSense webConfigurator under
4545
'System' -> 'REST API' or via `PATCH` request to the [/api/v2/system/restapi/settings](https://pfrest.org/api-docs/#/SYSTEM/patchSystemRESTAPISettingsEndpoint)
4646
endpoint.

docs/LIMITATIONS_AND_FAQS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,36 @@ Keep the following limitations in mind when using this API:
66

77
- pfSense's XML configuration was not designed for large scale concurrency. It may be necessary to delay API calls to
88
prevent unexpected behavior, such as configuration overwrites.
9+
- While the REST API contains controls that should help improve scalability and resource management in comparison to
10+
the webConfigurator, it is still recommended to use the API with caution on large datasets.
911

1012
## Frequently Asked Questions
13+
14+
### Why is this package not an official pfSense package?
15+
16+
I'd love for it to be an official package! A few years back, Netgate opened a friendly dialogue about the
17+
possibility of making this package official. There was some back and forth about the direction of the package and pfSense
18+
itself. Since then, I have been working on addressing most of the items that were brought up during the discussions but
19+
it seems interest has waned on Netgate's side. I am still open to the idea of making this an official package and would
20+
still love to work with Netgate to make that happen.
21+
22+
For now, I will say there are still some benefits to this package being unofficial. It allows for more rapid development and
23+
more flexibility in the direction of the package. It also allows for more community involvement in the development of the
24+
package. It also ensures the package remains free and open-source.
25+
26+
### Why are the v1 and v2 APIs separate packages?
27+
28+
There are three primary reasons it was decided to create a new package for the v2 API:
29+
30+
1. **Backwards Compatibility**: It was realized early on that the v2 API would require a significant amount of changes to
31+
the underlying codebase. This would have made it difficult to maintain backwards compatibility with the v1 API with both
32+
codebases in one package. Instead, it was decided to create a new package for the v2 API to allow for a clean break from
33+
the v1 API and still allow both packages to be installed concurrently for users who still require v1.
34+
2. **Namespaces**: v1 notably lacked the use of namespaces for the underlying framework which led to a number of conflicts
35+
when trying to implement v2. v2 was designed from the ground up with namespaces in mind to prevent these conflicts and
36+
allow major revisions to be included in the same package going forward.
37+
3. **Accuracy**: The v1 codebase was a brute force attempt at creating an API for pfSense. Initially it was not
38+
designed to with RESTful principles. The v2 API was designed from the ground up with RESTful principles in mind and
39+
is a much more accurate representation of a RESTful API, therfor it was decided to create a new package to reflect this
40+
change while also differentiating it from Netgate's purported RESTCONF plans.
41+

docs/QUERIES_AND_FILTERS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ Queries can be used to filter the data that is returned from the API based on sp
66
query parameters in the URL and are formatted as `key=value`. Multiple queries can be passed in a single request by
77
separating them with an ampersand `&`.
88

9-
!!! Note
10-
Queries are only available for `GET` requests to [plural endpoints](./ENDPOINT_TYPES.md#plural-many-endpoints).
9+
!!! Important
10+
- Queries are only available for `GET` requests to [plural endpoints](./ENDPOINT_TYPES.md#plural-many-endpoints).
11+
- While it is not standard HTTP practice, the REST API will allow you to pass query parameters in the request body
12+
for `GET` requests as long as the correct Content-Type header is set. This may be useful when you need to force
13+
the type of a query parameter or when the query parameter is too long to fit in the URL.
1114

1215
## Query Filters
1316

docs/WORKING_WITH_HATEOAS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ easily navigate the API and discover available actions and resources related to
1414
endpoint's `hateoas` field.
1515
!!! Important
1616
Enabling HATEOAS can greatly increase the size of API responses as additional links are included in the response data;
17-
which may also impact performance on large datasets.
17+
which may also impact performance on large datasets. It is strongly recommended to only enable HATEOAS when needed and
18+
to use [pagination](./QUERIES_AND_FILTERS.md#pagination) to limit the amount of data returned in a single request.
1819

1920
### Link types
2021

docs/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pfSense REST API
22

3-
The pfSense REST API package is an unofficial, open-source REST API for pfSense CE and pfSense Plus firewalls. This package is
3+
The pfSense REST API package is an unofficial, open-source REST API for pfSense CE and pfSense Plus firewalls that is
44
designed to be light-weight, fast, and easy to use. This guide will help you get started with the REST API package and
55
provide you with the information you need to configure and use the package effectively.
66

@@ -10,6 +10,10 @@ provide you with the information you need to configure and use the package effec
1010
'System' -> 'REST API' -> 'Documentation'. Alternatively, a simplified version of the Swagger documentation is
1111
available [here](https://pfrest.org/api-docs/).
1212

13+
!!! Note
14+
These docs are only applicable to the REST API v2 package and later. If you are using the legacy v1 package, please
15+
refer to the docs on the [legacy branch](https://github.com/jaredhendrickson13/pfsense-api/tree/legacy).
16+
1317
## Key Features
1418

1519
- 100+ endpoints available for managing your firewall and associated services

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ nav:
66
- Swagger & OpenAPI: SWAGGER_AND_OPENAPI.md
77
- Endpoint Types: ENDPOINT_TYPES.md
88
- Authentication & Authorization: AUTHENTICATION_AND_AUTHORIZATION.md
9+
- Content & Accept Types: CONTENT_AND_ACCEPT_TYPES.md
910
- Queries & Filters: QUERIES_AND_FILTERS.md
1011
- Working with Object IDs: WORKING_WITH_OBJECT_IDS.md
1112
- Working with HATEOAS: WORKING_WITH_HATEOAS.md

0 commit comments

Comments
 (0)