Skip to content

Commit

Permalink
fix: fixed broken priv handling in Plus 24.11
Browse files Browse the repository at this point in the history
This corrects the handling of pfSense's getUserEntry return value. Starting in 24.11,
this returns the user entry nested under an 'item' key.
  • Loading branch information
jaredhendrickson13 committed Dec 6, 2024
1 parent 80b14c9 commit e2ae2e9
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ class Auth {
public function authorize(): bool {
# Variables
$is_not_authorized = false;
$this->client_privileges = get_user_privileges(getUserEntry($this->username));

# Start with pfSense 24.11, getUserEntry returns an array with the key 'item' containing the user data.
# We need to handle both cases to support both.
$user_ent = getUserEntry($this->username);
$user_ent = (array_key_exists('item', $user_ent)) ? $user_ent['item'] : $user_ent;

# Obtain the client's privileges and check if they have the required privileges
$this->client_privileges = get_user_privileges($user_ent);

# This client is not authorized if the client does not have at least one of the required privileges
if ($this->required_privileges and !array_intersect($this->required_privileges, $this->client_privileges)) {
Expand Down

0 comments on commit e2ae2e9

Please sign in to comment.