PHP code example of cornell-custom-dev / laravel-cu-auth

1. Go to this page and download the library: Download cornell-custom-dev/laravel-cu-auth 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/ */

    

cornell-custom-dev / laravel-cu-auth example snippets


// File: routes/web.php
use CornellCustomDev\LaravelStarterKit\CUAuth\Middleware\CUAuth;

Route::group(['middleware' => [CUAuth::class]], function () {
    // Protected routes here
    Route::get('profile', [UserController::class, 'show']);
});

use CornellCustomDev\LaravelStarterKit\CUAuth\Managers\IdentityManager;

$remoteIdentity = app(IdentityManager::class)->getIdentity();
$netid = $remoteIdentity->id(); // NetID | CWID

// If provided with SSO attributes:
$email = $remoteIdentity->email(); // Primary email (i.e. [email protected])
$name = $remoteIdentity->name(); // Display name

# File: config/cu-auth.php
'

// File: routes/web.php
use CornellCustomDev\LaravelStarterKit\CUAuth\Middleware\AppTesters;
use CornellCustomDev\LaravelStarterKit\CUAuth\Middleware\CUAuth;

Route::group(['middleware' => [CUAuth::class, AppTesters::class], function () {
    Route::get('profile', [UserController::class, 'show']);
});
bash
  php artisan cu-auth:generate-keys
json
"scripts": {
    "post-install-cmd": [
        "@php artisan cu-auth:generate-keys"
    ]
}
bash
  php artisan vendor:publish --tag=starterkit:cu-auth-config
bash
  php artisan vendor:publish --tag=starterkit:php-saml-toolkit-config