Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
lemonldap-ng
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Bachelot
lemonldap-ng
Commits
5c5556a8
Commit
5c5556a8
authored
Mar 09, 2018
by
Xavier Guimard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2F choice works (#1148)
TODO: logos
parent
dc23b5e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
5 deletions
+52
-5
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Engines/Default.pm
...p-ng-portal/lib/Lemonldap/NG/Portal/2F/Engines/Default.pm
+49
-3
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
+1
-1
lemonldap-ng-portal/site/templates/bootstrap/totpregister.tpl
...nldap-ng-portal/site/templates/bootstrap/totpregister.tpl
+1
-1
lemonldap-ng-portal/site/templates/bootstrap/u2fregister.tpl
lemonldap-ng-portal/site/templates/bootstrap/u2fregister.tpl
+1
-0
No files found.
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/2F/Engines/Default.pm
View file @
5c5556a8
...
...
@@ -3,7 +3,11 @@ package Lemonldap::NG::Portal::2F::Engines::Default;
use
strict
;
use
Mouse
;
use
Lemonldap::NG::Portal::Main::
Constants
qw(
PE_ERROR
PE_NOTOKEN
PE_OK
PE_SENDRESPONSE
PE_TOKENEXPIRED
)
;
our
$VERSION
=
'
2.0.0
';
...
...
@@ -68,7 +72,7 @@ sub init {
# Store module
push
@
{
$self
->
{
$i
?
'
sfRModules
'
:
'
sfModules
'
}
},
{
m => $m, r =
>
$rule
};
{
p
=>
$prefix
,
m => $m, r =
>
$rule
};
}
else
{
$self
->
logger
->
debug
('
-> not enabled
');
...
...
@@ -116,11 +120,12 @@ sub run {
$req
->
sessionInfo
->
{
_2fRealSession
}
=
$req
->
id
;
$req
->
sessionInfo
->
{
_2fUrldc
}
=
$req
->
urldc
;
my
$token
=
$self
->
ott
->
createToken
(
$req
->
sessionInfo
);
delete
$req
->
{
authResult
};
# If only one 2F is authorizated, display it
unless
(
$#am
)
{
my
$res
=
$am
[
0
]
->
run
(
$req
,
$token
);
delete
$req
->
{
authResult
}
if
(
$res
);
$req
->
authResult
(
$res
);
return
$res
;
}
...
...
@@ -135,7 +140,8 @@ sub run {
MODULES
=>
[
map
{
{
CODE
=>
$_
->
prefix
,
LOGO
=>
$_
->
logo
}
}
@am
],
}
);
return
PE_OK
;
$req
->
response
(
$tpl
);
return
PE_SENDRESPONSE
;
# TODO:
# - 2fchoice.tpl
...
...
@@ -143,6 +149,46 @@ sub run {
# - add logos for 2F modules
}
sub
choice
{
my
(
$self
,
$req
)
=
@_
;
my
$token
;
# Restore session
unless
(
$token
=
$req
->
param
('
token
')
)
{
$self
->
userLogger
->
error
(
$self
->
prefix
.
'
2F access without token
'
);
$req
->
mustRedirect
(
1
);
return
$self
->
p
->
do
(
$req
,
[
sub
{
PE_NOTOKEN
}
]
);
}
my
$session
;
unless
(
$session
=
$self
->
ott
->
getToken
(
$token
)
)
{
$self
->
userLogger
->
info
('
Token expired
');
return
$self
->
p
->
do
(
$req
,
[
sub
{
PE_TOKENEXPIRED
}
]
);
}
$req
->
sessionInfo
(
$session
);
# New token
$token
=
$self
->
ott
->
createToken
(
$session
);
my
$ch
=
$req
->
param
('
sf
');
foreach
my
$m
(
@
{
$self
->
sfModules
}
)
{
if
(
$m
->
{
m}->prefix eq $ch ) {
my $res = $m->{m}
->
run
(
$req
,
$token
);
$req
->
authResult
(
$res
);
return
$self
->
p
->
do
(
$req
,
[
sub
{
$res
},
'
controlUrl
',
'
buildCookie
',
@
{
$self
->
p
->
afterDatas
},
]
);
}
}
$self
->
userLogger
->
error
('
Bd 2F choice
');
return
$self
->
p
->
lmError
(
$req
,
500
);
}
sub
_redirect
{
my
(
$self
,
$req
)
=
@_
;
my
$arg
=
$req
->
env
->
{
QUERY_STRING
};
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
5c5556a8
...
...
@@ -20,7 +20,7 @@ sub authProcess { qw(extractFormInfo getUser authenticate) }
sub
sessionDatas
{
qw(setAuthSessionInfo setSessionInfo setMacros setGroups setPersistentSessionInfo
setLocalGroups store
buildCookie secondFactor
)
;
setLocalGroups store
secondFactor buildCookie
)
;
}
# RESPONSE HANDLER
...
...
lemonldap-ng-portal/site/templates/bootstrap/totpregister.tpl
View file @
5c5556a8
...
...
@@ -30,7 +30,7 @@
</main>
<div
class=
"buttons"
>
<a
id=
"goback"
href=
""
class=
"btn btn-primary"
role=
"button"
>
<a
id=
"goback"
href=
"
<TMPL_VAR NAME="
PORTAL_URL
"
><TMPL_IF
NAME=
"AUTH_URL"
>
/?url=
<TMPL_VAR
NAME=
"AUTH_URL"
></TMPL_IF>
" class="btn btn-primary" role="button">
<span
class=
"glyphicon glyphicon-home"
></span>
<span
trspan=
"goToPortal"
>
Go to portal
</span>
</a>
...
...
lemonldap-ng-portal/site/templates/bootstrap/u2fregister.tpl
View file @
5c5556a8
...
...
@@ -28,6 +28,7 @@
</main>
<div
class=
"buttons"
>
<a
id=
"goback"
href=
"<TMPL_VAR NAME="
PORTAL_URL
"
><TMPL_IF
NAME=
"AUTH_URL"
>
/?url=
<TMPL_VAR
NAME=
"AUTH_URL"
></TMPL_IF>
" class="btn btn-primary" role="button">
<a
id=
"goback"
href=
""
class=
"btn btn-primary"
role=
"button"
>
<span
class=
"glyphicon glyphicon-home"
></span>
<span
trspan=
"goToPortal"
>
Go to portal
</span>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment