Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Xavier Bachelot
lemonldap-ng
Commits
cdeec009
Commit
cdeec009
authored
Mar 16, 2017
by
Yadd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace "?lmError=" by router path (#595)
parent
a8f7e689
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
51 additions
and
38 deletions
+51
-38
_example/etc/experimental/handler-nginx.conf
_example/etc/experimental/handler-nginx.conf
+2
-2
_example/etc/handler-apache2.4.conf
_example/etc/handler-apache2.4.conf
+3
-3
_example/etc/handler-apache2.X.conf
_example/etc/handler-apache2.X.conf
+3
-3
_example/etc/handler-apache2.conf
_example/etc/handler-apache2.conf
+3
-3
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/PSGI.pm
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/PSGI.pm
+1
-1
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/SecureToken.pm
...ap-ng-handler/lib/Lemonldap/NG/Handler/Lib/SecureToken.pm
+1
-1
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Run.pm
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Run.pm
+14
-3
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm
+0
-20
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
+5
-1
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
+19
-1
No files found.
_example/etc/experimental/handler-nginx.conf
View file @
cdeec009
...
...
@@ -12,8 +12,8 @@ log_format lm_combined '$remote_addr - $lmremote_user [$time_local] '
'"$http_referer" "$http_user_agent"'
;
# Common error page and security parameters
error_page
500
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
500
;
error_page
503
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
503
;
error_page
500
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
500
;
error_page
503
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
503
;
server
{
listen
__
VHOSTLISTEN__
;
...
...
_example/etc/handler-apache2.4.conf
View file @
cdeec009
...
...
@@ -20,9 +20,9 @@ PerlOptions +GlobalRequest
PerlModule
Lemonldap
::
NG
::
Handler
# Common error page and security parameters
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
503
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
503
<
VirtualHost
__
VHOSTLISTEN__
>
ServerName
reload
.
__
DNSDOMAIN__
...
...
_example/etc/handler-apache2.X.conf
View file @
cdeec009
...
...
@@ -20,9 +20,9 @@ PerlOptions +GlobalRequest
PerlModule
Lemonldap
::
NG
::
Handler
# Common error page and security parameters
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
503
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
503
<
VirtualHost
__
VHOSTLISTEN__
>
ServerName
reload
.
__
DNSDOMAIN__
...
...
_example/etc/handler-apache2.conf
View file @
cdeec009
...
...
@@ -20,9 +20,9 @@ PerlOptions +GlobalRequest
PerlModule
Lemonldap
::
NG
::
Handler
# Common error page and security parameters
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
?
lm
E
rror
=
503
ErrorDocument
403
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
403
ErrorDocument
500
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
500
ErrorDocument
503
http
://
auth
.
__
DNSDOMAIN__
/
lm
e
rror
/
503
<
VirtualHost
__
VHOSTLISTEN__
>
ServerName
reload
.
__
DNSDOMAIN__
...
...
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/PSGI.pm
View file @
cdeec009
...
...
@@ -145,7 +145,7 @@ sub _authAndTrace {
}
else
{
my
%h
=
$req
->
{
respHeaders
}
?
@
{
$req
->
{
respHeaders
}
}
:
();
my
$s
=
$type
->
tsv
->
{
portal
}
->
()
.
"
?
lm
E
rror
=
$res
";
my
$s
=
$type
->
tsv
->
{
portal
}
->
()
.
"
/
lm
e
rror
/
$res
";
$s
=
'
<html><head><title>Redirection</title></head><body>
'
.
qq{<script type="text/javascript">window.location='$s'</script>}
...
...
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/SecureToken.pm
View file @
cdeec009
...
...
@@ -227,7 +227,7 @@ sub _returnError {
# Redirect or Forbidden?
if
(
$class
->
tsv
->
{
useRedirectOnError
}
)
{
$class
->
logger
->
debug
("
Use redirect for error
");
return
$class
->
goTo
Portal
(
'
/
',
'
lmError=
500
'
);
return
$class
->
goTo
Error
(
'
/
',
500
);
}
else
{
...
...
lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Run.pm
View file @
cdeec009
...
...
@@ -91,7 +91,7 @@ sub run {
if
(
$class
->
tsv
->
{
useRedirectOnError
}
)
{
$class
->
logger
->
debug
("
Go to portal with maintenance error code
");
return
$class
->
goTo
Portal
(
'
/
',
'
lmError=
'
.
$class
->
MAINTENANCE
);
return
$class
->
goTo
Error
(
'
/
',
$class
->
MAINTENANCE
);
}
else
{
$class
->
logger
->
debug
("
Return maintenance error code
");
...
...
@@ -294,7 +294,7 @@ sub forbidden {
# Redirect or Forbidden?
if
(
$class
->
tsv
->
{
useRedirectOnForbidden
}
)
{
$class
->
logger
->
debug
("
Use redirect for forbidden access
");
return
$class
->
goTo
Portal
(
$uri
,
'
lmError=
403
'
);
return
$class
->
goTo
Error
(
$uri
,
403
);
}
else
{
$class
->
logger
->
debug
("
Return forbidden access
");
...
...
@@ -344,6 +344,17 @@ sub goToPortal {
return
$class
->
REDIRECT
;
}
sub
goToError
{
my
(
$class
,
$url
,
$code
)
=
@_
;
my
$urlc_init
=
$class
->
encodeUrl
(
$url
);
$class
->
logger
->
debug
(
"
Redirect
"
.
$class
->
remote_ip
.
"
to lmError (url was
$url
)
"
);
$class
->
set_header_out
(
'
Location
'
=>
$class
->
tsv
->
{
portal
}
->
()
.
"
/lmerror/
$code
"
.
"
?url=
$urlc_init
"
);
return
$class
->
REDIRECT
;
}
## @rmethod protected fetchId()
# Get user cookies and search for Lemonldap::NG cookie.
# @return Value of the cookie if found, 0 else
...
...
@@ -563,7 +574,7 @@ sub abort {
# Redirect or die
if
(
$class
->
tsv
->
{
useRedirectOnError
}
)
{
$class
->
logger
->
debug
("
Use redirect for error
");
return
$class
->
goTo
Portal
(
$uri
,
'
lmError=
500
'
);
return
$class
->
goTo
Error
(
$uri
,
500
);
}
else
{
return
$class
->
SERVER_ERROR
;
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm
View file @
cdeec009
...
...
@@ -36,26 +36,6 @@ sub display {
my
$skin_dir
=
$self
->
conf
->
{
templatesDir
};
my
(
$skinfile
,
%templateParams
);
# 0. Display error page
if
(
my
$http_error
=
$req
->
param
('
lmError
')
)
{
$skinfile
=
'
error
';
# Check URL
$self
->
controlUrl
(
$req
);
%templateParams
=
(
LOGOUT_URL
=>
$self
->
conf
->
{
portal
}
.
"
?logout=1
",
URL
=>
$req
->
{
urldc
},
);
# Error code
foreach
(
403
,
500
,
503
)
{
$templateParams
{"
ERROR
$_
"}
=
(
$http_error
==
$_
?
1
:
0
);
}
}
# 1. Authentication not complete
# 1.1 A notification has to be done (session is created but hidden and
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
View file @
cdeec009
...
...
@@ -109,10 +109,14 @@ sub init {
->
addUnauthRoute
(
'
psgi.js
'
=>
'
sendJs
',
['
GET
']
)
->
addAuthRoute
(
'
psgi.js
'
=>
'
sendJs
',
['
GET
']
)
# p
sgi.j
s
# p
ortal.cs
s
->
addUnauthRoute
(
'
portal.css
'
=>
'
sendCss
',
['
GET
']
)
->
addAuthRoute
(
'
portal.css
'
=>
'
sendCss
',
['
GET
']
)
# lmerror
->
addUnauthRoute
(
lmerror
=>
{
'
:code
'
=>
'
lmError
'
},
['
GET
']
)
->
addAuthRoute
(
lmerror
=>
{
'
:code
'
=>
'
lmError
'
},
['
GET
']
)
# Core REST API
->
addUnauthRoute
(
ping
=>
'
pleaseAuth
',
['
GET
']
)
->
addAuthRoute
(
ping
=>
'
authenticated
',
['
GET
']
)
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
cdeec009
...
...
@@ -259,7 +259,7 @@ sub autoRedirect {
if
(
$req
->
mustRedirect
and
not
(
$req
->
info
)
);
# Redirection should be made if urldc defined
if
(
$req
->
{
urldc
}
and
not
$req
->
param
('
lmError
')
)
{
if
(
$req
->
{
urldc
}
)
{
if
(
$self
->
_jsRedirect
->
()
)
{
$req
->
error
(
PE_REDIRECT
);
$req
->
datas
->
{
redirectFormMethod
}
=
"
get
";
...
...
@@ -734,6 +734,24 @@ sub sendCss {
];
}
sub
lmError
{
my
(
$self
,
$req
)
=
@_
;
my
$httpError
=
$req
->
param
('
code
');
# Check URL
$self
->
controlUrl
(
$req
);
my
%templateParams
=
(
LOGOUT_URL
=>
$self
->
conf
->
{
portal
}
.
"
?logout=1
",
URL
=>
$req
->
{
urldc
},
);
# Error code
$templateParams
{"
ERROR
$_
"}
=
(
$httpError
==
$_
?
1
:
0
)
foreach
(
403
,
500
,
503
);
return
$self
->
sendHtml
(
$req
,
'
error
',
params
=>
\
%templateParams
);
}
sub
rebuildCookies
{
my
(
$self
,
$req
)
=
@_
;
my
@tmp
;
...
...
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