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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25c9714d9a8a39ba10d25bce51b378d643bb2a86
4
- data.tar.gz: f6590ea8aed5079f41ddfe62d17c0095188efffb
3
+ metadata.gz: d4e2ae503388f1035ae5d360035105fd1c1c0162
4
+ data.tar.gz: 779c34257db659c28b824352e3275c0a9b152c32
5
5
  SHA512:
6
- metadata.gz: ca3ea43ae527d665af2ffd02ade85e8dac33d895a9d879fa425f13a6b6d0399819c06ea99368189601d7fd80155393d32ddf730788142be2d1b3ab6afe6a4783
7
- data.tar.gz: 00183ddbe8d5b9d65da316118da31618dfa57892aa993ba7930470495d08a4d03d66a4b5219bc2807068667072ab67940c9bee667e90a3a6ac591ad0b818a1ba
6
+ metadata.gz: 9c7a1981b30a3e9b8c841c1a8cb0becf1cf1fb3b1a5157703a946d49e2a845b8004e4832d06619bb3a690970a84070bd59b343ab8abaa8d21b1d1022d7e8e965
7
+ data.tar.gz: e99d4229fc89e8a6f516998004d72bc678a0554a02533b0a9db98a6ae8a09aae6bf48d6f3ffdc5e8235e76700d0e5133863aac1690e2a18ec1105c3d6ea1f25f
@@ -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
@@ -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
 
@@ -30,7 +30,7 @@ module AuthRocket
30
30
 
31
31
  self.instrument_key = 'request.authrocket'
32
32
 
33
- self.status_page = 'http://status.notioneer.com/'
33
+ self.status_page = 'http://status.authrocket.com/'
34
34
 
35
35
  self.auth_header_prefix = 'X-Authrocket'
36
36
 
@@ -1,3 +1,3 @@
1
1
  module AuthRocket
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -0,0 +1,11 @@
1
+ module AuthRocket
2
+ class JwtKey < Resource
3
+ crud :all, :find, :create, :delete
4
+
5
+ belongs_to :realm
6
+
7
+ attr :algo, :key, :use
8
+ attr :expired # readonly
9
+
10
+ end
11
+ end
@@ -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 :jwt_secret # readonly
16
+ attr :jwt_key # readonly
17
+ attr :jwt_secret # readonly, deprecated
16
18
  attr :jwt_data # deprecated
17
19
 
18
20
 
@@ -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
- jwt, _ = JWT.decode token, secret, true, algorithm: 'HS256'
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.1.1
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-01-07 00:00:00.000000000 Z
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.4.8
122
+ rubygems_version: 2.6.10
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: AuthRocket client for Ruby