authrocket 3.1.0 → 3.4.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 +23 -0
- data/LICENSE +1 -1
- data/README.md +64 -2
- data/authrocket.gemspec +1 -1
- data/lib/authrocket/api/railtie.rb +9 -0
- data/lib/authrocket/api/version.rb +1 -1
- data/lib/authrocket/auth_provider.rb +1 -1
- data/lib/authrocket/connection.rb +3 -2
- data/lib/authrocket/hook.rb +4 -1
- data/lib/authrocket/hook_state.rb +26 -0
- data/lib/authrocket/invitation.rb +1 -1
- data/lib/authrocket/realm.rb +1 -0
- data/lib/authrocket/user.rb +2 -1
- data/lib/authrocket.rb +1 -0
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1081c944badcc582e41e1b6a2c490b7b36797072ce37c4c0d4ff95cff70c9a37
|
4
|
+
data.tar.gz: c3fb78aa005891773187d5dd3494b51746566b180c99358d41ec48fa9e46a6ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ae02ef915333191bc493a141c6ef9fa452184028cfb528ade5b264aa7323adb1a3d13d457566766b628246b892e19a2fa7587edefe57938f884f0da972ed15
|
7
|
+
data.tar.gz: 86634dae4a53d8dca492b409782c45a096db901adeee0ef5012ea7405782cf0ab6d9258a99c4ec6ba0514c405a8500b31991a9666e9e3a7aef55959982cfd4d3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
#### 3.4.0
|
2
|
+
|
3
|
+
- Document how to change locales
|
4
|
+
- Self-configure rescue_responses when using Rails
|
5
|
+
- Add request caching
|
6
|
+
|
7
|
+
#### 3.3.0
|
8
|
+
|
9
|
+
- Update Invitation, Hook, Realm, User
|
10
|
+
|
11
|
+
#### 3.2.1
|
12
|
+
|
13
|
+
- Update AuthProvider
|
14
|
+
|
15
|
+
#### 3.2.0
|
16
|
+
|
17
|
+
- Add HookState
|
18
|
+
- Update Connection, Hook
|
19
|
+
|
1
20
|
#### 3.1.0
|
2
21
|
|
3
22
|
- Automatically handle login tokens in an Authorization header
|
@@ -24,6 +43,10 @@
|
|
24
43
|
- <exception>#errors is now an ActiveModel::Errors for all applicable exceptions
|
25
44
|
- Require Ruby >= 2.3
|
26
45
|
|
46
|
+
#### 2.4.1
|
47
|
+
|
48
|
+
- Require ncore 2.2.2+
|
49
|
+
|
27
50
|
#### 2.4.0
|
28
51
|
|
29
52
|
- Add Rails Engine for expedited setup
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -159,7 +159,7 @@ This default path may be changed using an initializer. Create/edit `config/initi
|
|
159
159
|
|
160
160
|
##### /logout route
|
161
161
|
|
162
|
-
The default route for logout is `/logout`. To
|
162
|
+
The default route for logout is `/logout`. To override it, add an initializer for AuthRocket (eg: `config/initializers/authrocket.rb`) and add:
|
163
163
|
|
164
164
|
AuthRocket::Api.use_default_routes = false
|
165
165
|
|
@@ -206,11 +206,13 @@ AuthRocket's login tokens use the JWT standard and are cryptographically signed.
|
|
206
206
|
AuthRocket also supports Managed Sessions, which enables you to enforce logouts, even across apps (single sign-out!). In this instance, the session is regularly verified using the AuthRocket API.
|
207
207
|
|
208
208
|
def current_user
|
209
|
-
@_current_user ||= AuthRocket::Session.retrieve(session[:ar_token])&.user
|
209
|
+
@_current_user ||= AuthRocket::Session.retrieve(session[:ar_token], cache: {expires_in: 15.minutes})&.user
|
210
210
|
end
|
211
211
|
|
212
212
|
For better performance (and to avoid API rate limits), you will want to cache the results of the API call for 3-15 minutes.
|
213
213
|
|
214
|
+
If not using Rails/ActiveSupport, use seconds: `cache: {expires_in: 15*60}` and also configure the cache store, as explained in Caching below. If using Rails, make sure Rails.cache is configured.
|
215
|
+
|
214
216
|
|
215
217
|
#### Initial login
|
216
218
|
|
@@ -229,6 +231,66 @@ Each of the above are designed for ongoing use. The initial login isn't going to
|
|
229
231
|
|
230
232
|
|
231
233
|
|
234
|
+
## Changing locales
|
235
|
+
|
236
|
+
The AuthRocket Core API supports multi-locale access. See the AuthRocket docs for the currently supported locales.
|
237
|
+
|
238
|
+
If you are using the streamlined Rails integration alongside LoginRocket, it may not be necessary to set the locale for API access. The locale is primarily used for generating localized error messages. This is only useful for API operations that might generate errors. When handling logins and signups via LoginRocket, LoginRocket will handle all of this for you.
|
239
|
+
|
240
|
+
When the Accept-Language header is not sent, the AuthRocket Core API uses English.
|
241
|
+
|
242
|
+
|
243
|
+
#### Global locale
|
244
|
+
|
245
|
+
To set a global locale for your app, add this to your AuthRocket initializer:
|
246
|
+
|
247
|
+
AuthRocket::Api.default_headers.merge!(
|
248
|
+
accept_language: 'en'
|
249
|
+
)
|
250
|
+
|
251
|
+
|
252
|
+
#### Per-request locale
|
253
|
+
|
254
|
+
If your app supports multiple locales, then you'll likely want to set the locale on a per-request basis. Add a `headers: {accept_language: 'en'}` param to relevant API calls:
|
255
|
+
|
256
|
+
AuthRocket::User.create(
|
257
|
+
email: 'jdoe@example.com',
|
258
|
+
password: 'secret!',
|
259
|
+
headers: {accept_language: 'en'}
|
260
|
+
)
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
## Caching
|
265
|
+
|
266
|
+
The AuthRocket gem is capable of caching the results of GET requests. Since authentication and user data generally needs to be timely, this is opt-in on a per-request basis. The most common use is when validating sessions via the API.
|
267
|
+
|
268
|
+
To enable caching, a cache store must be configured. On Rails, `authrocket` automatically uses Rails.cache, so simply ensure that's setup appropriately.
|
269
|
+
|
270
|
+
If not using Rails (or if you with to use a different cache store even when using Rails), add this to your AuthRocket initializer:
|
271
|
+
|
272
|
+
cache_options = {} # app specific
|
273
|
+
AuthRocket::Api.cache_store = RedisCacheStore.new(cache_options)
|
274
|
+
|
275
|
+
Any Rails-compatible cache store should work.
|
276
|
+
|
277
|
+
Next, enable the cache for specific API calls:
|
278
|
+
|
279
|
+
# To avoid caching for too long, it's recommended to set a specific expiration time.
|
280
|
+
AuthRocket::Session.retrieve(token, cache: {expires_in: 5.minutes})
|
281
|
+
|
282
|
+
# However, it's possible to leave out :expires_in and use the cache store's default.
|
283
|
+
# Warning: Ensure the cache store has a default expiration, otherwise cache entries
|
284
|
+
# will last forever!
|
285
|
+
AuthRocket::Session.retrieve(token, cache: {}) # These are identical
|
286
|
+
AuthRocket::Session.retrieve(token, cache: true)
|
287
|
+
|
288
|
+
# All options in cache: {...} are passed directly to the cache store, so anything
|
289
|
+
# supported by your cache store is valid.
|
290
|
+
AuthRocket::Session.retrieve(token, cache: {expires_in: 15.minutes, force: true})
|
291
|
+
|
292
|
+
|
293
|
+
|
232
294
|
## Reference
|
233
295
|
|
234
296
|
For full details on the AuthRocket API, including examples for Ruby, see our [documentation](https://authrocket.com/docs).
|
data/authrocket.gemspec
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module AuthRocket
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
|
4
|
+
config.action_dispatch.rescue_responses.merge!(
|
5
|
+
'AuthRocket::RecordInvalid' => :unprocessable_entity, # 422
|
6
|
+
'AuthRocket::RecordNotFound' => :not_found, # 404
|
7
|
+
)
|
8
|
+
|
9
|
+
initializer "authrocket.cache_store" do |app|
|
10
|
+
AuthRocket::Api.cache_store = Rails.cache
|
11
|
+
end
|
12
|
+
|
4
13
|
initializer "authrocket.log_runtime" do |app|
|
5
14
|
require 'authrocket/api/log_subscriber'
|
6
15
|
ActiveSupport.on_load(:action_controller) do
|
@@ -5,7 +5,7 @@ module AuthRocket
|
|
5
5
|
belongs_to :realm
|
6
6
|
|
7
7
|
attr :name, :provider_type, :state
|
8
|
-
attr :min_complexity, :min_length
|
8
|
+
attr :min_complexity, :min_length, :required_chars
|
9
9
|
attr :client_id, :client_secret, :scopes
|
10
10
|
attr :loginrocket_domain
|
11
11
|
attr :authorization_url, :profile_url, :token_url
|
@@ -4,9 +4,10 @@ module AuthRocket
|
|
4
4
|
|
5
5
|
belongs_to :realm
|
6
6
|
|
7
|
-
attr :connection_type
|
8
|
-
attr :email_from, :email_from_name
|
7
|
+
attr :connection_name, :connection_type, :state
|
8
|
+
attr :email_from, :email_from_name
|
9
9
|
attr :smtp_host, :smtp_password, :smtp_port, :smtp_user
|
10
|
+
attr :api_endpoint, :provider_account, :valid_list_ids
|
10
11
|
|
11
12
|
end
|
12
13
|
end
|
data/lib/authrocket/hook.rb
CHANGED
@@ -3,10 +3,13 @@ module AuthRocket
|
|
3
3
|
crud :all, :find, :create, :update, :delete
|
4
4
|
|
5
5
|
belongs_to :realm
|
6
|
+
belongs_to :connection
|
6
7
|
|
7
8
|
attr :accumulate, :delay, :event_type, :hook_type, :state
|
8
9
|
attr :destination
|
9
|
-
attr :
|
10
|
+
attr :email_renderers, :email_subjects, :email_templates, :email_to, :locales
|
11
|
+
attr :current_locales # readonly
|
12
|
+
attr :description, :list_id, :name, :on_create, :visibility
|
10
13
|
|
11
14
|
|
12
15
|
def self.event_types
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module AuthRocket
|
2
|
+
class HookState < Resource
|
3
|
+
crud :all, :find, :create, :update, :delete
|
4
|
+
|
5
|
+
belongs_to :hook
|
6
|
+
belongs_to :user
|
7
|
+
|
8
|
+
attr :hook_state_type
|
9
|
+
attr :list_state
|
10
|
+
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def create(attribs={})
|
15
|
+
if self[:user_id]
|
16
|
+
if attribs.key? json_root
|
17
|
+
attribs[json_root][:user_id] ||= self[:user_id]
|
18
|
+
else
|
19
|
+
attribs[:user_id] ||= self[:user_id]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
super attribs
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/authrocket/realm.rb
CHANGED
@@ -16,6 +16,7 @@ module AuthRocket
|
|
16
16
|
has_many :users
|
17
17
|
|
18
18
|
attr :custom, :environment, :name, :public_name, :state
|
19
|
+
attr :available_locales, :default_locale
|
19
20
|
attr :email_verification, :org_mode, :signup
|
20
21
|
attr :name_field, :org_name_field, :password_field, :username_field
|
21
22
|
attr :branding, :color_1, :logo, :logo_icon, :privacy_policy, :stylesheet, :terms_of_service
|
data/lib/authrocket/user.rb
CHANGED
@@ -5,10 +5,11 @@ module AuthRocket
|
|
5
5
|
belongs_to :realm
|
6
6
|
has_many :credentials
|
7
7
|
has_many :events
|
8
|
+
has_many :hook_states
|
8
9
|
has_many :memberships
|
9
10
|
has_many :sessions
|
10
11
|
|
11
|
-
attr :custom, :email, :email_verification, :first_name, :last_name, :name
|
12
|
+
attr :custom, :email, :email_verification, :first_name, :last_name, :locale, :name
|
12
13
|
attr :reference, :state, :username
|
13
14
|
attr :password, :password_confirmation # writeonly
|
14
15
|
attr_datetime :created_at, :last_login_at
|
data/lib/authrocket.rb
CHANGED
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: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AuthRocket Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/authrocket/domain.rb
|
111
111
|
- lib/authrocket/event.rb
|
112
112
|
- lib/authrocket/hook.rb
|
113
|
+
- lib/authrocket/hook_state.rb
|
113
114
|
- lib/authrocket/invitation.rb
|
114
115
|
- lib/authrocket/jwt_key.rb
|
115
116
|
- lib/authrocket/membership.rb
|
@@ -129,7 +130,7 @@ homepage: https://authrocket.com/
|
|
129
130
|
licenses:
|
130
131
|
- MIT
|
131
132
|
metadata: {}
|
132
|
-
post_install_message:
|
133
|
+
post_install_message:
|
133
134
|
rdoc_options: []
|
134
135
|
require_paths:
|
135
136
|
- lib
|
@@ -144,8 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
145
|
- !ruby/object:Gem::Version
|
145
146
|
version: '0'
|
146
147
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
148
|
+
rubygems_version: 3.2.22
|
149
|
+
signing_key:
|
149
150
|
specification_version: 4
|
150
151
|
summary: AuthRocket client for Ruby
|
151
152
|
test_files: []
|