1. Go to this page and download the library: Download avvertix/caslite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
avvertix / caslite example snippets
'providers' => [
// Other service providers...
Avvertix\Caslite\CasliteServiceProvider::class,
],
'cas' => [
/*
|--------------------------------------------------------------------------
| phpCAS Debug
|--------------------------------------------------------------------------
|
| @var boolean true to enable debug, log file will be written in storage/logs/cas.log
|
*/
'cas_debug' => env('CAS_DEBUG', false),
/*
|--------------------------------------------------------------------------
| phpCAS Hostname
|--------------------------------------------------------------------------
|
| Example: 'login.uksw.edu.pl'
| @var string
*/
'cas_hostname' => env('CAS_HOSTNAME', ''),
/*
|--------------------------------------------------------------------------
| CAS Port
|--------------------------------------------------------------------------
|
| Usually 443 is default
| @var integer
*/
'cas_port' => env('CAS_PORT', 443),
/*
|--------------------------------------------------------------------------
| CAS URI
|--------------------------------------------------------------------------
|
| Usually '/cas' is default
| @var string
*/
'cas_uri' => env('CAS_URI', '/cas'),
/*
|--------------------------------------------------------------------------
| CAS login URI
|--------------------------------------------------------------------------
|
| Empty is fine
| @var string
*/
'cas_login_uri' => env('CAS_LOGIN_URI', ''),
/*
|--------------------------------------------------------------------------
| CAS logout URI
|--------------------------------------------------------------------------
|
| Example: 'https://login.uksw.edu.pl/cas/logout?service='
| Empty is fine
| @var string
*/
'cas_logout_uri' => env('CAS_LOGOUT_URI', ''),
/*
|--------------------------------------------------------------------------
| CAS Validation
|--------------------------------------------------------------------------
|
| CAS server SSL validation: 'self' for self-signed certificate, 'ca' for
| certificate from a CA, empty for no SSL validation
| @var string
*/
'cas_validation' => env('CAS_VALIDATION', ''),
/*
|--------------------------------------------------------------------------
| CAS Certificate
|--------------------------------------------------------------------------
|
| Path to the CAS certificate file
| @var string
*/
'cas_cert' => env('CAS_CERT', ''),
/*
|--------------------------------------------------------------------------
| Use SAML to retrieve user attributes
|--------------------------------------------------------------------------
|
| CAS can be configured to return more than just the username to a given
| service. It could for example use an LDAP backend to return the first name,
| last name, and email of the user. This can be activated on the client side
| by setting 'cas_saml' to true
| @var boolean
*/
'cas_saml' => env('CAS_SAML', false),
/*
|--------------------------------------------------------------------------
| SAML group name attribute
|--------------------------------------------------------------------------
|
| If you are using SAML with LDAP backend you can simply check if logged
| user is member of specific group. Type below LDAP's group attribute
| name
| @var string
*/
'cas_saml_attr_groups' => env('CAS_SAML_ATTR_GROUPS', 'Groups'),
/*
|--------------------------------------------------------------------------
| CAS session name
|--------------------------------------------------------------------------
|
| Define your CAS session name
| @var string
*/
'cas_session_name' => env('CAS_SESSION_NAME', 'CAS_SESSION'),
],
namespace App\Http\Controllers;
use Caslite;
use Illuminate\Routing\Controller;
class AuthController extends Controller
{
// The Laravel AuthController might contain other methods and traits, please preserve them while editing
/**
* Redirect the user to the CAS authentication page.
*
* @return Response
*/
public function redirectToProvider()
{
return Caslite::authenticate();
}
/**
* Obtain the user information from CAS.
*
* @return Response
*/
public function handleProviderCallback()
{
$user = Caslite::user();
// $user->getEmail;
// here you can store the returned information in a local User model on your database (or storage).
// This is particularly usefull in case of profile construction with roles and other details
// e.g. Auth::login($local_user);
}
}