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
928c669d
Commit
928c669d
authored
Mar 31, 2016
by
Yadd
Browse files
New portal in progress... (
#595
)
parent
50f28ca6
Changes
2
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
View file @
928c669d
...
...
@@ -55,18 +55,26 @@ sub init {
$self
->
localConfig
(
{
%
{
HANDLER
->
confAcc
->
getLocalConf
('
portal
')
},
%$args
}
);
# Handle default requests (other path may be declared in enabled plugins)
$self
->
addAuthRoute
('
*
'
=>
'
menu
');
$self
->
addUnauthRoute
('
*
'
=>
'
login
');
# Handle requests (other path may be declared in enabled plugins)
$self
# Default routes must point to routines declared above
$self
->
defaultAuthRoute
('');
# "/"
->
addUnauthRoute
(
'
*
',
'
login
',
['
GET
']
)
->
addUnauthRoute
(
'
*
',
'
postLogin
',
['
POST
']
)
->
addAuthRoute
(
'
*
',
'
authenticatedRequest
',
['
GET
']
)
# Core REST API
->
addUnauthRoute
(
'
test
',
'
pleaseAuth
',
['
GET
']
)
->
addAuthRoute
(
'
test
',
'
authenticated
',
['
GET
']
)
# Default routes must point to routines declared above
$self
->
defaultAuthRoute
('');
$self
->
defaultUnauthRoute
('');
return
$self
->
reloadConf
(
$args
);
}
sub
reloadConf
{
my
(
$self
)
=
@_
;
my
(
$self
)
=
@_
;
my
$conf
=
HANDLER
->
lmConf
->
{
cfgNum
};
...
...
@@ -152,7 +160,9 @@ sub loadPlugin {
qw(beforeAuthProcess addSessionData afterAuthProcess forAuthUser)
)
{
if
(
$obj
->
can
(
$sub
)
)
{
push
@
{
$self
->
{
$sub
}
},
$obj
->
$sub
;
if
(
my
$callback
=
$obj
->
$sub
)
{
push
@
{
$self
->
{
$sub
}
},
sub
{
$obj
->
$callback
(
$_
[
1
]
)
};
}
}
}
return
$obj
->
init
;
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
928c669d
...
...
@@ -6,6 +6,10 @@
# underlying handler configuration before launching
# Lemonldap::NG::Common::PSGI::Router::handler() (which parse
# routes)
#
# Entry points:
# - "/test": * authenticated() for already authenticated users
# + pleaseAuth() for others
package
Lemonldap::NG::Portal::Main::
Run
;
use
strict
;
...
...
@@ -15,14 +19,52 @@ use Lemonldap::NG::Portal::Main::Request;
our
$VERSION
=
'
2.0.0
';
sub
handler
{
my
(
$self
,
$req
)
=
shift
;
unless
(
$self
->
conf
->
{
cfgNum
}
and
$self
->
conf
->
{
cfgNum
}
eq
HANDLER
->
lmConf
->
{
cfgNum
}
)
{
$self
->
reloadConf
()
my
(
$self
,
$req
)
=
shift
;
unless
(
$self
->
conf
->
{
cfgNum
}
and
$self
->
conf
->
{
cfgNum
}
eq
HANDLER
->
lmConf
->
{
cfgNum
}
)
{
$self
->
reloadConf
();
}
bless
$req
,
'
Lemonldap::NG::Portal::Main::Request
';
return
$self
->
SUPER::
handler
(
$req
);
}
# CORE REST API
# Methods that handle /test
sub
authenticated
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
sendJSONresponse
(
$req
,
{
status
=>
1
}
);
}
sub
pleaseAuth
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
sendJSONresponse
(
$req
,
{
status
=>
0
}
);
}
# MAIN ENTRY POINTS
sub
login
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
process
(
'
rememberArgs
',
@
{
$self
->
beforeAuthProcess
},
@authProcess
,
@
{
$self
->
addSessionData
},
@sessionDatas
,
@
{
$self
->
afterAuthProcess
}
);
}
sub
postLogin
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
process
(
@
{
$self
->
beforeAuthProcess
},
@authProcess
,
@
{
$self
->
addSessionData
},
@sessionDatas
,
@
{
$self
->
afterAuthProcess
}
);
}
sub
authenticatedRequest
{
}
# TODO in run
# - mustRedirect
# - store AuthnLevel in session (setSessionInfo)
...
...
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