PHP code example of sti-bayern / sti-auth

1. Go to this page and download the library: Download sti-bayern/sti-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/ */

    

sti-bayern / sti-auth example snippets


// config/sti-auth.php

'local_user' => [
    // Geben Sie hier Ihr lokales Benutzermodell an.
    'model' => App\Models\User::class,

    // Der Name der Datenbanktabelle (optional, Standard ist 'users').
    'table' => 'users',

    // Mappen Sie hier die Attribute des Remote-Users auf Ihre lokalen Datenbankspalten.
    'sync_attributes' => [
        'id'    => 'id',
        'name'  => 'name',
        'email' => 'email',
        'login' => 'login',
    ],
],



namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'users'; // Muss mit dem Wert in config('sti-auth.local_user.table') übereinstimmen

    /**
     * Indicates if the model's ID is auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'id',
        'name',
        'email',
        'login',
    ];
}
 php
'guards' => [
    'web' => [
        'driver'   => 'remote',
        'provider' => 'remote-users',
    ],
],

'providers' => [
    'remote-users' => [
        'driver' => 'remote',
    ],
],
 php
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'auth.remote' => \Sti\StiAuth\Middleware\VerifyApiToken::class,
    ]);
})
 php
Route::middleware('auth.remote')->group(function () {
    Route::get('/', fn() => view('dashboard'));
});