Commit c273e4b7 authored by Dainis Abols's avatar Dainis Abols
Browse files

Redme update

parent d8ea09b3
......@@ -16,7 +16,7 @@ composer req luitd/lu-ldap-authorization
$ldapAuth = new LDAP($ldapServer, $ldapDc);
$user = $ldapAuth->authorize($username, $password);
```
Variable $user will contain `null` on failed authorization and `LDAPUser` object on successfully authorization.
Variable `$user` will contain `null` on failed authorization and `LDAPUser` object on successfully authorization!
## LDAPUser Object
| Type | Getter | Description |
......@@ -33,6 +33,18 @@ Variable $user will contain `null` on failed authorization and `LDAPUser` object
| Collection | getGroups() | Assigned user access groups |
| Collection | getLDAPGroups() | Assigned user access LDAP groups |
### Important changes from 1.x
1) `Username` and `Email` has been remade into Type classes, use `toString()` to get plain values!
2) `Groups` and `LDAPGroups` have been remade into Collections, use `all()` to get content!
3) `cn` has been renamed to `fullName` to better show its true purpose!
4) `givenname` has been renamed to `firstName` to better show its true purpose!
5) `sn` has been renamed to `lastName` to better show its true purpose!
6) LDAPUser no longer contains `dc` return value!
All variables set to camelCase standard.
## Testing
```shell
......@@ -40,54 +52,11 @@ Variable $user will contain `null` on failed authorization and `LDAPUser` object
```
| Test File | Assertions |
|-------------------------|------------|
| Unit/LDAPUserTest.php | 25 |
| Type/BooleanTest.php | 7 |
| Unit/LDAPUserTest.php | 23 |
| Type/EmailTest.php | 10 |
| Type/NameTest.php | 10 |
| Type/NumberTest.php | 7 |
| Type/PhoneTest.php | 9 |
| Type/SmartListTest.php | 12 |
| Type/TextTest.php | 10 |
| Type/UsernameTest.php | 10 |
| Functional/LDAPTest.php | 4 |
| Functional/LDAPTest.php | 3 |
> LDAPTest requires LDAP connection data.
>
> Specify your server and user details with `LDAPTest.php ldapServer=<your-server> ldapDC=<your-dc> ldapUser=<test-user> ldapPass=<test-pass>`
## Upgrading from 1.x to 2.x
`LDAPUser` properties have been changed to **type classes** and **private**. To get plain values from type classes use `toString`, `toInt`, or `toList` requests.
### Version 1.x
LDAP `authorize` returned `false` on fail and `LDAPUser` object on success.
Variables where **public** and accessible directly:
``` php
$ldapAuth = new LDAP($ldap_server, $ldap_dc);
$user = $ldapAuth->authorize($username, $password);
if ($user !== false) {
$uid = $user->uid;
$email = $user->email;
// ...
}
```
### Version 2.x
LDAP `authorize` always returns `LDAPUser` object. Use LDAPUser `isValid` to check result.
Variables are **type classes** and **private** only accessible with **getters**:
``` php
$ldapAuth = new LDAP($ldapServer, $ldapDc);
$user = $ldapAuth->authorize($username, $password);
if ($user) {
$username = (string)$user->getUsername();
$email = (string)$user->getEmail();
// ...
}
```
Notice:
1) `cn` has been renamed to `fullName` to better show its true purpose!
2) `givenname` has been renamed to `firstName` to better show its true purpose!
3) `sn` has been renamed to `lastName` to better show its true purpose!
All variables set to camelCase standard
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment