Skip to content

Commit

Permalink
Merge pull request #54 from privacyidea/fix_password_encoding
Browse files Browse the repository at this point in the history
Fix password encoding
  • Loading branch information
cornelinux authored Aug 26, 2021
2 parents cb5ec19 + 93a5572 commit f01b6a1
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];
}
# Decode password (from <https://perldoc.perl.org/Encode::Guess#Encode::Guess-%3Eguess($data)>)
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 f01b6a1

Please sign in to comment.