Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.5.0 Fixes & Features #243

Merged
merged 78 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f9accd2
Added OpenVPN server and client endpoints
Dec 15, 2021
2dc13b8
Local database auth revert
pincher95 Dec 15, 2021
e686a7e
Merge pull request #1 from jaredhendrickson13/master
pincher95 Dec 21, 2021
c702a91
Merge branch 'jaredhendrickson13:master' into master
pincher95 Feb 25, 2022
f6b513f
Merge branch 'jaredhendrickson13:master' into master
pincher95 Mar 22, 2022
1b6b8dc
Added OpenVPN server and client endpoints
Dec 15, 2021
c3fb6f5
conflicts resolved
pincher95 Apr 30, 2022
001a4b8
Merge branch 'jaredhendrickson13:master' into master
pincher95 May 6, 2022
e67594a
Fix validate interface for firewall rule creation to support interfac…
dihedral Jun 3, 2022
cedc045
Updated maintainer emails.
jaredhendrickson13 Jun 6, 2022
e778f15
Merge branch 'jaredhendrickson13:master' into master
pincher95 Jun 7, 2022
573275c
Add OpenVPN Server endpoint
pincher95 May 8, 2022
2e25185
support interface groups for firewall rules at the heart of APITools\…
dihedral Jun 8, 2022
22e27ca
support interface groups for firewall rules at the heart of APITools\…
dihedral Jun 8, 2022
95971c5
add support for managing interface groups
dihedral Jun 8, 2022
a1905b9
add documentation for managing interface groups
dihedral Jun 8, 2022
ffb9f8e
Merge pull request #242 from dihedral/master
jaredhendrickson13 Jun 11, 2022
0bcfb47
Merge branch 'master' of github.com:jaredhendrickson13/pfsense-api in…
jaredhendrickson13 Jun 11, 2022
f5ee7d0
Merge branch 'master' into v150
jaredhendrickson13 Jun 30, 2022
dcd8662
Allow /api/v1/firewall/rule to acknowledge enc0 interface.
jaredhendrickson13 Jun 30, 2022
738da41
Merge branch 'master' into v150
jaredhendrickson13 Jul 1, 2022
63823f3
Removed under development OpenVPN Client endpoint
pincher95 May 8, 2022
16048b0
Added initail OpenVPN Client endpoint
pincher95 May 11, 2022
39e0f4c
Added OpenVPN client CREATE endpoint, refactor responses, Updated Ope…
pincher95 May 11, 2022
18daaab
Removed duplicated configurations, code optimization
pincher95 May 14, 2022
13105e9
Removed under development OpenVPN Client endpoint
pincher95 May 14, 2022
6c90949
BugFix OpenVPN server engine detection
pincher95 May 22, 2022
375f63c
Refactor OpenVPN Server interface lookup
pincher95 May 23, 2022
d9e595c
Conflict resolution
pincher95 May 26, 2022
ec8d492
Conflict resolution
pincher95 May 26, 2022
ffd588c
update response errorcodes
pincher95 Jul 16, 2022
9d50496
openapi.yml conflict resolved
pincher95 Jul 16, 2022
ba522bc
openapi.yml conflict v150 resolved
pincher95 Jul 16, 2022
5797ebe
Merge branch 'v150' into openvpn_prototype
pincher95 Jul 16, 2022
e91bf00
Merge branch 'master' into v150
jaredhendrickson13 Jul 16, 2022
0ba65ec
Merge pull request #228 from pincher95/openvpn_prototype
jaredhendrickson13 Jul 16, 2022
f87e71a
test: removed test for no server certificate found for test_api_v1_se…
jaredhendrickson13 Jul 16, 2022
e140a23
test: readding test from f87e71aafe15c45b3ad81114fa8d5ade8b385478 but…
jaredhendrickson13 Jul 16, 2022
7596ac7
Add OpenVPN Client endpoint
pincher95 Jul 17, 2022
11ac5aa
Merge branch 'master' into v150
jaredhendrickson13 Jul 18, 2022
f7ba7b6
Merge pull request #262 from pincher95/openvpn_client_prototype
jaredhendrickson13 Jul 18, 2022
183cc82
test: refactored test_api_v1_services_openvpn_client.py to support bu…
jaredhendrickson13 Jul 18, 2022
6fe5ae8
ci: adding pylint workflow for tools/tests lint
jaredhendrickson13 Aug 16, 2022
6d2ff3f
ci: ensure pylint gets installed before linting
jaredhendrickson13 Aug 16, 2022
6c5371d
ci: sampling phplinter action
jaredhendrickson13 Aug 16, 2022
03519a2
ci: lint using php 7.2 and 7.4
jaredhendrickson13 Aug 16, 2022
9f2d8f6
ci: adding workflow for php linting
jaredhendrickson13 Aug 16, 2022
087208d
Install dependencies via composer (#264)
jaredhendrickson13 Aug 17, 2022
fcd8ef9
chore(tools): force ntp sync before composer installs
jaredhendrickson13 Aug 17, 2022
63eedb9
chore(tools): fail package build on failed cmd
jaredhendrickson13 Aug 17, 2022
dcf4784
ci: adding dependabot for composer deps
jaredhendrickson13 Aug 17, 2022
6221e41
ci: add pip deps to dependabot
jaredhendrickson13 Aug 17, 2022
5885040
feat: OpenAPI Linting & IPsec Status endpoint (#265)
jaredhendrickson13 Aug 17, 2022
5a27436
feat: logging settings (#266)
jaredhendrickson13 Aug 19, 2022
57b908f
Advanced alias endpoint (#267)
jaredhendrickson13 Aug 22, 2022
a38dc68
feat: add IPsec tunnel endpoints (#271)
jaredhendrickson13 Sep 1, 2022
5578989
feat: tcpflags, quick, state type in rules (#272)
jaredhendrickson13 Sep 3, 2022
535d442
feat: Service Watchdog endpoint (#273)
jaredhendrickson13 Sep 5, 2022
a849a7c
feat: added ipsec apply endpoint
jaredhendrickson13 Sep 22, 2022
7eb97a4
feat: allow ipsec initiation
jaredhendrickson13 Sep 23, 2022
41f1934
docs: added documentation for initiate field
jaredhendrickson13 Sep 23, 2022
79c7947
fix: version lock ipsec initiate
jaredhendrickson13 Oct 1, 2022
1793602
test: add test for ipsec apply
jaredhendrickson13 Oct 1, 2022
a51f916
feat: add update_available field
jaredhendrickson13 Oct 1, 2022
b1f36a5
fix: fixed the all pkg parameter
jaredhendrickson13 Oct 1, 2022
8edd42e
feat: add async field to /api/v1/firewall/apply
jaredhendrickson13 Oct 2, 2022
8fc884c
test: added test for jwt auth
jaredhendrickson13 Oct 2, 2022
b8f687c
fix: correctly typos in test framework
jaredhendrickson13 Oct 2, 2022
f02f368
fix: addressed lint issue in jwt test
jaredhendrickson13 Oct 2, 2022
ede85ca
fix: initialize jwt server key
jaredhendrickson13 Oct 2, 2022
1b8c7f3
docs: fixed typo in log settings endpoint docs
jaredhendrickson13 Oct 4, 2022
e33d64c
fix: init service watchdog config first
jaredhendrickson13 Oct 4, 2022
a3425c0
feat: implement login protection (#282)
jaredhendrickson13 Oct 7, 2022
5958fb2
feat: API token enhancements (#283, #281)
jaredhendrickson13 Oct 8, 2022
3ceb3b4
feat: read available pfsense upgrades (#284)
jaredhendrickson13 Oct 8, 2022
d1ff2fc
docs: clarify ipsec 'initiate' field reqs
jaredhendrickson13 Oct 9, 2022
f9ca81e
fix: add missing installed_version to pkg read
jaredhendrickson13 Oct 9, 2022
7b317ea
deps(composer): adding composer.lock
jaredhendrickson13 Oct 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
12 changes: 12 additions & 0 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: OpenAPI
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint OpenAPI spec
uses: vaibhav-jain/spectral-action/@v2.6
with:
file_path: pfSense-pkg-API/files/usr/local/www/api/documentation/openapi.yml
18 changes: 18 additions & 0 deletions .github/workflows/phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PHPlint
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint on PHP 7.2
uses: firehed/lint-php-action@v1
with:
file-extensions: 'php, inc'
php-version: "7.2"
- name: Lint on PHP 7.4
uses: firehed/lint-php-action@v1
with:
file-extensions: 'php, inc'
php-version: "7.4"
23 changes: 23 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pylint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ tests/e2e_test_framework/__pycache__/
*.DS_Store
.phplint-cache
*.pyc
venv/
vendor/
7 changes: 7 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[DEFAULT]
# Tests require duplicate code and may contain many test cases that require many lines of code
disable=duplicate-code,too-many-lines

[FORMAT]
# Follow normal pep8 restriction
max-line-length=120
1 change: 1 addition & 0 deletions .spectral.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: ["spectral:oas", "spectral:asyncapi"]
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
# pfSense-API

[![OpenAPI](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/openapi.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/openapi.yml)
[![PHPlint](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/phplint.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/phplint.yml)
[![Pylint](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/pylint.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/pylint.yml)

# Introduction

Expand Down Expand Up @@ -136,12 +140,14 @@ curl -H "Authorization: Bearer xxxxx.xxxxxx.xxxxxx" -X GET https://pfsense.examp
<details>
<summary>API Token</summary>

Uses standalone tokens generated via the webConfigurator. These are better suited to distribute to systems as they are
Uses standalone tokens generated via API or webConfigurator. These are better suited to distribute to systems as they are
revocable and will only allow API authentication; not webConfigurator or SSH authentication (like the local database
credentials). To generate or revoke credentials, navigate to System > API within the webConfigurator and ensure the
Authentication Mode is set to API token. Then you should have the options to configure API Token generation, generate
new tokens, and revoke existing tokens. After generating a new API token, the actual token will display at the top of
the page on the success banner. This token will only be displayed once so ensure it is stored somewhere safe.<br><br>
the page on the success banner. This token will only be displayed once so ensure it is stored somewhere safe.
Alternatively, you can generate new API tokens using the /api/v1/access_token endpoint. This endpoint will always
require the use of the Local Database authentication type to receive the API token.<br><br>

Once you have your API token, you may authenticate your API call by specifying your client-id and client-token within
an `Authorization` header, these values must be separated by a space. For example:<br>
Expand All @@ -159,6 +165,14 @@ functionality is still supported but is not recommended. It will be removed in a
pfSense API uses the same privileges as the pfSense webConfigurator. The required privileges for each endpoint are
stated within the API documentation.

### Login Protection

By default, all API requests will be monitored by pfSense's Login Protection feature. This will allow API
authentication attempts to be logged and temporarily blocked if too many failed authentication attempts are made by
any one client. It is strongly recommended that this feature be used at all times to prevent brute force attacks on
API endpoints. This feature can be disabled by within the webConfigurator system-wide under System > Advanced or
only for API requests under System > API.

# Content Types

pfSense API can handle a few different content types. Please note, if a `Content-Type` header is not specified in your
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"firebase/php-jwt": "v6.3.*"
}
}
81 changes: 81 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
// Copyright 2022 Jared Hendrickson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require_once("api/framework/APIEndpoint.inc");

class APIFirewallAliasAdvanced extends APIEndpoint {
public function __construct() {
$this->url = "/api/v1/firewall/alias/advanced";
}

protected function get() {
return (new APIFirewallAliasAdvancedRead())->call();
}

protected function put() {
return (new APIFirewallAliasAdvancedUpdate())->call();
}
}
38 changes: 38 additions & 0 deletions pfSense-pkg-API/files/etc/inc/api/endpoints/APIInterfaceGroup.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
// Copyright 2022 Jared Hendrickson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require_once("api/framework/APIEndpoint.inc");

class APIInterfaceGroup extends APIEndpoint {
public function __construct() {
$this->url = "/api/v1/interface/group";
}

protected function get() {
return (new APIInterfaceGroupRead())->call();
}

protected function post() {
return (new APIInterfaceGroupCreate())->call();
}

protected function put() {
return (new APIInterfaceGroupUpdate())->call();
}

protected function delete() {
return (new APIInterfaceGroupDelete())->call();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
// Copyright 2022 Jared Hendrickson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require_once("api/framework/APIEndpoint.inc");

class APIServicesIPsecApply extends APIEndpoint {
public function __construct() {
$this->url = "/api/v1/services/ipsec/apply";
}

protected function post() {
return (new APIServicesIPsecApplyCreate())->call();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
// Copyright 2022 Jared Hendrickson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require_once("api/framework/APIEndpoint.inc");

class APIServicesIPsecPhase1 extends APIEndpoint {
public function __construct() {
$this->url = "/api/v1/services/ipsec/phase1";
}

protected function get() {
return (new APIServicesIPsecPhase1Read())->call();
}

protected function post() {
return (new APIServicesIPsecPhase1Create())->call();
}

protected function put() {
return (new APIServicesIPsecPhase1Update())->call();
}

protected function delete() {
return (new APIServicesIPsecPhase1Delete())->call();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
// Copyright 2022 Jared Hendrickson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

require_once("api/framework/APIEndpoint.inc");

class APIServicesIPsecPhase1Encryption extends APIEndpoint {
public function __construct() {
$this->url = "/api/v1/services/ipsec/phase1/encryption";
}

protected function post() {
return (new APIServicesIPsecPhase1EncryptionCreate())->call();
}
}
Loading