Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime Besson
lemonldap-ng
Commits
055e4a7f
Commit
055e4a7f
authored
Mar 31, 2016
by
Yadd
Browse files
New process skeleton
parent
ce0f0d09
Changes
6
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/_WebForm.pm
View file @
055e4a7f
...
...
@@ -10,9 +10,7 @@ use Mouse;
our
$VERSION
=
'
2.0.0
';
sub
AuthnLevel
{
return
$_
[
0
]
->
https
?
1
:
0
;
}
extends
Lemonldap::NG::Portal::Main::
Auth
;
## @apmethod int authInit()
# Does nothing.
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Auth.pm
0 → 100644
View file @
055e4a7f
package
Lemonldap::NG::Portal::Main::
Auth
;
use
strict
;
use
Mouse
;
our
$VERSION
=
'
2.0.0
';
extends
'
Lemonldap::NG::Portal::Main::Module
';
has
authnLevel
=>
(
is
=>
'
rw
');
1
;
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
View file @
055e4a7f
...
...
@@ -27,17 +27,17 @@ has _authentication => ( is => 'rw' );
has
_userDB
=>
(
is
=>
'
rw
'
);
# Lists to store plugins entry-points
has
beforeAuth
Process
=>
(
has
beforeAuth
=>
(
is
=>
'
rw
',
isa
=>
'
ArrayRef
',
default
=>
sub
{
[]
}
);
has
addSession
Data
=>
(
has
betweenAuthAnd
Data
s
=>
(
is
=>
'
rw
',
isa
=>
'
ArrayRef
',
default
=>
sub
{
[]
}
);
has
after
AuthProces
s
=>
(
has
after
Data
s
=>
(
is
=>
'
rw
',
isa
=>
'
ArrayRef
',
default
=>
sub
{
[]
}
...
...
@@ -129,6 +129,8 @@ sub reloadConf {
unless
(
$self
->
{"
_
$type
"}
=
$self
->
loadModule
(
$module
)
and
$self
->
{"
_
$type
"}
->
init
);
}
$self
->
_authentication
->
authnLevel
(
$self
->
conf
->
{
$self
->
conf
->
authentication
.
"
AuthnLevel
"
}
);
# Initialize trusted domain list
$self
->
conf
->
{
trustedDomains
}
||=
"";
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Plugins.pm
View file @
055e4a7f
...
...
@@ -49,6 +49,8 @@ sub enabledPlugins {
}
}
# TODO: Password
# Check if custom plugins are required
if
(
$self
->
conf
->
{
plugins
}
)
{
$self
->
lmLog
(
'
Custom plugins:
'
.
$self
->
conf
->
{
plugins
},
'
debug
'
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm
View file @
055e4a7f
...
...
@@ -5,4 +5,11 @@ use Mouse;
extends
'
Lemonldap::NG::Common::PSGI::Request
';
has
steps
=>
(
is
=>
'
rw
'
);
has
error
=>
(
is
=>
'
rw
'
);
sub
wantJSON
{
return
$_
[
0
]
->
accept
=~
m#(?:application|text)/json#
?
1
:
0
;
}
1
;
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
055e4a7f
...
...
@@ -14,6 +14,7 @@ package Lemonldap::NG::Portal::Main::Run;
use
strict
;
use
Mouse
;
use
Lemonldap::NG::Portal::Main::
Constants
;
use
Lemonldap::NG::Portal::Main::
Request
;
our
$VERSION
=
'
2.0.0
';
...
...
@@ -44,30 +45,76 @@ sub pleaseAuth {
# MAIN ENTRY POINTS
# List constants
sub
authProcess
{
qw(extractFormInfo getUser authenticate)
}
sub
sessionDatas
{
qw(setAuthSessionInfo setSessionInfo setMacros setGroups
setPersistentSessionInfo setLocalGroups grantSession store
buildCookie)
;
}
sub
login
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
process
(
'
rememberArgs
',
@
{
$self
->
beforeAuthProcess
},
@authProcess
,
@
{
$self
->
addSessionData
},
@sessionDatas
,
@
{
$self
->
afterAuthProcess
}
return
$req
->
do
(
$req
,
[
'
rememberArgs
',
@
{
$self
->
beforeAuth
},
&authProcess
,
@
{
$self
->
betweenAuthAndDatas
},
&sessionDatas
,
@
{
$self
->
afterdatas
},
]
);
}
sub
postLogin
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
process
(
@
{
$self
->
beforeAuthProcess
},
@authProcess
,
@
{
$self
->
addSessionData
},
@sessionDatas
,
@
{
$self
->
afterAuthProcess
}
return
$req
->
do
(
$req
,
[
'
restoreArgs
',
@
{
$self
->
beforeAuth
},
&authProcess
,
@
{
$self
->
betweenAuthAndDatas
},
&sessionDatas
,
@
{
$self
->
afterdatas
},
]
);
}
sub
authenticatedRequest
{
my
(
$self
,
$req
)
=
@_
;
return
$req
->
do
(
$req
,
$self
->
forAuthUser
);
}
sub
do
{
my
(
$self
,
$req
,
$steps
)
=
@_
;
$req
->
steps
(
$steps
);
my
$err
=
$self
->
process
(
$req
);
# TODO: updateStatus
if
(
!
$self
->
conf
->
{
noAjaxHook
}
and
$req
->
wantJSON
)
{
if
(
$err
>
0
)
{
return
[
401
,
['
WWW-Authenticate
'
=>
"
SSO
"
.
$self
->
conf
->
{
portal
},'
Access-Control-Allow-Origin
'
=>
'
*
'],
[]
];
}
else
{
return
$self
->
senfJSONresponse
({
result
=>
1
,
message
=>
'
Authenticated
'});
}
}
else
{
if
(
$err
)
{
return
$self
->
sendHtml
(
$req
,'
login.tpl
');
}
else
{
return
$self
->
autoRedirect
(
$req
);
}
}
}
sub
process
{
my
(
$self
,
$req
)
=
@_
;
#$req->error(PE_OK);
my
$err
=
PE_OK
;
while
(
my
$sub
=
shift
@
{
$req
->
steps
})
{
last
if
(
$err
=
$self
->
$sub
(
$req
);
}
return
$err
;
}
# TODO in run
# - mustRedirect
# - store AuthnLevel in session (setSessionInfo)
# $self->{sessionInfo}->{authenticationLevel} = $self->_authentication->AuthnLevel
1
;
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