Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
lemonldap-ng
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maxime Besson
lemonldap-ng
Commits
832d7d87
Commit
832d7d87
authored
Feb 01, 2019
by
Christophe Maudoux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix AuthSSL with Choice (#1636)
parent
f33697de
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
112 additions
and
11 deletions
+112
-11
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Choice.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Choice.pm
+16
-0
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SSL.pm
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SSL.pm
+1
-0
lemonldap-ng-portal/site/coffee/ssl.coffee
lemonldap-ng-portal/site/coffee/ssl.coffee
+4
-2
lemonldap-ng-portal/site/coffee/sslChoice.coffee
lemonldap-ng-portal/site/coffee/sslChoice.coffee
+23
-0
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.js
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.js
+8
-4
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.min.js
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.min.js
+1
-1
lemonldap-ng-portal/site/htdocs/static/common/js/sslChoice.js
...nldap-ng-portal/site/htdocs/static/common/js/sslChoice.js
+30
-0
lemonldap-ng-portal/site/htdocs/static/common/js/sslChoice.min.js
...p-ng-portal/site/htdocs/static/common/js/sslChoice.min.js
+1
-0
lemonldap-ng-portal/site/templates/bootstrap/login.tpl
lemonldap-ng-portal/site/templates/bootstrap/login.tpl
+2
-2
lemonldap-ng-portal/site/templates/bootstrap/sslformChoice.tpl
...ldap-ng-portal/site/templates/bootstrap/sslformChoice.tpl
+19
-0
lemonldap-ng-portal/t/28-AuthChoice-with-rules.t
lemonldap-ng-portal/t/28-AuthChoice-with-rules.t
+7
-2
No files found.
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Choice.pm
View file @
832d7d87
...
...
@@ -25,6 +25,22 @@ sub _authCancel {
sub
extractFormInfo
{
my
(
$self
,
$req
)
=
@_
;
unless
(
$self
->
checkChoice
(
$req
)
)
{
foreach
my
$mod
(
values
%
{
$self
->
modules
}
)
{
$self
->
logger
->
debug
("
Auth module ->
$mod
");
if
(
$mod
=~
/::Auth::SSL/
and
$self
->
conf
->
{
sslByAjax
}
and
not
$req
->
param
('
nossl
')
)
{
$self
->
logger
->
debug
('
Send SSL javascript
');
$req
->
data
->
{
customScript
}
.=
'
<script type="application/init">{"sslHost":"
'
.
$self
->
conf
->
{
sslHost
}
.
'
"}</script>
';
$self
->
logger
->
debug
(
"
Send JS ->
"
.
$req
->
data
->
{
customScript
}
);
}
}
foreach
my
$mod
(
values
%
{
$self
->
modules
}
)
{
if
(
$mod
->
can
('
setSecurity
')
)
{
$mod
->
setSecurity
(
$req
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SSL.pm
View file @
832d7d87
...
...
@@ -44,6 +44,7 @@ sub extractFormInfo {
'
<script type="application/init">{"sslHost":"
'
.
$self
->
conf
->
{
sslHost
}
.
'
"}</script>
';
$self
->
logger
->
debug
("
Send JS ->
"
.
$req
->
data
->
{
customScript
});
return
PE_FIRSTACCESS
;
}
else
{
...
...
lemonldap-ng-portal/site/coffee/ssl.coffee
View file @
832d7d87
# Launch SSL request
tryssl
=
()
->
console
.
log
'Call URL -> '
,
window
.
datas
.
sslHost
$
.
ajax
window
.
datas
.
sslHost
,
dataType
:
'json'
# Called if browser can't find Kerberos ticket will display
# PE_BADCREDENTIALS
statusCode
:
401
:
()
->
$
(
'#lform'
).
submit
()
console
.
log
'Error code 401'
# If request succeed, cookie is set, posting form to get redirection
# or menu
success
:
(
data
)
->
$
(
'#lform'
).
submit
()
console
.
log
'Success -> '
,
data
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
# backend
error
:
()
->
$
(
'#lform'
).
submit
()
console
.
log
'Error'
$
(
document
).
ready
->
$
(
'.sslclick'
).
on
'click'
,
tryssl
lemonldap-ng-portal/site/coffee/sslChoice.coffee
0 → 100644
View file @
832d7d87
# Launch SSL request
tryssl
=
()
->
console
.
log
'Call URL -> '
,
window
.
datas
.
sslHost
$
.
ajax
window
.
datas
.
sslHost
,
dataType
:
'json'
# PE_BADCREDENTIALS
statusCode
:
401
:
()
->
$
(
'#lformSSL'
).
submit
()
console
.
log
'Error code 401'
# If request succeed, cookie is set, posting form to get redirection
# or menu
success
:
(
data
)
->
$
(
'#lformSSL'
).
submit
()
console
.
log
'Success -> '
,
data
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
# backend
error
:
()
->
$
(
'#lformSSL'
).
submit
()
console
.
log
'Error'
$
(
document
).
ready
->
$
(
'.sslclick'
).
on
'click'
,
tryssl
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.js
View file @
832d7d87
// Generated by CoffeeScript 1.1
0.0
// Generated by CoffeeScript 1.1
2.7
(
function
()
{
var
tryssl
;
tryssl
=
function
()
{
console
.
log
(
'
Call URL ->
'
,
window
.
datas
.
sslHost
);
return
$
.
ajax
(
window
.
datas
.
sslHost
,
{
dataType
:
'
json
'
,
statusCode
:
{
401
:
function
()
{
return
$
(
'
#lform
'
).
submit
();
$
(
'
#lform
'
).
submit
();
return
console
.
log
(
'
Error code 401
'
);
}
},
success
:
function
(
data
)
{
return
$
(
'
#lform
'
).
submit
();
$
(
'
#lform
'
).
submit
();
return
console
.
log
(
'
Success ->
'
,
data
);
},
error
:
function
()
{
return
$
(
'
#lform
'
).
submit
();
$
(
'
#lform
'
).
submit
();
return
console
.
log
(
'
Error
'
);
}
});
};
...
...
lemonldap-ng-portal/site/htdocs/static/common/js/ssl.min.js
View file @
832d7d87
(
function
(){
var
a
;
a
=
function
(){
return
$
.
ajax
(
window
.
datas
.
sslHost
,{
dataType
:
"
json
"
,
statusCode
:{
401
:
function
(){
return
$
(
"
#lform
"
).
submit
()}},
success
:
function
(
b
){
return
$
(
"
#lform
"
).
submit
()},
error
:
function
(){
return
$
(
"
#lform
"
).
submit
()}})};
$
(
document
).
ready
(
function
(){
return
$
(
"
.sslclick
"
).
on
(
"
click
"
,
a
)})}).
call
(
this
);
\ No newline at end of file
(
function
(){
var
tryssl
;
tryssl
=
function
(){
console
.
log
(
"
Call URL ->
"
,
window
.
datas
.
sslHost
);
return
$
.
ajax
(
window
.
datas
.
sslHost
,{
dataType
:
"
json
"
,
statusCode
:{
401
:
function
(){
$
(
"
#lform
"
).
submit
();
return
console
.
log
(
"
Error code 401
"
)}},
success
:
function
(
data
){
$
(
"
#lform
"
).
submit
();
return
console
.
log
(
"
Success ->
"
,
data
)},
error
:
function
(){
$
(
"
#lform
"
).
submit
();
return
console
.
log
(
"
Error
"
)}})};
$
(
document
).
ready
(
function
(){
return
$
(
"
.sslclick
"
).
on
(
"
click
"
,
tryssl
)})}).
call
(
this
);
lemonldap-ng-portal/site/htdocs/static/common/js/sslChoice.js
0 → 100644
View file @
832d7d87
// Generated by CoffeeScript 1.12.7
(
function
()
{
var
tryssl
;
tryssl
=
function
()
{
console
.
log
(
'
Call URL ->
'
,
window
.
datas
.
sslHost
);
return
$
.
ajax
(
window
.
datas
.
sslHost
,
{
dataType
:
'
json
'
,
statusCode
:
{
401
:
function
()
{
$
(
'
#lformSSL
'
).
submit
();
return
console
.
log
(
'
Error code 401
'
);
}
},
success
:
function
(
data
)
{
$
(
'
#lformSSL
'
).
submit
();
return
console
.
log
(
'
Success ->
'
,
data
);
},
error
:
function
()
{
$
(
'
#lformSSL
'
).
submit
();
return
console
.
log
(
'
Error
'
);
}
});
};
$
(
document
).
ready
(
function
()
{
return
$
(
'
.sslclick
'
).
on
(
'
click
'
,
tryssl
);
});
}).
call
(
this
);
lemonldap-ng-portal/site/htdocs/static/common/js/sslChoice.min.js
0 → 100644
View file @
832d7d87
(
function
(){
var
tryssl
;
tryssl
=
function
(){
console
.
log
(
"
Call URL ->
"
,
window
.
datas
.
sslHost
);
return
$
.
ajax
(
window
.
datas
.
sslHost
,{
dataType
:
"
json
"
,
statusCode
:{
401
:
function
(){
$
(
"
#lformSSL
"
).
submit
();
return
console
.
log
(
"
Error code 401
"
)}},
success
:
function
(
data
){
$
(
"
#lformSSL
"
).
submit
();
return
console
.
log
(
"
Success ->
"
,
data
)},
error
:
function
(){
$
(
"
#lformSSL
"
).
submit
();
return
console
.
log
(
"
Error
"
)}})};
$
(
document
).
ready
(
function
(){
return
$
(
"
.sslclick
"
).
on
(
"
click
"
,
tryssl
)})}).
call
(
this
);
lemonldap-ng-portal/site/templates/bootstrap/login.tpl
View file @
832d7d87
...
...
@@ -37,7 +37,7 @@
<div
id=
"<TMPL_VAR NAME="
key
"
>
">
<form
action=
"<TMPL_VAR NAME="
url
"
>
" method="post" class="login
<TMPL
_VAR
NAME=
"module"
>
">
<form
id=
"lform<TMPL_VAR NAME="
module
"
>
"
action="
<TMPL
_VAR
NAME=
"url"
>
" method="post" class="login
<TMPL
_VAR
NAME=
"module"
>
">
<!-- Hidden fields -->
<TMPL
_VAR
NAME=
"HIDDEN_INPUTS"
>
...
...
@@ -59,7 +59,7 @@
</TMPL
_IF
>
<TMPL
_IF
NAME=
"sslform"
>
<TMPL
_INCLUDE
NAME=
"sslform.tpl"
>
<TMPL
_INCLUDE
NAME=
"sslform
Choice
.tpl"
>
</TMPL
_IF
>
<TMPL
_IF
NAME=
"logo"
>
...
...
lemonldap-ng-portal/site/templates/bootstrap/sslformChoice.tpl
0 → 100644
View file @
832d7d87
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/ssl.min.js"></script>
//else -->
<script
type=
"text/javascript"
src=
"<TMPL_VAR NAME="
STATIC_PREFIX
"
>
common
/
js
/
sslChoice
.
js
"
>
</script>
<!-- //endif -->
<div
class=
"form"
>
<input
type=
"hidden"
name=
"nossl"
value=
"1"
/>
<div
class=
"sslclick"
>
<img
src=
"<TMPL_VAR NAME="
STATIC_PREFIX
"
>
common/modules/SSL.png" alt="
<TMPL
_VAR
NAME=
"module"
>
" class="img-thumbnail mb-3" />
</div>
<TMPL
_INCLUDE
NAME=
"checklogins.tpl"
>
<button
type=
"submit"
class=
"btn btn-success sslclick"
>
<span
class=
"fa fa-sign-in"
></span>
<span
trspan=
"connect"
>
Connect
</span>
</button>
</div>
lemonldap-ng-portal/t/28-AuthChoice-with-rules.t
View file @
832d7d87
...
...
@@ -5,7 +5,7 @@ use IO::String;
require
'
t/test-lib.pm
';
my
$res
;
my
$maintests
=
1
2
;
my
$maintests
=
1
3
;
eval
{
unlink
'
t/userdb.db
'
};
...
...
@@ -48,6 +48,8 @@ SKIP: {
dbiAuthPasswordHash
=>
'',
customAuth
=>
'
::Auth::Apache
',
customAddParams
=>
{},
sslByAjax
=>
1
,
sslHost
=>
'
https://authssl.example.com:19876
'
}
}
);
...
...
@@ -63,9 +65,12 @@ SKIP: {
ok
(
$res
->
[
2
]
->
[
0
]
=~
qr%<img src="/static/common/modules/SSL.png"%
,
'
Found 5_ssl Logo
'
)
or
print
STDERR
Dumper
(
$res
->
[
2
]
->
[
0
]
);
ok
(
$res
->
[
2
]
->
[
0
]
=~
m%<form action="https://test.example.com"%
,
ok
(
$res
->
[
2
]
->
[
0
]
=~
m%<form
id="lformDemo"
action="https://test.example.com"%
,
'
Redirect URL found
'
)
or
print
STDERR
Dumper
(
$res
->
[
2
]
->
[
0
]
);
ok
(
$res
->
[
2
]
->
[
0
]
=~
m%<script type="application/init">\{"sslHost":"https://authssl.example.com:19876"\}</script>%
,
'
SSL AJAX URL found
'
)
or
print
STDERR
Dumper
(
$res
->
[
2
]
->
[
0
]
);
my
$header
=
getHeader
(
$res
,
'
Content-Security-Policy
'
);
ok
(
$header
=~
m%;form-action \'self\' https://test.example.com;%
,
'
CSP URL found
'
)
...
...
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