From 49d4b33575ac135eca408d2bca56a737563fe609 Mon Sep 17 00:00:00 2001 From: Aurel Branzeanu Date: Sat, 13 Aug 2016 01:25:46 +0300 Subject: [PATCH] Do not run Doorkeper's authorization method if oauth2 scope is set to 'false'. Particularily useful when using WineBouncer in the grape-swagger for hiding certain endpoints for different kind of users. In this case oauth2 'false' is set on the GET swagger_doc endpoint making the doorkeeper_access_token available further in the process of building API endpoints. --- lib/wine_bouncer/oauth2.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/wine_bouncer/oauth2.rb b/lib/wine_bouncer/oauth2.rb index b5b2292..c166ed4 100644 --- a/lib/wine_bouncer/oauth2.rb +++ b/lib/wine_bouncer/oauth2.rb @@ -89,7 +89,8 @@ def before context.protected_endpoint = endpoint_protected? return unless context.protected_endpoint? self.doorkeeper_request = env # set request for later use. - doorkeeper_authorize!(*auth_scopes) + scopes = auth_scopes + doorkeeper_authorize!(*scopes) unless scopes.include? :false context.doorkeeper_access_token = doorkeeper_token end