diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-04-26 02:38:13 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-04-26 02:38:13 +0200 |
commit | 8387d8eb466e1187ee6caeaeb773d67652797731 (patch) | |
tree | 0f3af0439d67c836b36108e4339900b1a2fcded6 /lib/JWebmail/Plugin/Helper.pm | |
parent | affff46cea8dad31bb850ec27ba2a57f123e681b (diff) |
put auth into the stash
Diffstat (limited to 'lib/JWebmail/Plugin/Helper.pm')
-rw-r--r-- | lib/JWebmail/Plugin/Helper.pm | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/JWebmail/Plugin/Helper.pm b/lib/JWebmail/Plugin/Helper.pm index c454b9f..3281d26 100644 --- a/lib/JWebmail/Plugin/Helper.pm +++ b/lib/JWebmail/Plugin/Helper.pm @@ -83,7 +83,8 @@ sub print_sizes2 { sub d { qr/([[:digit:]]{$_[0]})/ } sub parse_iso_date { - my @d = shift =~ m/@{[d(4).'-'.d(2).'-'.d(2).'T'.d(2).':'.d(2).':'.d(2)]}/; + state $rx = d(4).'-'.d(2).'-'.d(2).'T'.d(2).':'.d(2).':'.d(2); + my @d = shift =~ m/$rx/; if (!all { defined $_ } @d) { # TODO } @@ -159,10 +160,10 @@ sub session_passwd { warn_crypt($c); if (defined $passwd) { # set - if ( HMAC && lc($c->config->{'session'}{secure} || 'none') eq 'cram' ) { + if ( HMAC && lc($c->config->{session}{secure}) eq 'cram' ) { $c->session(S_PASSWD() => $passwd ? b64_encode(hmac_md5($passwd, $c->app->secrets->[0]), '') : ''); } - elsif (lc($c->config->{'session'}->{secure} || 'none') eq 's3d') { + elsif (lc($c->config->{session}{secure}) eq 's3d') { unless ($passwd) { $c->s3d(S_PASSWD, ''); delete $c->session->{S_OTP_S3D_PW()}; @@ -181,10 +182,10 @@ sub session_passwd { } } else { # get - if ( HMAC && lc($c->config->{'session'}->{secure} || 'none') eq 'cram' ) { + if ( HMAC && lc($c->config->{'session'}{secure}) eq 'cram' ) { return ($c->app->secrets->[0], $c->session(S_PASSWD)); } - elsif (lc($c->config->{'session'}->{secure} || 'none') eq 's3d') { + elsif (lc($c->config->{'session'}{secure}) eq 's3d') { my $pw = b64_decode($c->s3d(S_PASSWD) || ''); my $otp = b64_decode($c->session(S_OTP_S3D_PW) || ''); my ($res) = split "\n", decode('UTF-8', $pw ^ $otp), 2; @@ -201,11 +202,10 @@ sub warn_cram { state $once = 0; - if ( !HMAC && !$once && lc($c->config->{'session'}->{secure} || 'none') eq 'cram' ) { + if ( !HMAC && !$once && lc($c->config->{'session'}{secure}) eq 'cram' ) { $c->log->warn("cram requires Digest::HMAC_MD5. Falling back to 'none'."); + $once = 1; } - - $once = 1; } sub warn_crypt { @@ -213,11 +213,10 @@ sub warn_crypt { state $once = 0; - if ( !TRUE_RANDOM && !$once && lc($c->config->{'session'}->{secure} || 'none') eq 's3d' ) { + if ( !TRUE_RANDOM && !$once && lc($c->config->{'session'}{secure}) eq 's3d' ) { $c->log->warn("Falling back to pseudo random generation. Please install Crypt::Random"); + $once = 1; } - - $once = 1; } ### pagination |