Mail template (#2325)
This commit is contained in:
parent
d0c6f7eec6
commit
13a7a81173
|
@ -1,4 +1,4 @@
|
|||
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
|
||||
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
|
@ -133,7 +133,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "llng-fastcgi-server 8"
|
||||
.TH llng-fastcgi-server 8 "2021-07-03" "perl v5.30.0" "User Contributed Perl Documentation"
|
||||
.TH llng-fastcgi-server 8 "2021-08-10" "perl v5.32.1" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
|
|
@ -5,7 +5,7 @@ use strict;
|
|||
use Exporter 'import';
|
||||
use base qw(Exporter);
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
# CONSTANTS
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is generated by Lemonldap::NG::Manager::Build. Don't modify it by hand
|
||||
package Lemonldap::NG::Common::Conf::DefaultValues;
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
sub defaultValues {
|
||||
return {
|
||||
|
|
|
@ -5,7 +5,7 @@ use strict;
|
|||
use Exporter 'import';
|
||||
use base qw(Exporter);
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [qw($simpleHashKeys $doubleHashKeys $specialNodeKeys $casAppMetaDataNodeKeys $casSrvMetaDataNodeKeys $oidcOPMetaDataNodeKeys $oidcRPMetaDataNodeKeys $samlIDPMetaDataNodeKeys $samlSPMetaDataNodeKeys $virtualHostKeys $specialNodeHash $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters $casServiceParameters)] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
|
|
|
@ -4,7 +4,7 @@ package Lemonldap::NG::Handler::Lib::StatusConstants;
|
|||
use strict;
|
||||
use Exporter 'import';
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
sub portalConsts {
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is generated by Lemonldap::NG::Manager::Build. Don't modify it by hand
|
||||
package Lemonldap::NG::Manager::Attributes;
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
sub perlExpr {
|
||||
my ( $val, $conf ) = @_;
|
||||
|
@ -2071,6 +2071,12 @@ m[^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
|
|||
'default' => 'mail',
|
||||
'type' => 'text'
|
||||
},
|
||||
'newLocationWarningMailBody' => {
|
||||
'type' => 'longtext'
|
||||
},
|
||||
'newLocationWarningMailSubject' => {
|
||||
'type' => 'text'
|
||||
},
|
||||
'nginxCustomHandlers' => {
|
||||
'keyTest' => qr/^\w+$/,
|
||||
'msgFail' => '__badPerlPackageName__',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
package Lemonldap::NG::Manager::Build::Attributes;
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
use strict;
|
||||
use Regexp::Common qw/URI/;
|
||||
|
||||
|
@ -585,6 +585,14 @@ sub attributes {
|
|||
documentation => 'New location warning mail session attribute',
|
||||
flags => 'p',
|
||||
},
|
||||
newLocationWarningMailBody => {
|
||||
type => 'longtext',
|
||||
documentation => 'Mail body for new location warning',
|
||||
},
|
||||
newLocationWarningMailSubject=> {
|
||||
type => 'text',
|
||||
documentation => 'Mail subject for new location warning',
|
||||
},
|
||||
globalLogoutRule => {
|
||||
type => 'boolOrExpr',
|
||||
default => 0,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package Lemonldap::NG::Manager::Build::Tree;
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
# TODO: Missing:
|
||||
# * activeTimer
|
||||
|
@ -1042,7 +1042,9 @@ sub tree {
|
|||
help => 'newLocationWarning.html',
|
||||
nodes => [
|
||||
'newLocationWarning',
|
||||
'newLocationWarningMailAttribute'
|
||||
'newLocationWarningMailAttribute',
|
||||
'newLocationWarningMailSubject',
|
||||
'newLocationWarningMailBody'
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@ package Lemonldap::NG::Portal::Main::Constants;
|
|||
use strict;
|
||||
use Exporter 'import';
|
||||
|
||||
our $VERSION = '2.0.12';
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
use constant HANDLER => 'Lemonldap::NG::Handler::PSGI::Main';
|
||||
use constant URIRE =>
|
||||
|
|
|
@ -9,7 +9,10 @@ use Lemonldap::NG::Portal::Main::Constants qw(
|
|||
|
||||
our $VERSION = '2.0.13';
|
||||
|
||||
extends 'Lemonldap::NG::Portal::Main::Plugin';
|
||||
extends qw(
|
||||
Lemonldap::NG::Portal::Lib::SMTP
|
||||
Lemonldap::NG::Portal::Main::Plugin
|
||||
);
|
||||
|
||||
# Entrypoint
|
||||
use constant endAuth => 'check';
|
||||
|
@ -26,6 +29,7 @@ sub check {
|
|||
my $successLogin = $req->sessionInfo->{_loginHistory}->{successLogin};
|
||||
my $failedLogin = $req->sessionInfo->{_loginHistory}->{failedLogin};
|
||||
my $ipSource = $req->env->{ipAddr};
|
||||
|
||||
my @IPsS =
|
||||
map { $_->{ipAddr} eq $ipSource ? $_->{ipAddr} : () } @$successLogin;
|
||||
my @IPsF =
|
||||
|
@ -33,15 +37,73 @@ sub check {
|
|||
my @IPs = ( @IPsS, @IPsF );
|
||||
|
||||
$self->logger->debug( '**************** ' . Dumper( \@IPs ) );
|
||||
return scalar @IPs ? $self->sendMail($req) : PE_OK;
|
||||
return scalar @IPs ? $self->_sendMail($req) : PE_OK;
|
||||
}
|
||||
|
||||
sub sendMail {
|
||||
sub _sendMail {
|
||||
my ( $self, $req ) = @_;
|
||||
my $epoch = time();
|
||||
my $ipSource = $req->env->{ipAddr};
|
||||
my $host = $req->env->{HTTP_HOST};
|
||||
$self->logger->debug( "******************************* $host");
|
||||
|
||||
my $mail =
|
||||
$req->sessionInfo->{ $self->conf->{newLocationWarningMailAttribute}
|
||||
|| 'mail' };
|
||||
$self->logger->debug("+++++++++++++++++++++++ $mail");
|
||||
|
||||
# Build mail content
|
||||
my $tr = $self->translate($req);
|
||||
my $subject = $self->conf->{newLocationWarningMailSubject};
|
||||
unless ($subject) {
|
||||
$subject = 'newLocationWarningMailSubject';
|
||||
$tr->( \$subject );
|
||||
}
|
||||
my $body;
|
||||
my $html;
|
||||
if ( $self->conf->{newLocationWarningMailBody} ) {
|
||||
|
||||
# We use a specific text message, no html
|
||||
$body = $self->conf->{newLocationWarningMailBody};
|
||||
|
||||
# Replace variables in body
|
||||
$body =~ s/\$newLocationIP/$ipSource/ge;
|
||||
$body =~ s/\$newLocationTime/$epoch/ge;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
# Use HTML template
|
||||
$body = $self->loadMailTemplate(
|
||||
$req,
|
||||
'mail_new_location_warning',
|
||||
filter => $tr,
|
||||
params => {
|
||||
session_ipAddr => $ipSource,
|
||||
newLocationTime => $epoch,
|
||||
host => $host,
|
||||
},
|
||||
);
|
||||
$html = 1;
|
||||
}
|
||||
|
||||
$self->logger->info( "Warning, user "
|
||||
. $req->data->{mailAddress}
|
||||
. " is loggin in from a new location" );
|
||||
|
||||
# Send mail
|
||||
unless (
|
||||
$self->send_mail(
|
||||
$mail, $subject, $body, $html
|
||||
)
|
||||
)
|
||||
{
|
||||
$self->logger->debug('Unable to send new location warning mail');
|
||||
|
||||
# Don't return an error here to avoid enumeration
|
||||
}
|
||||
|
||||
|
||||
return PE_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<TMPL_INCLUDE NAME="mail_header.tpl">
|
||||
|
||||
<p>
|
||||
<span trspan="hello">Hello</span> <TMPL_VAR NAME="session_cn" ESCAPE=HTML>,<br />
|
||||
<br />
|
||||
<a href="<TMPL_VAR NAME="url" ESCAPE=HTML>" style="text-decoration:none;color:orange;">
|
||||
<span trspan="host">Host</span> <b><TMPL_VAR NAME="host"></b></br>
|
||||
<span trspan="date">Date</span> <b><TMPL_VAR NAME="newLocationDate"></b>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<TMPL_INCLUDE NAME="mail_footer.tpl">
|
Loading…
Reference in New Issue