rack-oauth2 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c9ef17a769a22815156fa9a794447925496fe4c
4
- data.tar.gz: d613d947f2a001b1c5b172919a7c118e678e4682
3
+ metadata.gz: 8a2df927b2cd7727df348e6e2c2d2822382bb207
4
+ data.tar.gz: 0cbd438ae8f7be634556bdf320721142e6ff497d
5
5
  SHA512:
6
- metadata.gz: ec69d172bb0cfaa870990b0752c4488cd006328b5ccc8dddb282034a49b7915a6c0e3658340ff59c7fce17f2cab95ba61de25403682cc9704dc6587acaf312b2
7
- data.tar.gz: 74a77e9be5eb7e8778e0c7b077eb22a2fc72555d2a076fdf9dde3c4c7f18f5c87e5594db54d7316de69f8b03770a5132b918f105b2eb3c323e022d1a6de9b774
6
+ metadata.gz: 6498b5c59d3bc2ccdbe0b651956872185c3e89023c59fb1f609c8d1cc2012d0a1df926146d5d3579431d6fd5ed95498214b34fa67d8bacf7911f5d327ddb26b4
7
+ data.tar.gz: 57fafb111c251219dc32f95abb3523448e8852868873eea00e72c7bd7ba63f90750ebb69abffca6676f1eaf978101e6a883c179a55c4ebda2ad4db86a4f23b85
@@ -2,7 +2,6 @@ before_install:
2
2
  - gem install bundler
3
3
 
4
4
  rvm:
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- - 2.3.0
5
+ - 2.2.2
6
+ - 2.2.5
7
+ - 2.3.1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.4.0
@@ -1,4 +1,5 @@
1
1
  require 'rack/oauth2/server/abstract'
2
+ require 'rack/oauth2/server/extension'
2
3
  require 'rack/oauth2/server/authorize'
3
4
  require 'rack/oauth2/server/token'
4
5
  require 'rack/oauth2/server/resource'
@@ -10,6 +10,8 @@ module Rack
10
10
  end
11
11
 
12
12
  class Request < Authorize::Request
13
+ include Server::Extension::PKCE::AuthorizationRequest
14
+
13
15
  def initialize(env)
14
16
  super
15
17
  @response_type = :code
@@ -17,6 +17,8 @@ module Rack
17
17
  end
18
18
 
19
19
  class Request < Authorize::Token::Request
20
+ include Server::Extension::PKCE::AuthorizationRequest
21
+
20
22
  def initialize(env)
21
23
  super
22
24
  @response_type = [:code, :token]
@@ -0,0 +1 @@
1
+ require 'rack/oauth2/server/extension/pkce'
@@ -0,0 +1,47 @@
1
+ module Rack
2
+ module OAuth2
3
+ module Server
4
+ module Extension
5
+ module PKCE
6
+ module AuthorizationRequest
7
+ def self.included(klass)
8
+ klass.send :attr_optional, :code_challenge, :code_challenge_method
9
+ end
10
+
11
+ def initialize(env)
12
+ super
13
+ @code_challenge = params['code_challenge']
14
+ @code_challenge_method = params['code_challenge_method']
15
+ end
16
+ end
17
+
18
+ module TokenRequest
19
+ def self.included(klass)
20
+ klass.send :attr_optional, :code_verifier
21
+ end
22
+
23
+ def initialize(env)
24
+ super
25
+ @code_verifier = params['code_verifier']
26
+ end
27
+
28
+ def verify_code_verifier!(code_challenge, code_challenge_method = :S256)
29
+ if code_verifier.present? || code_challenge.present?
30
+ case code_challenge_method.try(:to_sym)
31
+ when :S256
32
+ code_challenge == Util.urlsafe_base64_encode(
33
+ OpenSSL::Digest::SHA256.digest(code_verifier.to_s)
34
+ ) or invalid_grant!
35
+ when :plain
36
+ code_challenge == code_verifier or invalid_grant!
37
+ else
38
+ invalid_grant!
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -10,6 +10,8 @@ module Rack
10
10
  end
11
11
 
12
12
  class Request < Token::Request
13
+ include Server::Extension::PKCE::TokenRequest
14
+
13
15
  attr_required :code
14
16
  attr_optional :redirect_uri
15
17
 
@@ -9,7 +9,11 @@ module Rack
9
9
  end
10
10
 
11
11
  def base64_encode(text)
12
- Base64.encode64(text).gsub(/\n/, '')
12
+ Base64.encode64(text).delete("\n")
13
+ end
14
+
15
+ def urlsafe_base64_encode(text)
16
+ Base64.urlsafe_encode64(text).delete('=')
13
17
  end
14
18
 
15
19
  def compact_hash(hash)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-16 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -201,6 +201,8 @@ files:
201
201
  - lib/rack/oauth2/server/authorize/extension.rb
202
202
  - lib/rack/oauth2/server/authorize/extension/code_and_token.rb
203
203
  - lib/rack/oauth2/server/authorize/token.rb
204
+ - lib/rack/oauth2/server/extension.rb
205
+ - lib/rack/oauth2/server/extension/pkce.rb
204
206
  - lib/rack/oauth2/server/rails.rb
205
207
  - lib/rack/oauth2/server/rails/authorize.rb
206
208
  - lib/rack/oauth2/server/rails/response_ext.rb