AuthServiceProvider.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Providers;
  3. use Gate;
  4. use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
  5. use Laravel\Passport\Passport;
  6. use App\Models\CustomFilter;
  7. use App\Policies\CustomFilterPolicy;
  8. class AuthServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * The policy mappings for the application.
  12. *
  13. * @var array
  14. */
  15. protected $policies = [
  16. CustomFilter::class => CustomFilterPolicy::class,
  17. ];
  18. /**
  19. * Register any authentication / authorization services.
  20. *
  21. * @return void
  22. */
  23. public function boot()
  24. {
  25. if(config('pixelfed.oauth_enabled') == true) {
  26. Passport::ignoreRoutes();
  27. Passport::tokensExpireIn(now()->addDays(config('instance.oauth.token_expiration', 356)));
  28. Passport::refreshTokensExpireIn(now()->addDays(config('instance.oauth.refresh_expiration', 400)));
  29. Passport::enableImplicitGrant();
  30. if (config('instance.oauth.pat.enabled')) {
  31. Passport::personalAccessClientId(config('instance.oauth.pat.id'));
  32. }
  33. Passport::tokensCan([
  34. 'read' => 'Full read access to your account',
  35. 'write' => 'Full write access to your account',
  36. 'follow' => 'Ability to follow other profiles',
  37. 'admin:read' => 'Read all data on the server',
  38. 'admin:read:domain_blocks' => 'Read sensitive information of all domain blocks',
  39. 'admin:write' => 'Modify all data on the server',
  40. 'admin:write:domain_blocks' => 'Perform moderation actions on domain blocks',
  41. 'push' => 'Receive your push notifications'
  42. ]);
  43. Passport::setDefaultScope([
  44. 'read',
  45. 'write',
  46. 'follow',
  47. ]);
  48. }
  49. // Gate::define('viewWebSocketsDashboard', function ($user = null) {
  50. // return $user->is_admin;
  51. // });
  52. }
  53. }