authrocket 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/authrocket.rb +1 -1
- data/lib/authrocket/api/api_config.rb +1 -1
- data/lib/authrocket/api/version.rb +1 -1
- data/lib/authrocket/jwt_key.rb +11 -0
- data/lib/authrocket/realm.rb +3 -1
- data/lib/authrocket/session.rb +13 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e2ae503388f1035ae5d360035105fd1c1c0162
|
4
|
+
data.tar.gz: 779c34257db659c28b824352e3275c0a9b152c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7a1981b30a3e9b8c841c1a8cb0becf1cf1fb3b1a5157703a946d49e2a845b8004e4832d06619bb3a690970a84070bd59b343ab8abaa8d21b1d1022d7e8e965
|
7
|
+
data.tar.gz: e99d4229fc89e8a6f516998004d72bc678a0554a02533b0a9db98a6ae8a09aae6bf48d6f3ffdc5e8235e76700d0e5133863aac1690e2a18ec1105c3d6ea1f25f
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,27 @@
|
|
1
|
+
#### 2.2.0
|
2
|
+
|
3
|
+
- Add Realm#jwt_algo
|
4
|
+
- Deprecate Realm#jwt_secret - replaced with Realm#jwt_key
|
5
|
+
- Add JwtKey resource
|
6
|
+
- Support RS256 signed tokens
|
7
|
+
|
1
8
|
#### 2.1.1
|
9
|
+
|
2
10
|
- Add Realm#jwt_fields
|
3
11
|
- Deprecate Realm#jwt_data - replaced by #jwt_fields
|
4
12
|
- Parse custom attributes from JWT when available
|
5
13
|
|
6
14
|
#### 2.1.0
|
15
|
+
|
7
16
|
- AuthProvider.authorize, #authorize_token can now return a UserToken
|
8
17
|
- Add UserToken#credential_type
|
9
18
|
|
10
19
|
#### 2.0.3
|
20
|
+
|
11
21
|
- Fix error handling for missing jwt_secret
|
12
22
|
|
13
23
|
#### 2.0.2
|
24
|
+
|
14
25
|
- Add Realm#resource_links
|
15
26
|
|
16
27
|
#### 2.0.1
|
data/lib/authrocket.rb
CHANGED
@@ -5,7 +5,7 @@ require 'jwt'
|
|
5
5
|
require "authrocket/api/#{f}"
|
6
6
|
end
|
7
7
|
|
8
|
-
%w(app_hook auth_provider credential event login_policy membership notification org realm session user user_token).each do |f|
|
8
|
+
%w(app_hook auth_provider credential event jwt_key login_policy membership notification org realm session user user_token).each do |f|
|
9
9
|
require "authrocket/#{f}"
|
10
10
|
end
|
11
11
|
|
data/lib/authrocket/realm.rb
CHANGED
@@ -5,6 +5,7 @@ module AuthRocket
|
|
5
5
|
has_many :app_hooks
|
6
6
|
has_many :auth_providers
|
7
7
|
has_many :events
|
8
|
+
has_many :jwt_keys
|
8
9
|
has_many :login_policies
|
9
10
|
has_many :orgs
|
10
11
|
has_many :users
|
@@ -12,7 +13,8 @@ module AuthRocket
|
|
12
13
|
attr :api_key_minutes, :api_key_policy, :api_key_prefix, :custom, :name
|
13
14
|
attr :jwt_fields, :require_unique_emails, :resource_links, :session_minutes
|
14
15
|
attr :session_type, :state, :username_validation_human
|
15
|
-
attr :
|
16
|
+
attr :jwt_key # readonly
|
17
|
+
attr :jwt_secret # readonly, deprecated
|
16
18
|
attr :jwt_data # deprecated
|
17
19
|
|
18
20
|
|
data/lib/authrocket/session.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'jwt'
|
3
|
+
|
1
4
|
module AuthRocket
|
2
5
|
class Session < Resource
|
3
6
|
crud :all, :find, :create, :delete
|
@@ -13,12 +16,21 @@ module AuthRocket
|
|
13
16
|
|
14
17
|
|
15
18
|
# options - :within - (in seconds) Maximum time since the token was originally issued
|
19
|
+
# - credentials: {jwt_secret: StringOrKey} - used to verify the token
|
20
|
+
# - :algo - one of HS256, RS256 (default: auto-detect based on :jwt_secret)
|
16
21
|
def self.from_token(token, options={})
|
17
22
|
secret = (options[:credentials]||credentials||{})[:jwt_secret]
|
18
23
|
raise Error, "missing :jwt_secret (or AUTHROCKET_JWT_SECRET)" unless secret
|
19
24
|
return unless token
|
20
25
|
|
21
|
-
|
26
|
+
algo = options[:algo]
|
27
|
+
if secret.is_a?(String) && secret.length > 256
|
28
|
+
secret = OpenSSL::PKey.read secret
|
29
|
+
end
|
30
|
+
algo ||= 'RS256' if secret.is_a?(OpenSSL::PKey::RSA)
|
31
|
+
algo ||= 'HS256'
|
32
|
+
|
33
|
+
jwt, _ = JWT.decode token, secret, true, algorithm: algo
|
22
34
|
|
23
35
|
if within = options.delete(:within)
|
24
36
|
return if jwt['iat'] < Time.now.to_i - within
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authrocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AuthRocket Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ncore
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/authrocket/auth_provider.rb
|
91
91
|
- lib/authrocket/credential.rb
|
92
92
|
- lib/authrocket/event.rb
|
93
|
+
- lib/authrocket/jwt_key.rb
|
93
94
|
- lib/authrocket/login_policy.rb
|
94
95
|
- lib/authrocket/membership.rb
|
95
96
|
- lib/authrocket/notification.rb
|
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
121
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.6.10
|
122
123
|
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: AuthRocket client for Ruby
|