Skip to content

Commit 8694aa9

Browse files
author
nov
committed
goodbye ruby 1.8
1 parent c02f89a commit 8694aa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+268
-268
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ task :spec do
1616
Rake::Task[:'coverage:report'].invoke unless ENV['TRAVIS_RUBY_VERSION']
1717
end
1818

19-
task :default => :spec
19+
task default: :spec

lib/rack/oauth2.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def self.debug(&block)
4242

4343
def self.http_client(agent_name = "Rack::OAuth2 (#{VERSION})", &local_http_config)
4444
_http_client_ = HTTPClient.new(
45-
:agent_name => agent_name
45+
agent_name: agent_name
4646
)
4747
http_config.try(:call, _http_client_)
4848
local_http_config.try(:call, _http_client_) unless local_http_config.nil?

lib/rack/oauth2/access_token.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class AccessToken
44
include AttrRequired, AttrOptional
55
attr_required :access_token, :token_type, :httpclient
66
attr_optional :refresh_token, :expires_in, :scope
7-
delegate :get, :post, :put, :delete, :to => :httpclient
7+
delegate :get, :post, :put, :delete, to: :httpclient
88

99
alias_method :to_s, :access_token
1010

@@ -21,11 +21,11 @@ def initialize(attributes = {})
2121

2222
def token_response(options = {})
2323
{
24-
:access_token => access_token,
25-
:refresh_token => refresh_token,
26-
:token_type => token_type,
27-
:expires_in => expires_in,
28-
:scope => Array(scope).join(' ')
24+
access_token: access_token,
25+
refresh_token: refresh_token,
26+
token_type: token_type,
27+
expires_in: expires_in,
28+
scope: Array(scope).join(' ')
2929
}
3030
end
3131
end
@@ -35,4 +35,4 @@ def token_response(options = {})
3535
require 'rack/oauth2/access_token/authenticator'
3636
require 'rack/oauth2/access_token/bearer'
3737
require 'rack/oauth2/access_token/mac'
38-
require 'rack/oauth2/access_token/legacy'
38+
require 'rack/oauth2/access_token/legacy'

lib/rack/oauth2/access_token/mac.rb

+26-26
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ def initialize(attributes = {})
1414

1515
def token_response
1616
super.merge(
17-
:mac_key => mac_key,
18-
:mac_algorithm => mac_algorithm
17+
mac_key: mac_key,
18+
mac_algorithm: mac_algorithm
1919
)
2020
end
2121

22-
def verify!(request)
22+
def verify!(request)
2323
if self.ext_verifier.present?
2424
body = request.body.read
2525
request.body.rewind # for future use
2626

2727
self.ext_verifier.new(
28-
:raw_body => body,
29-
:algorithm => self.mac_algorithm
28+
raw_body: body,
29+
algorithm: self.mac_algorithm
3030
).verify!(request.ext)
3131
end
3232

3333
now = Time.now.utc.to_i
3434
now = @ts.to_i if @ts.present?
35-
35+
3636
raise Rack::OAuth2::AccessToken::MAC::Verifier::VerificationFailed.new("Request ts expired") if now - request.ts.to_i > @ts_expires_in.to_i
3737

3838
Signature.new(
39-
:secret => self.mac_key,
40-
:algorithm => self.mac_algorithm,
41-
:nonce => request.nonce,
42-
:method => request.request_method,
43-
:request_uri => request.fullpath,
44-
:host => request.host,
45-
:port => request.port,
46-
:ts => request.ts,
47-
:ext => request.ext
39+
secret: self.mac_key,
40+
algorithm: self.mac_algorithm,
41+
nonce: request.nonce,
42+
method: request.request_method,
43+
request_uri: request.fullpath,
44+
host: request.host,
45+
port: request.port,
46+
ts: request.ts,
47+
ext: request.ext
4848
).verify!(request.signature)
4949
rescue Verifier::VerificationFailed => e
5050
request.invalid_token! e.message
@@ -56,21 +56,21 @@ def authenticate(request)
5656

5757
if self.ext_verifier.present?
5858
@ext = self.ext_verifier.new(
59-
:raw_body => request.body,
60-
:algorithm => self.mac_algorithm
59+
raw_body: request.body,
60+
algorithm: self.mac_algorithm
6161
).calculate
6262
end
6363

