Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Make ccache check safer (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGodbehere authored Jan 26, 2024
1 parent 118d933 commit d41732d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/Support/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use AMRCFactoryPlus\ServiceClient;
use App\Exceptions\ReauthenticationRequiredException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -22,18 +20,16 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{

$this->app->singletonIf(ServiceClient::class, function (Application $app) {

$ccache = new \KRB5CCache;

// If the user is logged in then get their ccache
// and use that for all future requests
$ccache->open("FILE:/app/storage/".auth()->user()->username . '.ccache');

// If the ccache has expired then re-authenticate by ending the session
// and showing the login modal
try {
// If the user is logged in then get their ccache
// and use that for all future requests
$ccache->open("FILE:/app/storage/" . auth()->user()->username . '.ccache');

$ccache->isValid();
} catch (\Exception $e) {
// Throw a 'ReauthenticationRequiredException' to show the login dialog
Expand Down

0 comments on commit d41732d

Please sign in to comment.