PHP code example of taufik-t / uauth-rest-client

1. Go to this page and download the library: Download taufik-t/uauth-rest-client 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/ */

    

taufik-t / uauth-rest-client example snippets


'api' => [
    'base_url' => env('UAUTH_API_BASE_URL', null),
    'ssl_verify' => env('UAUTH_API_SSL_VERIFY', true),
    'timeout' => env('UAUTH_API_TIMEOUT', 30),
    'connect_timeout' => env('UAUTH_API_CONNECT_TIMEOUT', 10),
    'provider_id' => env('UAUTH_API_PROVIDER_ID', null),
  ],



namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
  /**
   * The trusted proxies for this application.
   *
   * @var array<int, string>|string|null
   */
  protected $proxies;

  /**
   * The headers that should be used to detect proxies.
   *
   * @var int
   */
  protected $headers =
  Request::HEADER_X_FORWARDED_FOR |
    Request::HEADER_X_FORWARDED_HOST |
    Request::HEADER_X_FORWARDED_PORT |
    Request::HEADER_X_FORWARDED_PROTO |
    Request::HEADER_X_FORWARDED_AWS_ELB;

  // add this line
  public function __construct()
  {
    $this->proxies = config('uauth.proxies');
  }
}

Route::group(['middleware' => ['sso.api']], function () {
    // tempatkan route resource yang ingin di proteksi disini
});

public function boot(): void
{
  $this->routes(function () {
    Route::middleware('api') // hapus default middleware
      ->prefix('api')
      ->group(base_path('routes/api.php'));

      // menjadi

    Route::prefix('api')
      ->group(base_path('routes/api.php'));
  })
}