malt_dp
malt_dp

Reputation: 17

FreeRadius filter_username

I need to adjust the filter to a radius in order to allow a connection only with the username which contains the word "test".

Set up the block:

filter_private  {
            if (User-Name =~ /^(?!test).*$/) {
                    update reply {
                            Reply-Message += "Rejected: Username rejected, because not test"
                    }
                    reject
            }
    }

But it allows absolutely any username.

Upvotes: 1

Views: 1691

Answers (1)

John Cummings
John Cummings

Reputation: 2184

Based on the documentation, I think you need to negate the logic:

if (User-Name !~ /^(?!test).*$/) {
    # etc.
}

Also, the regex above probably (depending on your local regex engine) allows usernames starting with test (due to ^) not any username containing test. For the latter, you would need to change the logic to be:

if (User-Name !~ /.*test.*/) {
    # etc.
}

Upvotes: 0

Related Questions