doorkeeper-jwt 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +1 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/doorkeeper-jwt.gemspec +1 -1
- data/lib/doorkeeper-jwt.rb +53 -31
- data/lib/doorkeeper-jwt/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a943aa0b9dc65189852d3ab4584371c3254c2ee1
|
4
|
+
data.tar.gz: 2a4f967cbef940a5d3fb5248b419d48adcdb324c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c15efeba186db245f32174ba86e8eec0e8939f7534d42e19cc05230a20ba9269994c17ecaab588d33cd32a6c77bab5386ec5146111d48430aa1443ce190403c8
|
7
|
+
data.tar.gz: bb1c0da134318b6787b6571ec9c34b269095c0a9f5421d3186ed24ce3ba6c27e6f6494be83dbcca8d90632bcafea06db852ae80311c863e252aa8141bbb6c5d9
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/doorkeeper-jwt.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "jwt", "~> 1.
|
22
|
+
spec.add_dependency "jwt", "~> 1.5.2", ">= 1.5.2"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.8", ">= 1.8"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0", ">= 10.0"
|
data/lib/doorkeeper-jwt.rb
CHANGED
@@ -4,44 +4,66 @@ require 'jwt'
|
|
4
4
|
|
5
5
|
module Doorkeeper
|
6
6
|
module JWT
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
class << self
|
8
|
+
def generate(opts = {})
|
9
|
+
::JWT.encode(
|
10
|
+
token_payload(opts),
|
11
|
+
secret_key,
|
12
|
+
encryption_method
|
13
|
+
)
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
+
private
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def token_payload(opts = {})
|
19
|
+
Doorkeeper::JWT.configuration.token_payload.call opts
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def secret_key
|
23
|
+
return secret_key_file unless secret_key_file.nil?
|
24
|
+
return rsa_key if rsa_encryption?
|
25
|
+
return ecdsa_key if ecdsa_encryption?
|
26
|
+
Doorkeeper::JWT.configuration.secret_key
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
29
|
+
def secret_key_file
|
30
|
+
return nil if Doorkeeper::JWT.configuration.secret_key_path.nil?
|
31
|
+
return rsa_key_file if rsa_encryption?
|
32
|
+
return ecdsa_key_file if ecdsa_encryption?
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def encryption_method
|
36
|
+
return nil unless Doorkeeper::JWT.configuration.encryption_method
|
37
|
+
Doorkeeper::JWT.configuration.encryption_method.to_s.upcase
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
def rsa_encryption?
|
41
|
+
/RS\d{3}/ =~ encryption_method
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
def ecdsa_encryption?
|
45
|
+
/ES\d{3}/ =~ encryption_method
|
46
|
+
end
|
47
|
+
|
48
|
+
def rsa_key
|
49
|
+
OpenSSL::PKey::RSA.new(Doorkeeper::JWT.configuration.secret_key)
|
50
|
+
end
|
51
|
+
|
52
|
+
def ecdsa_key
|
53
|
+
OpenSSL::PKey::EC.new(Doorkeeper::JWT.configuration.secret_key)
|
54
|
+
end
|
55
|
+
|
56
|
+
def rsa_key_file
|
57
|
+
OpenSSL::PKey::RSA.new(secret_key_file_open)
|
58
|
+
end
|
59
|
+
|
60
|
+
def ecdsa_key_file
|
61
|
+
OpenSSL::PKey::EC.new(secret_key_file_open)
|
62
|
+
end
|
63
|
+
|
64
|
+
def secret_key_file_open
|
65
|
+
File.open(Doorkeeper::JWT.configuration.secret_key_path)
|
66
|
+
end
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Warren
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.2
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.5.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.5.2
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.5.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|