Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2016-02-08 19:45:01 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
d32460070f8e608ec20cc58ddcfa137057086dc5
d3246007
1 parent
105500e5
Made ldap auth use the 'dn' if a 'uid' is not present.
Fixes #56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
app/Services/LdapService.php
database/migrations/2016_01_11_210908_add_external_auth_to_users.php
tests/Auth/LdapTest.php
app/Services/LdapService.php
View file @
d324600
...
...
@@ -46,7 +46,7 @@ class LdapService
$user
=
$users
[
0
];
return
[
'uid'
=>
$user
[
'uid'
][
0
],
'uid'
=>
(
isset
(
$user
[
'uid'
]))
?
$user
[
'uid'
][
0
]
:
$user
[
'dn'
],
'name'
=>
$user
[
'cn'
][
0
],
'dn'
=>
$user
[
'dn'
],
'email'
=>
(
isset
(
$user
[
'mail'
]))
?
$user
[
'mail'
][
0
]
:
null
...
...
database/migrations/2016_01_11_210908_add_external_auth_to_users.php
View file @
d324600
...
...
@@ -28,4 +28,4 @@ class AddExternalAuthToUsers extends Migration
$table
->
dropColumn
(
'external_auth_id'
);
});
}
}
}
\ No newline at end of file
...
...
tests/Auth/LdapTest.php
View file @
d324600
...
...
@@ -28,7 +28,7 @@ class LdapTest extends \TestCase
->
andReturn
([
'count'
=>
1
,
0
=>
[
'uid'
=>
[
$this
->
mockUser
->
name
],
'cn'
=>
[
$this
->
mockUser
->
name
],
'dn'
=>
[
'dc=test'
.
config
(
'services.ldap.base_dn'
)]
'dn'
=>
[
'dc=test'
.
config
(
'services.ldap.base_dn'
)]
]]);
$this
->
mockLdap
->
shouldReceive
(
'bind'
)
->
times
(
6
)
->
andReturn
(
true
);
...
...
@@ -46,6 +46,30 @@ class LdapTest extends \TestCase
->
seeInDatabase
(
'users'
,
[
'email'
=>
$this
->
mockUser
->
email
,
'email_confirmed'
=>
1
,
'external_auth_id'
=>
$this
->
mockUser
->
name
]);
}
public
function
test_login_works_when_no_uid_provided_by_ldap_server
()
{
$this
->
mockLdap
->
shouldReceive
(
'connect'
)
->
once
()
->
andReturn
(
$this
->
resourceId
);
$this
->
mockLdap
->
shouldReceive
(
'setOption'
)
->
once
();
$ldapDn
=
'cn=test-user,dc=test'
.
config
(
'services.ldap.base_dn'
);
$this
->
mockLdap
->
shouldReceive
(
'searchAndGetEntries'
)
->
times
(
2
)
->
with
(
$this
->
resourceId
,
config
(
'services.ldap.base_dn'
),
Mockery
::
type
(
'string'
),
Mockery
::
type
(
'array'
))
->
andReturn
([
'count'
=>
1
,
0
=>
[
'cn'
=>
[
$this
->
mockUser
->
name
],
'dn'
=>
$ldapDn
,
'mail'
=>
[
$this
->
mockUser
->
email
]
]]);
$this
->
mockLdap
->
shouldReceive
(
'bind'
)
->
times
(
3
)
->
andReturn
(
true
);
$this
->
visit
(
'/login'
)
->
see
(
'Username'
)
->
type
(
$this
->
mockUser
->
name
,
'#username'
)
->
type
(
$this
->
mockUser
->
password
,
'#password'
)
->
press
(
'Sign In'
)
->
seePageIs
(
'/'
)
->
see
(
$this
->
mockUser
->
name
)
->
seeInDatabase
(
'users'
,
[
'email'
=>
$this
->
mockUser
->
email
,
'email_confirmed'
=>
1
,
'external_auth_id'
=>
$ldapDn
]);
}
public
function
test_initial_incorrect_details
()
{
$this
->
mockLdap
->
shouldReceive
(
'connect'
)
->
once
()
->
andReturn
(
$this
->
resourceId
);
...
...
@@ -55,7 +79,7 @@ class LdapTest extends \TestCase
->
andReturn
([
'count'
=>
1
,
0
=>
[
'uid'
=>
[
$this
->
mockUser
->
name
],
'cn'
=>
[
$this
->
mockUser
->
name
],
'dn'
=>
[
'dc=test'
.
config
(
'services.ldap.base_dn'
)]
'dn'
=>
[
'dc=test'
.
config
(
'services.ldap.base_dn'
)]
]]);
$this
->
mockLdap
->
shouldReceive
(
'bind'
)
->
times
(
3
)
->
andReturn
(
true
,
true
,
false
);
...
...
Please
register
or
sign in
to post a comment