Skip to content

Commit

Permalink
modif
Browse files Browse the repository at this point in the history
  • Loading branch information
mhetru committed Jul 27, 2018
1 parent e0f0228 commit 2d768fe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Entity/UidUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class UidUser implements UserInterface {
protected $uid;
private $roles = array();

public function updateRoles() {
$this->roles = array('ROLE_USER');
public function updateRoles(array $rolesConfig = array()) {
$this->roles = $rolesConfig;
return;
}

Expand Down
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
User Provider for CAS

Allow use only UID for application Symfony2
Allow use only UID (returned by CasBundle) for application Symfony2, Symfony3 and Symfony4
(uid is the id user returned by jasig cas sso server and by the l3-team/CasBundle (repository github) or l3/cas-bundle (repository packagist))

Installation of the Bundle
---
Simple add this line in the require in your composer.json :
```
"l3/uid-user-bundle": "~1.0"
```
Launch the command **composer update** to install the package and add the Bundle in the AppKernel.php file.
Launch the command **composer update** to install the package.

For Symfony 2 and 3 : add the Bundle in the AppKernel.php file.
```
<?php
// app/AppKernel.php
Expand All @@ -31,13 +34,32 @@ class AppKernel extends Kernel
}
```

For Symfony 4 :
Verify if the line are present in config/bundles.php file (if not present, just add the line) :
```
# config/bundles.php
...
L3\Bundle\UidUserBundle\L3UidUserBundle::class => ['all' => true],
...
```

Configuration of the bundle
---
In the firewall of your application, use the Bundle :

For Symfony 2 and 3 : in the firewall of your application, use the Bundle :
```
# app/config/security.yml
security:
providers:
ldap:
id: uid_user_provider
uid:
id: uid_user_provider
```

For Symfony 4 : in the firewall of your application, use the Bundle :
```
# config/packages/security.yaml
security:
providers:
uid:
id: uid_user_provider
```
10 changes: 8 additions & 2 deletions Services/UidUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ class UidUserProvider implements UserProviderInterface {
public function __construct() {}

public function loadUserByUsername($username) {
$user = $user = new UidUser();
$user = new UidUser();
$user->setUid($username);
$user->updateRoles();
$roles = Array();
if ($username === '__NO_USER__') {
$roles = array('ROLE_ANON');
} else {
$roles = array('ROLE_ANON', 'ROLE_USER');
}
$user->updateRoles($roles);
return $user;
}

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"name": "l3/uid-user-bundle",
"type": "symfony-bundle",
"description": "User Provider for CAS (return only the UID)",
"homepage": "https://github.com/mhetru/UidUserBundle",
"license": "(c) Copyright Universite Lille3 - Charles de Gaulle",
"homepage": "https://github.com/l3-team/UidUserBundle",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "Mathieu Hétru",
"email": "mathieu.hetru@univ-lille3.fr"
"email": "mathieu.hetru@univ-lille.fr"
}
],
"require": {
Expand Down

0 comments on commit 2d768fe

Please sign in to comment.