6464
@signature = Signature.new(
65-
:secret => self.mac_key,
66-
:algorithm => self.mac_algorithm,
67-
:nonce => self.nonce,
68-
:method => request.header.request_method,
69-
:request_uri => request.header.create_query_uri,
70-
:host => request.header.request_uri.host,
71-
:port => request.header.request_uri.port,
72-
:ts => @ts_generated,
73-
:ext => @ext
65+
secret: self.mac_key,
66+
algorithm: self.mac_algorithm,
67+
nonce: self.nonce,
68+
method: request.header.request_method,
69+
request_uri: request.header.create_query_uri,
70+
host: request.header.request_uri.host,
71+
port: request.header.request_uri.port,
72+
ts: @ts_generated,
73+
ext: @ext
7474
).calculate
7575

7676
request.header['Authorization'] = authorization_header

lib/rack/oauth2/access_token/mac/verifier.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def hash_generator
4141
end
4242
end
4343
end
44-
end
44+
end

lib/rack/oauth2/client.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ def authorization_uri(params = {})
2020
params[:response_type] = Array(params[:response_type]).join(' ')
2121
params[:scope] = Array(params[:scope]).join(' ')
2222
Util.redirect_uri absolute_uri_for(authorization_endpoint), :query, params.merge(
23-
:client_id => self.identifier,
24-
:redirect_uri => self.redirect_uri
23+
client_id: self.identifier,
24+
redirect_uri: self.redirect_uri
2525
)
2626
end
2727

2828
def authorization_code=(code)
2929
@grant = Grant::AuthorizationCode.new(
30-
:code => code,
31-
:redirect_uri => self.redirect_uri
30+
code: code,
31+
redirect_uri: self.redirect_uri
3232
)
3333
end
3434

3535
def resource_owner_credentials=(credentials)
3636
@grant = Grant::Password.new(
37-
:username => credentials.first,
38-
:password => credentials.last
37+
username: credentials.first,
38+
password: credentials.last
3939
)
4040
end
4141

4242
def refresh_token=(token)
4343
@grant = Grant::RefreshToken.new(
44-
:refresh_token => token
44+
refresh_token: token
4545
)
4646
end
4747

@@ -64,8 +64,8 @@ def access_token!(*args)
6464
)
6565
else
6666
params.merge!(
67-
:client_id => identifier,
68-
:client_secret => secret
67+
client_id: identifier,
68+
client_secret: secret
6969
)
7070
end
7171
handle_response do
@@ -119,7 +119,7 @@ def handle_error_response(response)
119119
error = parse_json response.body
120120
raise Error.new(response.status, error)
121121
rescue MultiJson::DecodeError
122-
raise Error.new(response.status, :error => 'Unknown', :error_description => response.body)
122+
raise Error.new(response.status, error: 'Unknown', error_description: response.body)
123123
end
124124

125125
def parse_json(raw_json)

lib/rack/oauth2/client/grant.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(attributes = {})
1313

1414
def as_json(options = {})
1515
(required_attributes + optional_attributes).inject({
16-
:grant_type => self.class.name.demodulize.underscore.to_sym
16+
grant_type: self.class.name.demodulize.underscore.to_sym
1717
}) do |hash, key|
1818
hash.merge! key => self.send(key)
1919
end
@@ -26,4 +26,4 @@ def as_json(options = {})
2626
require 'rack/oauth2/client/grant/authorization_code'
2727
require 'rack/oauth2/client/grant/password'
2828
require 'rack/oauth2/client/grant/client_credentials'
29-
require 'rack/oauth2/client/grant/refresh_token'
29+
require 'rack/oauth2/client/grant/refresh_token'

lib/rack/oauth2/server/abstract/error.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def initialize(status, error, description = nil, options = {})
1616

1717
def protocol_params
1818
{
19-
:error => error,
20-
:error_description => description,
21-
:error_uri => uri
19+
error: error,
20+
error_description: description,
21+
error_uri: uri
2222
}
2323
end
2424

@@ -66,4 +66,4 @@ def initialize(error = :forbidden, description = nil, options = {})
6666
end
6767
end
6868
end
69-
end
69+
end

lib/rack/oauth2/server/abstract/request.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def attr_missing_with_error_handling!
1919
end
2020
attr_missing_without_error_handling!
2121
rescue AttrRequired::AttrMissing => e
22-
invalid_request! e.message, :state => @state, :redirect_uri => @redirect_uri
22+
invalid_request! e.message, state: @state, redirect_uri: @redirect_uri
2323
end
2424
alias_method_chain :attr_missing!, :error_handling
2525
end
2626
end
2727
end
2828
end
29-
end
29+
end

lib/rack/oauth2/server/authorize.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def approve!
9191
end
9292

