mariovalney / laravel-keycloak-web-guard

Simple Keycloak Guard to Laravel Web Routes - https://packagist.org/packages/vizir/laravel-keycloak-web-guard
146 stars 80 forks source link

Gate integration #29

Closed gpedro closed 4 years ago

gpedro commented 4 years ago
// AuthServiceProvider@boot
Gate::before(function ($user, $ability) {
  return $user->hasRole($ability) ?: null;
});

// HomeController@admin
public function admin() {
  $this->authorize('superadmin');
  return response()->json([
     'result' => 'welcome superadmin'
  ]);
}

this allows better integration with the laravel eco-system and moves the custom middlewares to deprecation.


maybe we should add this in the documentation.

mariovalney commented 4 years ago

Thanks Pedro!

I'll check it to be added as enhancement.

mariovalney commented 4 years ago

Gate defined on 2.2.0