feat(resource_wlan): Add support for Private Pre-Shared Keys (PPSK) #520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces support for configuring Private Pre-Shared Keys (PPSK) on the
unifi_wlanresource. This allows users to define multiple passphrases for a single SSID, with each passphrase potentially assigning clients to a different VLAN/network.Motivation and Context
PPSK is a valuable Unifi Network Application feature for enhancing network segmentation without proliferating SSIDs. It allows, for example, IoT devices, guest users, and trusted internal users to connect to the same SSID but be isolated on different network segments based on the passphrase they use. This functionality was previously unavailable for management via this Terraform provider.
Implementation Details
The implementation is based on investigation of the Unifi Controller API (tested on version
9.1.120. The key API elements utilized for theunifi_wlanresource are:private_preshared_keys_enabledon the WLAN object.private_preshared_keys, where each entry contains:networkconf_id: The_idof theunifi_networkfor VLAN assignment.password: The passphrase for that specific entry.The
unifi_wlanresource schema has been updated with two new optional attributes:private_preshared_keys_enabled(Boolean): Enables PPSK mode for the WLAN. Defaults tofalse.private_preshared_key(Block List/Set): A list of blocks, each defining a private pre-shared key. Each block contains:password(String, Required, Sensitive): The actual passphrase.network_id(String, Required): The ID of an existingunifi_networkresource to associate with this passphrase.When
private_preshared_keys_enabledis set totrue, the top-levelx_passwordattribute for the WLAN is not used and should not be configured, as observed in Unifi UI behavior where the primary PSK is effectively managed within the PPSK list. The provider will ensure these are mutually exclusive or thatx_passwordis ignored when PPSK is active.This PR also includes an upgrade of the
go-unifilibrary tov1.34.0and necessary adaptations inresource_network.goandresource_port_profile.goto align with changes in the updated library.How to Test
Ensure you have a Unifi site and at least two
unifi_networkresources defined (e.g., for VLAN 10 and VLAN 20).Configure a
unifi_wlanresource using the new PPSK attributes:Run terraform apply.
Verify in the Unifi Network Application UI that the SSID ("MyPPSK-SSID") is created with "Multiple Passphrases" / PPSK enabled and the specified keys are present and correctly mapped to their respective networks (VLANs).
Test by connecting different client devices to "MyPPSK-SSID" using the different passphrases. Verify that clients receive IP addresses from the correct VLAN subnets and that network traffic is tagged appropriately.