9393
def protocol_params
94-
{:state => state}
94+
{state: state}
9595
end
9696

9797
def redirect_uri_with_credentials
@@ -114,4 +114,4 @@ def finish
114114
require 'rack/oauth2/server/authorize/code'
115115
require 'rack/oauth2/server/authorize/token'
116116
require 'rack/oauth2/server/authorize/extension'
117-
require 'rack/oauth2/server/authorize/error'
117+
require 'rack/oauth2/server/authorize/error'

lib/rack/oauth2/server/authorize/code.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Response < Authorize::Response
2525
attr_required :code
2626

2727
def protocol_params
28-
super.merge(:code => code)
28+
super.merge(code: code)
2929
end
3030

3131
def protocol_params_location
@@ -36,4 +36,4 @@ def protocol_params_location
3636
end
3737
end
3838
end
39-
end
39+
end

lib/rack/oauth2/server/authorize/error.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def self.included(klass)
88
end
99

1010
def protocol_params
11-
super.merge(:state => state)
11+
super.merge(state: state)
1212
end
1313

1414
def finish
@@ -36,13 +36,13 @@ class TemporarilyUnavailable < Abstract::TemporarilyUnavailable
3636

3737
module ErrorMethods
3838
DEFAULT_DESCRIPTION = {
39-
:invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, or is otherwise malformed.",
40-
:unauthorized_client => "The client is not authorized to use the requested response type.",
41-
:access_denied => "The end-user or authorization server denied the request.",
42-
:unsupported_response_type => "The requested response type is not supported by the authorization server.",
43-
:invalid_scope => "The requested scope is invalid, unknown, or malformed.",
44-
:server_error => "Internal Server Error",
45-
:temporarily_unavailable => "Service Unavailable"
39+
invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, or is otherwise malformed.",
40+
unauthorized_client: "The client is not authorized to use the requested response type.",
41+
access_denied: "The end-user or authorization server denied the request.",
42+
unsupported_response_type: "The requested response type is not supported by the authorization server.",
43+
invalid_scope: "The requested scope is invalid, unknown, or malformed.",
44+
server_error: "Internal Server Error",
45+
temporarily_unavailable: "Service Unavailable"
4646
}
4747

4848
def self.included(klass)
@@ -87,4 +87,4 @@ def error!(klass, error, description, options)
8787
end
8888
end
8989
end
90-
end
90+
end

lib/rack/oauth2/server/authorize/extension/code_and_token.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class Response < Authorize::Token::Response
2828
attr_required :code
2929

3030
def protocol_params
31-
super.merge(:code => code)
31+
super.merge(code: code)
3232
end
3333
end
3434
end
3535
end
3636
end
3737
end
3838
end
39-
end
39+
end

lib/rack/oauth2/server/resource.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def oauth2?
5252

5353
require 'rack/oauth2/server/resource/error'
5454
require 'rack/oauth2/server/resource/bearer'
55-
require 'rack/oauth2/server/resource/mac'
55+
require 'rack/oauth2/server/resource/mac'

lib/rack/oauth2/server/resource/error.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def initialize(error = :forbidden, description = nil, options = {})
3232
end
3333

3434
def protocol_params
35-
super.merge(:scope => Array(scope).join(' '))
35+
super.merge(scope: Array(scope).join(' '))
3636
end
3737
end
3838

3939
module ErrorMethods
4040
DEFAULT_DESCRIPTION = {
41-
:invalid_request => "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.",
42-
:invalid_token => "The access token provided is expired, revoked, malformed or invalid for other reasons.",
43-
:insufficient_scope => "The request requires higher privileges than provided by the access token."
41+
invalid_request: "The request is missing a required parameter, includes an unsupported parameter or parameter value, repeats the same parameter, uses more than one method for including an access token, or is otherwise malformed.",
42+
invalid_token: "The access token provided is expired, revoked, malformed or invalid for other reasons.",
43+
insufficient_scope: "The request requires higher privileges than provided by the access token."
4444
}
4545

4646
def self.included(klass)
@@ -78,4 +78,4 @@ def forbidden!(error, description = nil, options = {})
7878
end
7979
end
8080
end
81-
end
81+
end

lib/rack/oauth2/server/token.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ def finish
8181
require 'rack/oauth2/server/token/client_credentials'
8282
require 'rack/oauth2/server/token/refresh_token'
8383
require 'rack/oauth2/server/token/extension'
84-
require 'rack/oauth2/server/token/error'
84+
require 'rack/oauth2/server/token/error'

0 commit comments

Comments
 (0)