Skip to content

Commit

Permalink
Fix encoding issues with passwords
Browse files Browse the repository at this point in the history
FreeRADIUS handles passwords as byte-strings. How the client or the
plugin encode/decode these bytes is up to them.
Some VPNs seem to use ISO-latin encoding, other UTF-8.
With this fix we try to guess the encoding using a built-in perl
module and decode it accordingly before URL-encoding it for privacyIDEA.
  • Loading branch information
plettich committed Aug 20, 2021
1 parent cb5ec19 commit 4b59e2d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion privacyidea_radius.pm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ use Try::Tiny;
use JSON;
use Time::HiRes qw( gettimeofday tv_interval );
use URI::Encode;

use Encode::Guess;

# use ...
# This is very important ! Without this script will not get the filled hashes from main.
Expand Down Expand Up @@ -423,6 +423,15 @@ sub authenticate {
my @p = split(/\0/, $password);
$password = @p[0];
}
# Encode password
my $decoder = Encode::Guess->guess($password);
if ( ! ref($decoder) ) {
radiusd::radlog( Info, "Could not find valid password encoding. Sending password as-is." );
radiusd::radlog( Debug, $decoder );
} else {
&radiusd::radlog( Info, "Password encoding guessed: " . $decoder->name);
$password = $decoder->decode($password);
}
$params{"pass"} = $password;
} elsif ( $Config->{ADD_EMPTY_PASS} =~ /true/i ) {
$params{"pass"} = "";
Expand Down

0 comments on commit 4b59e2d

Please sign in to comment.