Browse Source

Update config, make oauth opt-in

Daniel Supernault 6 years ago
parent
commit
bedb42baca
2 changed files with 17 additions and 13 deletions
  1. 15 13
      app/Providers/AuthServiceProvider.php
  2. 2 0
      config/pixelfed.php

+ 15 - 13
app/Providers/AuthServiceProvider.php

@@ -25,19 +25,21 @@ class AuthServiceProvider extends ServiceProvider
     {
         $this->registerPolicies();
 
-        Passport::routes();
-        Passport::tokensExpireIn(now()->addDays(15));
-        Passport::refreshTokensExpireIn(now()->addDays(30));
-        Passport::enableImplicitGrant();
-        
-        Passport::setDefaultScope([
-            'user:read',
-            'user:write'
-        ]);
+        if(config('pixelfed.oauth_enabled')) {
+            Passport::routes();
+            Passport::tokensExpireIn(now()->addDays(15));
+            Passport::refreshTokensExpireIn(now()->addDays(30));
+            Passport::enableImplicitGrant();
+            
+            Passport::setDefaultScope([
+                'user:read',
+                'user:write'
+            ]);
 
-        Passport::tokensCan([
-            'user:read' => 'Read a user’s profile info and media',
-            'user:write' => 'This scope lets an app "Change your profile information"',
-        ]);
+            Passport::tokensCan([
+                'user:read' => 'Read a user’s profile info and media',
+                'user:write' => 'This scope lets an app "Change your profile information"',
+            ]);
+        }
     }
 }

+ 2 - 0
config/pixelfed.php

@@ -276,4 +276,6 @@ return [
             ]
         ]
     ],
+
+    'oauth_enabled' => env('OAUTH_ENABLED', false),
 ];