clowk 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/clowk/authenticable.rb +6 -6
- data/lib/clowk/configuration.rb +7 -2
- data/lib/clowk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 28abd896caa982a35fa6efd1f1412ce35c65e16c097ae6bca4106f7947eb235b
|
|
4
|
+
data.tar.gz: 6f34617088b87ac8c7e7a1b9792e772a62134e78726ee750ec4dc878e87f5cf7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b35e25266da57b3c408ef66b3386d2fd85cc1c5aa6f0aafe9df0cac2b52e365b68dc79219f6f6857845043725e35b3e1c1939a37ee57d38206bc63fca7629d2
|
|
7
|
+
data.tar.gz: afc0e6ed3b78bcc9f7caed60cbda3131ad3869e141ed999a8588e95525ea52f8f5bea32624c2982e2d76a40206618d707978a8830f235b1a906bdc85271aa93e
|
data/README.md
CHANGED
|
@@ -277,9 +277,11 @@ Both ends — the broker said inactive, the ceiling passed — go through
|
|
|
277
277
|
Clowk writes the token to its own cookie, and — by default, as every version
|
|
278
278
|
before 0.9 did — mirrors a copy into the app's Rails session.
|
|
279
279
|
|
|
280
|
+
Both are cookies, so the setting names the owner rather than the mechanism:
|
|
281
|
+
|
|
280
282
|
```ruby
|
|
281
|
-
config.token_store = :
|
|
282
|
-
config.token_store = :
|
|
283
|
+
config.token_store = :clowk # Clowk's own cookie, and nowhere else
|
|
284
|
+
config.token_store = :app # also mirrored into the Rails session (the default)
|
|
283
285
|
```
|
|
284
286
|
|
|
285
287
|
The copy is not free. A Rails session lives in **one** cookie with about 4096
|
|
@@ -290,12 +292,12 @@ previous cookie simply stays. Everything written on that request goes with it: a
|
|
|
290
292
|
flash message, a selected tenant, a CSRF rotation. What a person sees is a button
|
|
291
293
|
that does nothing.
|
|
292
294
|
|
|
293
|
-
Under `:
|
|
295
|
+
Under `:clowk` the session keeps the claims and the sign-in time, nothing else.
|
|
294
296
|
`current_token` reads Clowk's cookie instead, which is where an API-only app has
|
|
295
297
|
always read it from. Sessions written before the switch are pruned on their next
|
|
296
298
|
request, so an app does not have to wait for everyone to sign out.
|
|
297
299
|
|
|
298
|
-
The default stays `:
|
|
300
|
+
The default stays `:app` so an upgrade changes nothing until you ask.
|
|
299
301
|
|
|
300
302
|
### Token verification
|
|
301
303
|
|
data/lib/clowk/authenticable.rb
CHANGED
|
@@ -97,8 +97,8 @@ module Clowk
|
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
# The session first, which holds a copy only under token_store :
|
|
101
|
-
# and, for one request after an app switches to :
|
|
100
|
+
# The session first, which holds a copy only under token_store :app —
|
|
101
|
+
# and, for one request after an app switches to :clowk, in a session
|
|
102
102
|
# written before the switch. drop_mirrored_token! clears those. Clowk's own
|
|
103
103
|
# cookie is the source either way.
|
|
104
104
|
def current_token
|
|
@@ -321,7 +321,7 @@ module Clowk
|
|
|
321
321
|
claims = {user: payload, signed_in_at: Time.now.to_i}
|
|
322
322
|
|
|
323
323
|
store[Clowk.config.session_key] =
|
|
324
|
-
(Clowk.config.token_store == :
|
|
324
|
+
(Clowk.config.token_store == :clowk) ? claims : claims.merge(token:)
|
|
325
325
|
|
|
326
326
|
clowk_cookie_jar&.[]=(Clowk.config.cookie_key, {
|
|
327
327
|
value: token,
|
|
@@ -331,13 +331,13 @@ module Clowk
|
|
|
331
331
|
})
|
|
332
332
|
end
|
|
333
333
|
|
|
334
|
-
# A session written under :
|
|
334
|
+
# A session written under :app still carries the token, and
|
|
335
335
|
# persist_clowk_session does not run again while that session stands — so
|
|
336
|
-
# without this, switching an app to :
|
|
336
|
+
# without this, switching an app to :clowk would shrink nothing until every
|
|
337
337
|
# person signed out and back in. Drops the copy once, on the first request
|
|
338
338
|
# after the switch.
|
|
339
339
|
def drop_mirrored_token!
|
|
340
|
-
return unless Clowk.config.token_store == :
|
|
340
|
+
return unless Clowk.config.token_store == :clowk
|
|
341
341
|
|
|
342
342
|
store = clowk_session_store
|
|
343
343
|
held = stored_session
|
data/lib/clowk/configuration.rb
CHANGED
|
@@ -66,7 +66,12 @@ module Clowk
|
|
|
66
66
|
# the next request; max_session_age is what bounds that.
|
|
67
67
|
@fail_open_on_broker_error = true
|
|
68
68
|
|
|
69
|
-
#
|
|
69
|
+
# Whose cookie keeps the token for the next request: :app or :clowk.
|
|
70
|
+
#
|
|
71
|
+
# Both are cookies — that is why the setting names the OWNER rather than
|
|
72
|
+
# the mechanism. :clowk is this gem's own cookie; :app is the Rails
|
|
73
|
+
# session, which is itself one cookie carrying everything the app puts in
|
|
74
|
+
# `session[...]`.
|
|
70
75
|
#
|
|
71
76
|
# Clowk's own cookie is written either way — it is what `current_token`
|
|
72
77
|
# reads when the session has none, and the only place an API-only app has
|
|
@@ -83,7 +88,7 @@ module Clowk
|
|
|
83
88
|
#
|
|
84
89
|
# :session stays the default so an upgrade changes nothing until an app
|
|
85
90
|
# asks for :cookie.
|
|
86
|
-
@token_store = :
|
|
91
|
+
@token_store = :app
|
|
87
92
|
end
|
|
88
93
|
|
|
89
94
|
# Where API-only apps cache session status, since they have no Rails session
|
data/lib/clowk/version.rb
CHANGED