Skip to content

Commit

Permalink
Fixes network filter for firewall sso and log less verbose when you have
Browse files Browse the repository at this point in the history
hundred of firewalls.
  • Loading branch information
fdurand committed Apr 25, 2024
1 parent 36dcc5b commit 7a020d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions go/firewallsso/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func ExecuteStart(ctx context.Context, fw FirewallSSOInt, info map[string]string
if !fw.CheckStatus(ctx, info) {
return false, nil
}
log.LoggerWContext(ctx).Info("Processing SSO Start")

if !fw.MatchesRole(ctx, info) {
log.LoggerWContext(ctx).Debug(fmt.Sprintf("Not sending SSO for user device %s since it doesn't match the role", info["role"]))
return false, nil
Expand All @@ -273,7 +273,7 @@ func ExecuteStart(ctx context.Context, fw FirewallSSOInt, info map[string]string
log.LoggerWContext(ctx).Debug(fmt.Sprintf("Not sending SSO for IP %s since it doesn't match any configured network", info["ip"]))
return false, nil
}

log.LoggerWContext(ctx).Info("Processing SSO Start")
// We change the username with the way it is expected given the format of this firewall
info["username"] = fw.FormatUsername(ctx, info)

Expand All @@ -291,13 +291,12 @@ func ExecuteStart(ctx context.Context, fw FirewallSSOInt, info map[string]string
// Makes sure to call FirewallSSO.Start and to validate the network if necessary
func ExecuteStop(ctx context.Context, fw FirewallSSOInt, info map[string]string) (bool, error) {
ctx = log.AddToLogContext(ctx, "firewall-id", fw.GetFirewallSSO(ctx).PfconfigHashNS)
log.LoggerWContext(ctx).Info("Processing SSO Stop")

if !fw.MatchesNetwork(ctx, info) {
log.LoggerWContext(ctx).Debug(fmt.Sprintf("Not sending SSO for IP %s since it doesn't match any configured network", info["ip"]))
return false, nil
}

log.LoggerWContext(ctx).Info("Processing SSO Stop")
// We change the username with the way it is expected given the format of this firewall
info["username"] = fw.FormatUsername(ctx, info)

Expand Down
3 changes: 1 addition & 2 deletions lib/pfconfig/namespaces/config/Firewall_SSO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use strict;
use warnings;

use pfconfig::namespaces::config;
use pfconfig::objects::NetAddr::IP;
use pf::file_paths qw($firewall_sso_config_file);

use base 'pfconfig::namespaces::config';
Expand All @@ -34,7 +33,7 @@ sub build_child {
my %tmp_cfg = %{ $self->{cfg} };
while ( my ($key, $item) = each %tmp_cfg ) {
$self->cleanup_after_read( $key, $item);
$item->{networks} = [map { pfconfig::objects::NetAddr::IP->new($_) // () } @{$item->{networks}}];
$item->{networks} = [map { { cidr => $_ } } @{$item->{networks}}];
}

$self->roleReverseLookup(\%tmp_cfg, 'firewall_sso', qw(categories));
Expand Down

0 comments on commit 7a020d8

Please sign in to comment.