-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
785 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,65 @@ | ||
cas | ||
CAS | ||
=== | ||
|
||
CAS server SSO authentication in laravel 4.x | ||
CAS server SSO authentication in Laravel 4.x & 5.x | ||
|
||
## Installation | ||
|
||
Require this package in your composer.json and run composer update (or run `composer require xavrsl/cas:dev-master` directly): | ||
Require this package in your composer.json and run composer update. | ||
|
||
"xavrsl/cas": "dev-master" | ||
For Laravel 4 use v1.1.* : | ||
|
||
After updating composer, add the ServiceProvider to the providers array in app/config/app.php | ||
"xavrsl/cas": "1.1.*" | ||
|
||
'Xavrsl\Cas\CasServiceProvider', | ||
For Laravel 5 use v1.2.* : | ||
|
||
As well as the Facade : | ||
"xavrsl/cas": "1.2.*" | ||
|
||
After updating composer, add the ServiceProvider to the providers array in app/config/app.php | ||
```php | ||
'Xavrsl\Cas\CasServiceProvider', | ||
``` | ||
As well as the Facade : | ||
```php | ||
'Cas' => 'Xavrsl\Cas\Facades\Cas', | ||
``` | ||
Then publish the package's config using one of those methods : | ||
|
||
You need to publish the conf so you will ffind it in app/config/packages/xavrsl/cas/ | ||
|
||
For Laravel 4 : | ||
``` | ||
$ php artisan config:publish xavrsl/cas | ||
``` | ||
|
||
For Laravel 5 : | ||
``` | ||
$ php artisan vendor:publish | ||
``` | ||
|
||
Configuration | ||
== | ||
|
||
Configuration should be pretty straightforward for anyone who's ever used the PHPCas client. However, I've added the possibility to easily turn your application into a CAS Proxy, a CAS Service or both. You only need to set the cas_proxy setting to true (if you need to proxy services) and set the cas_service to whatever proxy you want to allow (this is all explained in the config file). | ||
Configuration should be pretty straightforward for anyone who's ever used the phpCAS client. Using the .env file will allow you to have different environments without even touching the cas.php config file. I've added the possibility to easily turn your application into a CAS Proxy, a CAS Service or both. You only need to set the cas_proxy setting to true (if you need to proxy services) and set the cas_service to whatever proxy you want to allow (this is all explained in the config file). | ||
|
||
A new config variable (cas_pretend_user) available in the 1.2 release allows you to pretend to be a selected CAS user. The idea came with the usage of laravel homestead. My application was running on a private network, on a fake domain. The CAS server was not able to redirect to that application. So activating the CAS plugin on that application was not possible, but I needed a user id to query my LDAP and allow/disallow the user in my application. You only need to give it a user id and the application will act just as if you ware logged in with that CAS user. | ||
|
||
Usage | ||
== | ||
|
||
Authenticate against the CAS server | ||
Authenticate against the CAS server. This should be called before trying to retrieve the CAS user id. | ||
|
||
```php | ||
Cas::authenticate(); | ||
``` | ||
|
||
Exemple of Cas authentication in a route filter : | ||
Then get the current user id this way : | ||
|
||
```php | ||
Route::group(array('https', 'before' => 'cas'), function() | ||
{ | ||
Route::controller('toolbar', 'ToolbarController'); | ||
|
||
Route::controller('bibsearch', 'BibsearchController'); | ||
}); | ||
Cas::getCurrentUser(); | ||
``` | ||
|
||
Route::controller('bibimages', 'BibimagesController'); | ||
OR | ||
|
||
Route::filter('cas', function() | ||
{ | ||
Cas::authenticate(); | ||
}); | ||
```php | ||
Cas::user(); | ||
``` | ||
|
||
Then get the current user id this way : | ||
|
||
Cas::getCurrentUser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php namespace Xavrsl\Cas; | ||
|
||
class CasAuthenticationException extends \Exception{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.