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
Guilherme Monteiro
lemonldap-ng
Commits
d51877a4
Commit
d51877a4
authored
Sep 10, 2021
by
Christophe Maudoux
🐛
Browse files
Code refactoring
parent
f378c863
Changes
1
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Remote.pm
View file @
d51877a4
...
...
@@ -2,11 +2,18 @@ package Lemonldap::NG::Portal::Lib::Remote;
use
strict
;
use
Mouse
;
use
Lemonldap::NG::Common::
Session
;
use
Lemonldap::NG::Portal::Main::
Constants
qw(PE_OK PE_ERROR PE_REDIRECT)
;
use
MIME::
Base64
;
use
Lemonldap::NG::Common::
Session
;
use
Lemonldap::NG::Portal::Main::
Constants
qw(
URIRE
PE_OK
PE_ERROR
PE_REDIRECT
)
;
our
$VERSION
=
'
2.0.14
';
our
$VERSION
=
'
2.0.0
'
;
has
cookieName
=>
(
is
=>
'
rw
'
)
;
# INITIALIZATION
...
...
@@ -20,29 +27,37 @@ sub init {
$self
->
error
(
"
Missing required parameters
"
.
join
(
'
,
',
@missing
)
);
return
0
;
}
unless
(
$self
->
conf
->
{
remotePortal
}
=~
URIRE
)
{
$self
->
error
("
Bad remotePortal URL
");
return
0
;
}
eval
"
require
"
.
$self
->
conf
->
{
remoteGlobalStorage
};
if
(
$@
)
{
$self
->
error
(
$@
);
return
0
;
}
$self
->
conf
->
{
remoteCookieName
}
||=
$self
->
conf
->
{
cookieName
};
$self
->
cookieName
(
$self
->
conf
->
{
remoteCookieName
}
||
$self
->
conf
->
{
cookieName
}
);
return
1
;
}
# RUNNING METHODS
## @apmethod int checkRemoteId()
# check if a CDA mechanism has been instantiated and if session is available.
# Redirect
the
user to
the
remote portal else by calling goToPortal().
# Redirect user to remote portal else by calling goToPortal().
# @return Lemonldap::NG::Portal constant
sub
checkRemoteId
{
my
(
$self
,
$req
)
=
@_
;
my
%h
;
if
(
my
$rId
=
$req
->
param
(
$self
->
co
nf
->
{
remoteCo
okieName
}
)
)
{
if
(
my
$rId
=
$req
->
param
(
$self
->
cookieName
)
)
{
$req
->
mustRedirect
(
1
);
# Trying to recover session from global session storage
my
$remoteSession
=
Lemonldap::NG::Common::
Session
->
new
(
{
storageModule
=>
$self
->
conf
->
{
remoteGlobalStorage
},
storageModuleOptions
=>
...
...
@@ -53,7 +68,6 @@ sub checkRemoteId {
kind
=>
"
SSO
",
}
);
if
(
$remoteSession
->
error
)
{
$self
->
logger
->
error
("
Remote session error
");
$self
->
logger
->
error
(
$remoteSession
->
error
);
...
...
@@ -62,24 +76,26 @@ sub checkRemoteId {
%
{
$req
->
data
->
{
rSessionInfo
}
}
=
%
{
$remoteSession
->
data
()
};
delete
(
$req
->
data
->
{
rSessionInfo
}
->
{'
_password
'}
)
unless
(
$self
->
conf
->
{
storePassword
}
)
;
unless
$self
->
conf
->
{
storePassword
};
return
PE_OK
;
}
return
$self
->
goToPortal
(
$req
);
}
## @method protected void goToPortal()
# Redirect
the
user to
the
remote portal.
# Redirect user to remote portal.
sub
goToPortal
{
my
(
$self
,
$req
)
=
@_
;
$req
->
urldc
(
$self
->
conf
->
{
remotePortal
}
.
"
?url=
"
$self
->
conf
->
{
remotePortal
}
.
'
?url=
'
.
encode_base64
(
$self
->
conf
->
{
portal
}
.
(
$req
->
query_string
?
'
?
'
.
$req
->
query_string
:
''
),
''
)
);
return
PE_REDIRECT
;
}
...
...
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