Add conditional SQL configuration for MySQL support - #5668
Open
TobiasKWF wants to merge 1 commit into
Open
Conversation
Member
|
True, thx! |
mimugmail
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Important notices
Before you submit a pull request, we ask you kindly to acknowledge the following:
When Remote MySQL is enabled in the FreeRADIUS plugin, OPNsense correctly generates and initializes the sql1 module. The module successfully connects to the configured MySQL/MariaDB database and can also load RADIUS clients from the nas table when read_clients = yes.
However, sql1 is not called from the authorize section of the default virtual server. As a result, the configured remote SQL tables such as radcheck, radreply, radusergroup, radgroupcheck, and radgroupreply are not consulted during authentication and authorization.
This prevents use cases such as SQL-backed MAC authentication and dynamic VLAN assignment, even though the Remote MySQL connection itself is working.
Invoke sql1 in the default virtual server's authorize section when Remote MySQL is enabled.
The change adds:
{% if helpers.exists('OPNsense.freeradius.general.mysql') and OPNsense.freeradius.general.mysql == '1' %}
sql1
{% endif %}
This was tested with an existing Remote MySQL FreeRADIUS database. After adding sql1, FreeRADIUS successfully:
authenticated a user from radcheck
processed radreply
resolved membership through radusergroup
processed radgroupcheck and radgroupreply
returned dynamic VLAN attributes in the Access-Accept, including Tunnel-Type, Tunnel-Medium-Type, and Tunnel-Private-Group-Id
SQL-backed NAS clients via read_clients = yes continue to work as expected.
This pull request intentionally only addresses authorization. Remote MySQL accounting and post-auth integration are separate concerns.
Related issue
Related to #5196, which describes another area where Remote MySQL is configured but not fully integrated into the FreeRADIUS processing flow.
This PR specifically addresses Remote MySQL authorization and does not attempt to change accounting behavior.