summaryrefslogtreecommitdiff
path: root/lib/api/api_guard.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
committerToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
commit62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch)
treec3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/api/api_guard.rb
parentf6453eca992a9c142268e78ac782cef98110d183 (diff)
downloadgitlab-ce-tc-standard-gem.tar.gz
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I decided to try https://github.com/testdouble/standard on our codebase. It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/api/api_guard.rb')
-rw-r--r--lib/api/api_guard.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb
index af9b519ed9e..2deb50e287b 100644
--- a/lib/api/api_guard.rb
+++ b/lib/api/api_guard.rb
@@ -2,7 +2,7 @@
# Guard API with OAuth 2.0 Access Token
-require 'rack/oauth2'
+require "rack/oauth2"
module API
module APIGuard
@@ -10,7 +10,7 @@ module API
included do |base|
# OAuth2 Resource Server Authentication
- use Rack::OAuth2::Server::Resource::Bearer, 'The API' do |request|
+ use Rack::OAuth2::Server::Resource::Bearer, "The API" do |request|
# The authenticator only fetches the raw token string
# Must yield access token to store it in the env
@@ -95,7 +95,7 @@ module API
Gitlab::Auth::ExpiredError,
Gitlab::Auth::RevokedError,
Gitlab::Auth::ImpersonationDisabled,
- Gitlab::Auth::InsufficientScopeError]
+ Gitlab::Auth::InsufficientScopeError,]
base.__send__(:rescue_from, *error_classes, oauth2_bearer_token_error_handler) # rubocop:disable GitlabSecurity/PublicSend
end
@@ -110,22 +110,26 @@ module API
when Gitlab::Auth::TokenNotFoundError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Bad Access Token.")
+ "Bad Access Token."
+ )
when Gitlab::Auth::ExpiredError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token is expired. You can either do re-authorization or token refresh.")
+ "Token is expired. You can either do re-authorization or token refresh."
+ )
when Gitlab::Auth::RevokedError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token was revoked. You have to re-authorize from the user.")
+ "Token was revoked. You have to re-authorize from the user."
+ )
when Gitlab::Auth::ImpersonationDisabled
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token is an impersonation token but impersonation was disabled.")
+ "Token is an impersonation token but impersonation was disabled."
+ )
when Gitlab::Auth::InsufficientScopeError
# FIXME: ForbiddenError (inherited from Bearer::Forbidden of Rack::Oauth2)
@@ -133,7 +137,8 @@ module API
Rack::OAuth2::Server::Resource::Bearer::Forbidden.new(
:insufficient_scope,
Rack::OAuth2::Server::Resource::ErrorMethods::DEFAULT_DESCRIPTION[:insufficient_scope],
- { scope: e.scopes })
+ {scope: e.scopes}
+ )
end
response.finish