Skip to content
GitLab
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
8d1c669a
Commit
8d1c669a
authored
Apr 04, 2016
by
Yadd
Browse files
#595 in progress...
parent
a16d452a
Changes
10
Hide whitespace changes
Inline
Side-by-side
lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Cli/Lib.pm
View file @
8d1c669a
...
...
@@ -120,8 +120,8 @@ sub _del {
sub
jsonResponse
{
my
(
$self
,
$path
,
$query
)
=
@_
;
my
$res
=
$self
->
_get
(
$path
,
$query
)
or
die
"
Manager
lib has refused my get, aborting
";
die
"
Manager
lib does not return a 200 code, aborting
"
or
die
"
PSGI
lib has refused my get, aborting
";
die
"
PSGI
lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
from_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
...
...
@@ -130,8 +130,8 @@ sub jsonResponse {
sub
jsonPostResponse
{
my
(
$self
,
$path
,
$query
,
$body
,
$type
,
$len
)
=
@_
;
my
$res
=
$self
->
_post
(
$path
,
$query
,
$body
,
$type
,
$len
)
or
die
"
Manager
lib has refused my post, aborting
";
die
"
Manager
lib does not return a 200 code, aborting
"
or
die
"
PSGI
lib has refused my post, aborting
";
die
"
PSGI
lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
from_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
...
...
@@ -140,8 +140,8 @@ sub jsonPostResponse {
sub
jsonPutResponse
{
my
(
$self
,
$path
,
$query
,
$body
,
$type
,
$len
)
=
@_
;
my
$res
=
$self
->
_put
(
$path
,
$query
,
$body
,
$type
,
$len
)
or
die
"
Manager
lib has refused my put, aborting
";
die
"
Manager
lib does not return a 200 code, aborting
"
or
die
"
PSGI
lib has refused my put, aborting
";
die
"
PSGI
lib does not return a 200 code, aborting
"
unless
(
$res
->
[
0
]
==
200
);
my
$href
=
from_json
(
$res
->
[
2
]
->
[
0
]
)
or
die
'
Response is not JSON
';
return
$href
;
...
...
lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm
View file @
8d1c669a
...
...
@@ -71,7 +71,7 @@ has QUERY_STRING => (
);
sub
_urlcode2params
{
my
(
$self
,
$str
)
=
shift
;
my
(
$self
,
$str
)
=
@_
;
my
@tmp
=
$str
?
map
{
uri_unescape
(
$_
)
}
split
(
/&/
,
$str
)
:
();
foreach
my
$s
(
@tmp
)
{
if
(
$s
=~
/^(.+?)=(.+)$/
)
{
$self
->
{
_params
}
->
{
$
1
}
=
$
2
;
}
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/_WebForm.pm
View file @
8d1c669a
...
...
@@ -99,9 +99,6 @@ sub extractFormInfo {
# Other parameters
$req
->
{
timezone
}
=
$req
->
param
('
timezone
');
# Check user
return
PE_MALFORMEDUSER
unless
$self
->
get_user
;
PE_OK
;
}
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Constants.pm
View file @
8d1c669a
...
...
@@ -3,6 +3,7 @@ package Lemonldap::NG::Portal::Main::Constants;
use
strict
;
use
Exporter
'
import
';
use
constant
HANDLER
=>
'
Lemonldap::NG::Handler::PSGI::API
';
use
constant
{
# Portal errors
...
...
@@ -150,6 +151,7 @@ our @EXPORT = qw( PE_IMG_NOK PE_IMG_OK PE_INFO PE_REDIRECT PE_DONE PE_OK
PM_LAST_LOGINS PM_LAST_FAILED_LOGINS PM_OIDC_CONSENT PM_OIDC_SCOPE_OPENID
PM_OIDC_SCOPE_PROFILE PM_OIDC_SCOPE_EMAIL PM_OIDC_SCOPE_ADDRESS
PM_OIDC_SCOPE_PHONE PM_OIDC_SCOPE_OTHER PM_OIDC_CONFIRM_LOGOUT
HANDLER
)
;
our
%EXPORT_TAGS
=
(
'
all
'
=>
[
@EXPORT
,
'
import
'
],
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm
View file @
8d1c669a
...
...
@@ -11,6 +11,7 @@ package Lemonldap::NG::Portal::Main::Init;
use
strict
;
use
Mouse
;
use
Lemonldap::NG::Common::Conf::
Constants
;
use
Lemonldap::NG::Portal::Main::
Constants
;
use
Lemonldap::NG::Handler::Main::
Reload
qw/keepConf/
;
use
Lemonldap::NG::Portal::Main::
Plugins
;
use
Regexp::
Assemble
;
...
...
@@ -20,8 +21,6 @@ our $VERSION = '2.0.0';
extends
'
Lemonldap::NG::Handler::PSGI::Try
',
'
Lemonldap::NG::Portal::Main::Plugins
';
use
constant
HANDLER
=>
'
Lemonldap::NG::Handler::PSGI::API
';
# Configuration storage
has
localConfig
=>
(
is
=>
'
rw
',
default
=>
sub
{
{}
}
);
has
conf
=>
(
is
=>
'
rw
',
default
=>
sub
{
{}
}
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm
View file @
8d1c669a
...
...
@@ -5,6 +5,7 @@ use Mouse;
use
Lemonldap::NG::Portal::Main::
Constants
;
use
Lemonldap::NG::Portal::Main::
Request
;
use
MIME::
Base64
;
use
POSIX
qw(strftime)
;
our
$VERSION
=
'
2.0.0
';
...
...
@@ -21,9 +22,11 @@ sub process {
my
$err
=
PE_OK
;
while
(
my
$sub
=
shift
@
{
$req
->
steps
}
)
{
if
(
ref
$sub
)
{
$self
->
lmLog
(
"
Processing code ref
",
'
debug
'
);
last
if
(
$sub
->
(
$req
)
);
}
else
{
$self
->
lmLog
(
"
Processing
$sub
",
'
debug
'
);
last
if
(
$err
=
$self
->
$sub
(
$req
)
);
}
}
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm
View file @
8d1c669a
...
...
@@ -17,6 +17,7 @@ has datas => ( is => 'rw', default => sub { {} } );
# Session datas when created
has
id
=>
(
is
=>
'
rw
'
);
has
sessionInfo
=>
(
is
=>
'
rw
'
);
has
user
=>
(
is
=>
'
rw
'
);
# Response cookies (list of strings built by cookie())
has
respCookies
=>
(
is
=>
'
rw
'
);
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm
View file @
8d1c669a
...
...
@@ -16,8 +16,6 @@ use Lemonldap::NG::Portal::Main::Request;
extends
'
Lemonldap::NG::Portal::Main::Process
';
use
constant
HANDLER
=>
'
Lemonldap::NG::Handler::PSGI::API
';
our
$VERSION
=
'
2.0.0
';
# List constants
...
...
@@ -86,14 +84,14 @@ sub postLogin {
'
restoreArgs
',
'
controlUrl
',
@
{
$self
->
beforeAuth
},
&authProcess
,
@
{
$self
->
betweenAuthAndDatas
},
&sessionDatas
,
@
{
$self
->
after
d
atas
},
@
{
$self
->
after
D
atas
},
]
);
}
sub
authenticatedRequest
{
my
(
$self
,
$req
)
=
@_
;
return
$self
->
do
(
$req
,
$self
->
forAuthUser
);
return
$self
->
do
(
$req
,
[
'
controlUrl
',
@
{
$self
->
forAuthUser
}
]
);
}
# RUNNING METHODS
...
...
lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/Demo.pm
View file @
8d1c669a
...
...
@@ -19,9 +19,9 @@ our $VERSION = '2.0.0';
sub
init
{
my
$self
=
shift
;
unless
(
$self
->
p
->
getModule
(
undef
,
'
auth
'
)
=~
/
^
Demo/
)
{
$self
->
lmLog
(
"
Use UserDBDemo only with AuthDemo
"
,
'
error
'
);
return
PE_ERROR
;
unless
(
$self
->
p
->
getModule
(
undef
,
'
auth
'
)
=~
/Demo/
)
{
$self
->
p
->
error
(
"
Use UserDB
::
Demo only with Auth
::
Demo
");
return
0
;
}
# Sample accounts from Doctor Who characters
...
...
@@ -53,9 +53,9 @@ sub getUser {
my
(
$self
,
$req
)
=
@_
;
# Search by login
if
(
$req
->
{
user
}
)
{
if
(
$req
->
user
)
{
return
PE_OK
if
(
defined
$self
->
{
_demoAccounts
}
->
{
$req
->
{
user
}
}
);
if
(
defined
$self
->
{
_demoAccounts
}
->
{
$req
->
user
}
);
}
# Search by mail
...
...
lemonldap-ng-portal/t/01-AuthDemo.t
View file @
8d1c669a
use
Test::
More
;
use
strict
;
use
IO::
String
;
require
'
t/test-lib.pm
';
print
STDERR
Dumper
(
&client
->
_get
('
/
'));
my
$res
;
ok
(
$res
=
&client
->
_get
('
/
'),
'
Unauth JSON request
'
);
ok
(
$res
->
[
0
]
==
401
,
'
Response is 401
'
)
or
explain
(
$res
,
401
);
count
(
2
);
#ok( $res = &client->jsonPostResponse('/','',IO::String->new('user=dwho&password=dwho'),'application/x-www-form-urlencoded',23), 'Auth query');
#count(1);
done_testing
(
count
()
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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