2017 © Pedro Peláez
 

library cas-server

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

image

loren138/cas-server

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  • Monday, May 29, 2017
  • by loren138
  • Repository
  • 1 Watchers
  • 3 Stars
  • 62 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Archived

Feel free to fork/clone/copy this for your own uses (and update to more recent versions of Laravel), (*1)

Laravel CAS Server

Todo

  • Add SAML/Warn
  • Unit test flashing an error to session

This is a Laravel implementation of the CAS protocol because tomcat/CAS are way to hard to deal with and keep up to date. This should be much easier and much easier to understand., (*2)

Because of the required URLs for CAS, it is recommended that you install this in it's own Laravel instance., (*3)

Laravel installation instructions can be found here: https://laravel.com/docs/5.2/installation, (*4)

Install

composer require loren138/cas-server

After updating composer, add the service provider to the providers array in config/app.php, (*5)

Loren138\CASServer\CASServerServiceProvider::class,

Next, you'll want to publish the views, public files, config, and migrations., (*6)

php artisan vendor:publish --provider="Loren138\CASServer\CASServerServiceProvider"

Next, you'll need to implement your user authentication class. The class for users must Implement Loren138\CASServer\Models\CASUserInterface, (*7)

 use Loren138\CASServer\Models\CASUserInterface;
 use Illuminate\Database\Eloquent\Model;

 class MyUser extends Model implements CASUserInterface
 {
      public function checkLogin($username, $password)
      {
            if (loginGood) {
                return true;
            }
            return false;
      }
      public function userAttributes($username);
      {
            return [
                'attribute' => 'value'
            ];
      }
 }

Last, update the casserver.php file in the config folder such that the userClass setting references your class (and update other settings as desired)., (*8)

You should now have a working CAS Server., (*9)

Table Cleanup

It is recommended that you have CAS cleanup the authentication and ticket tables daily. You can do that by adding the following in the schedule function in your console/Kernel.php file, (*10)

$schedule->command('casserver:cleanup')->daily();

Note: For this to work, you must have setup a cron job to call Laravel's command: https://laravel.com/docs/5.2/scheduling#introduction, (*11)

Session configuration

It is recommended to verify/set the following in config/session.php: (These settings are toward the bottom of the file.), (*12)

'secure'    => true,
'http_only' => true,
'expire_on_close' => true,

It is also recommended to change the cookie name in config/session.php:, (*13)

'cookie' => 'cas_session',

You should also make sure the lifetime variable is at least as long as your sso lifetime in casserver.php in config/session.php by default, you'll want to set session lifetime to 480., (*14)

Catching CSRF Errors

In the render (not report) function of app/Exceptions/Handler.php, you may want to add the following:, (*15)

if ($e instanceof TokenMismatchException) {
    session()->flash('error', 'Validation Token expired. Please try again.');
    return redirect()->back();
}

SSL

Single Sign on Sessions are only stored if you are using SSL. Thus, you may want to force SSL. You can do this on your web server or with a middleware such as: https://github.com/lesstif/laravel-secure-url, (*16)

You can also use modrewrite, (*17)

# This will enable the Rewrite capabilities
RewriteEngine On

# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on

# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Server Install

Testing requires sqlite., (*18)

The Versions

29/05 2017

dev-master

9999999-dev

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sso cas

15/08 2016

1.0.2

1.0.2.0

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sso cas

15/08 2016

dev-analysis-qMeolv

dev-analysis-qMeolv

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sso cas

13/08 2016

1.0.1

1.0.1.0

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sso cas

12/08 2016

1.0

1.0.0.0

A CAS Server form Single Sign On (SSO) implemented as a Laravel Package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel sso cas