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

[feature] Added auth and ip assignment for ZeroTier member #799

Merged
merged 108 commits into from Sep 26, 2023

Conversation

Additionally, basic support has been added for managing
ZeroTier networks through OpenWISP using the ZeroTier Service API

Closes #604
- Removed Zerotier read-only fields from the schema and utilized
only the 'network_id' as the system-defined variable for the Zerotier network.
- Fixed the issue of unwanted execution of "unsaved-changes.js" caused by
the different order of configuration received from the API and the configuration defined in the VPN backend.
- Enabled OpenWISP to control IP assignment using the subnet and IP fields of the VPN model.
- Moved API requests for delete and update operations for Zerotier
to background celery tasks, while the create operation remains synchronous.
- Implemented basic error handling for Zerotier service API calls
(further improvements will be made in the next review).
- Updated existing migrations to include updated help text.
- Fixed JS to hide unnecessary fields.
#778 (comment)

- Handled the scenario where an invalid hostname is provided in the ZeroTier /status call.
- Improved user experience by overriding the clean() method, which now reports that
the auth_token field is required when the user selects the ZeroTier VPN backend.
- Moved the logic from the _update_zerotier_server() method to the
update_vpn_server_configuration method for better code organization.
- Removed redundant conditional checks and unnecessary
log statement from the _update_zerotier_server method.
- Improved ZerotierService methods.
- Improved host and auth_token field validation.
- Added OpenwispApiTask for retry mechanism.
- Added a new notification type for background API tasks.
- This notification type will be used in the zerotier backend to
notify users about various events related to background API calls.
- Currently, the new notification is used in the following scenarios:
    - Creating a new zerotier network.
    - Updating an existing zerotier network.
    - Modifying network member configurations
      such as authorization and IP assignments.
**ZerotierService class**
- Added a timeout of '5' seconds to API request methods.

**OpenwispApiTask class**
- Changed the log level to `logger.warn` when the retry limit is not reached,
  and `logger.error` only when the retry limit is reached.
- Modified the logic to send a recovery notification only when the API task
  encountered an error before. Otherwise, no recovery notification is generated.
- Updated the cache key as suggested in the review.
- Added a docstring and comments for the `handle_api_call` method.

**vpn.py**
- Disabled email notifications for background API tasks.
- Utilized guard clause in the `_validate_host` method.
- Moved Zerotier VPN `auth_token` validation back to `models.py`.
- Simplified the subnet and IP values for Zerotier API tasks.
- Updated translation string messages and used the `.format` method instead of f-strings.
For more information, see: https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#standard-translation
- Added TestZeroTier and TestZeroTierTransaction
- Updated `_invalidate_peer_cache` method of the
Vpn model to emit `vpn_peers_changed` signal
for only for Wireguard or VXLAN VPN backends
…calls

- Ensure that recovery notifications are triggered only when the VPN server
  has previously encountered an unrecoverable error (error notification)
- Added a test case for zerotier vpn deletion 404
@Aryamanz29 Aryamanz29 self-assigned this Jul 28, 2023
@Aryamanz29 Aryamanz29 added this to In progress 🔄 in [GSoC 23] ZeroTier 🔅 via automation Jul 28, 2023
@Aryamanz29 Aryamanz29 force-pushed the issue-606/zerotier-member-auth-ip-assign branch 3 times, most recently from 3e75438 to 7b02aff Compare July 28, 2023 14:55
…pn server

- (req-changes) Moved time import at the top of the file.
- Subnet should be type cast after ip assignment evaluation.
- Updated zt vpn deletion tests.
@Aryamanz29 Aryamanz29 force-pushed the issue-604/add-zerotier-vpn-backend branch from 590a3ef to 83bd932 Compare July 30, 2023 20:24
- Fixed test vpn deletion notification mock.
- Deleted ZT API tasks notification cache keys after vpn deletion.
@Aryamanz29 Aryamanz29 force-pushed the issue-604/add-zerotier-vpn-backend branch from 83bd932 to 016248f Compare July 30, 2023 21:39
@Aryamanz29 Aryamanz29 force-pushed the issue-606/zerotier-member-auth-ip-assign branch 4 times, most recently from b037b39 to ca5431a Compare July 31, 2023 12:55
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress, please see my comments below.

openwisp_controller/config/base/vpn.py Outdated Show resolved Hide resolved
openwisp_controller/config/tests/test_vpn.py Show resolved Hide resolved
openwisp_controller/config/tests/test_vpn.py Show resolved Hide resolved
openwisp_controller/config/tests/test_vpn.py Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Aug 21, 2023

Coverage Status

coverage: 99.006% (+0.01%) from 98.992% when pulling a5b41ed on issue-606/zerotier-member-auth-ip-assign into 3512977 on gsoc23.

- Also included enabled bridge option for member auth ip assignment API call.
openwisp_controller/config/base/vpn.py Outdated Show resolved Hide resolved
openwisp_controller/config/base/vpn.py Show resolved Hide resolved
openwisp_controller/config/base/vpn.py Outdated Show resolved Hide resolved
Aryamanz29 added a commit to openwisp/netjsonconfig that referenced this pull request Sep 10, 2023
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @pandafy please confirm.

@pandafy
Copy link
Member

pandafy commented Sep 26, 2023

LGTM! 👍🏼

@nemesifier nemesifier merged commit f11d561 into gsoc23 Sep 26, 2023
9 checks passed
[GSoC 23] ZeroTier 🔅 automation moved this from Ready for review ✅ to Done 🔥 Sep 26, 2023
@nemesifier nemesifier deleted the issue-606/zerotier-member-auth-ip-assign branch September 26, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants