Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Access Check - Account manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Access Check - Account manager
Commits
763fb58f
Commit
763fb58f
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
inline mail sending function
parent
aabfc388
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/IdPAccountManager/Tools.pm
+0
-24
0 additions, 24 deletions
lib/IdPAccountManager/Tools.pm
lib/IdPAccountManager/WebRequest.pm
+31
-22
31 additions, 22 deletions
lib/IdPAccountManager/WebRequest.pm
with
31 additions
and
46 deletions
lib/IdPAccountManager/Tools.pm
+
0
−
24
View file @
763fb58f
...
...
@@ -104,30 +104,6 @@ sub update_ssp_authsources {
}
## Send a mail notice
## Default is to send email to the manager admins, unless other recipients are specified
## mail_notice(IN)
## IN is a HASH with expected entries :
## template : mail template file
## data : data used by the TT2 parser
sub
mail_notice
{
my
(
%args
)
=
@_
;
die
"
unable to send mail, no sendmail executable found
"
unless
-
x
'
/usr/sbin/sendmail
';
open
SENDMAIL
,
"
|/usr/sbin/sendmail -f
$args
{data}->{from}
$args
{data}->{to}
";
my
$tt2
=
Template
->
new
({
INCLUDE_PATH
=>
$args
{
templates_dir
}
});
$tt2
->
process
(
$args
{
template
},
$args
{
data
},
\
*SENDMAIL
)
or
die
$tt2
->
error
();
close
SENDMAIL
;
}
1
;
__END__
...
...
This diff is collapsed.
Click to expand it.
lib/IdPAccountManager/WebRequest.pm
+
31
−
22
View file @
763fb58f
...
...
@@ -362,34 +362,43 @@ sub req_generate_token {
$self
->
{
out
}
->
{
sp_entityid
}
=
$self
->
{
in
}
->
{
sp_entityid
};
$self
->
{
out
}
->
{
subtitle
}
=
'
Generate an authentication token
';
## Send the challenge email with the token
eval
{
IdPAccountManager::Tools::
mail_notice
(
template
=>
'
mail/send_authentication_token.tt2.eml
',
templates_dir
=>
$self
->
{
configuration
}
->
{
templates_dir
},
data
=>
{
env
=>
{
REMOTE_HOST
=>
$ENV
{
REMOTE_HOST
},
REMOTE_ADDR
=>
$ENV
{
REMOTE_ADDR
},
},
conf
=>
{
app_name
=>
$self
->
{
configuration
}
->
{
app_name
},
app_url
=>
$self
->
{
configuration
}
->
{
app_url
},
support_email
=>
$self
->
{
configuration
}
->
{
support_email
},
},
from
=>
$self
->
{
configuration
}
->
{
notice_from
},
to
=>
$self
->
{
in
}
->
{
email_address
},
sp_entityid
=>
$self
->
{
in
}
->
{
sp_entityid
},
authentication_token
=>
$token
->
token
(),
}
);
my
$sender
=
$self
->
{
configuration
}
->
{
notice_from
};
my
$recipient
=
$self
->
{
in
}
->
{
email_address
};
unless
(
open
(
SENDMAIL
,
"
|/usr/sbin/sendmail -f
$sender
$recipient
"))
{
push
@
{
$self
->
{
out
}
->
{
errors
}
},
"
mail_notification_error
";
$self
->
{
logger
}
->
errorf
("
Mail notification error: %s
",
$ERRNO
);
return
undef
;
}
my
$tt2
=
Template
->
new
({
INCLUDE_PATH
=>
$self
->
{
configuration
}
->
{
templates_dir
}
});
my
$template
=
'
mail/send_authentication_token.tt2.eml
';
my
$data
=
{
env
=>
{
REMOTE_HOST
=>
$ENV
{
REMOTE_HOST
},
REMOTE_ADDR
=>
$ENV
{
REMOTE_ADDR
},
},
conf
=>
{
app_name
=>
$self
->
{
configuration
}
->
{
app_name
},
app_url
=>
$self
->
{
configuration
}
->
{
app_url
},
support_email
=>
$self
->
{
configuration
}
->
{
support_email
},
},
from
=>
$sender
,
to
=>
$recipient
,
sp_entityid
=>
$self
->
{
in
}
->
{
sp_entityid
},
authentication_token
=>
$token
->
token
(),
};
if
(
$EVAL_ERROR
)
{
unless
(
$tt2
->
process
(
$template
,
$data
,
\
*SENDMAIL
))
{
push
@
{
$self
->
{
out
}
->
{
errors
}
},
"
mail_notification_error
";
$self
->
{
logger
}
->
errorf
("
Mail notification error: %s
",
$EVAL_ERROR
);
return
undef
;
}
close
SENDMAIL
;
$self
->
{
logger
}
->
infof
(
"
Token send to %s for sp_entityid=%s;token=%s
",
$self
->
{
in
}
->
{
email_address
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment