clowk 0.7.0 → 0.8.0
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 +9 -6
- data/lib/clowk/authenticable.rb +12 -17
- 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: b8925255001baaeae3fb7507651c4fa65ba8ccb24358a593c191f5e3a0070b2a
|
|
4
|
+
data.tar.gz: f6acd810ff58c1410c67c8b78c4db705966fa8643d39fef2673da25816c006c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d61ceac58f3444d2cf6cf0af582d595a115c0971048ad7a2e979611cc45a4020bbc1a3689fccf33144ccc3d28bbc7cfbc32cb1bd870de94f43cede1289cd9aea
|
|
7
|
+
data.tar.gz: 538f167b4d02d928f9cd231fadbbb8e8a7639b2648903e5f46da1414b058b376e5dd9ce926ab47cbb1fbc1aeacbdce748d5ef8bb6d24ea8c6ec00fd90f941685
|
data/README.md
CHANGED
|
@@ -239,15 +239,18 @@ those actions and they get a live one:
|
|
|
239
239
|
|
|
240
240
|
```ruby
|
|
241
241
|
class ApiKeysController < ApplicationController
|
|
242
|
-
|
|
242
|
+
before_action :clowk_enforce_fresh_session!, only: [:create, :update, :destroy]
|
|
243
243
|
end
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
cached check, so an app pays for the round trip on
|
|
248
|
-
undo and nowhere else.
|
|
249
|
-
|
|
250
|
-
|
|
246
|
+
An ordinary `before_action`, so the filter options you already know all work.
|
|
247
|
+
Everything not named keeps the cached check, so an app pays for the round trip on
|
|
248
|
+
the few actions it cannot undo and nowhere else.
|
|
249
|
+
|
|
250
|
+
Under a configured `prefix_by` the method is named for the scope, like every
|
|
251
|
+
other one here — `clowk_user_enforce_fresh_session!` beside
|
|
252
|
+
`clowk_user_enforce_session!`. And `clowk_session_active?(force: true)` returns
|
|
253
|
+
the answer instead of enforcing it.
|
|
251
254
|
|
|
252
255
|
Two settings decide what happens when Clowk itself cannot be reached:
|
|
253
256
|
|
data/lib/clowk/authenticable.rb
CHANGED
|
@@ -67,22 +67,6 @@ module Clowk
|
|
|
67
67
|
Clowk::Authenticable.install_dynamic_methods(self)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
class_methods do
|
|
71
|
-
# Demand a live answer from Clowk before these actions, whatever a cached
|
|
72
|
-
# status says.
|
|
73
|
-
#
|
|
74
|
-
# class ApiKeysController < ApplicationController
|
|
75
|
-
# clowk_require_fresh_session only: [:create, :update, :destroy]
|
|
76
|
-
# end
|
|
77
|
-
#
|
|
78
|
-
# Takes the same options as before_action. Everything NOT listed keeps the
|
|
79
|
-
# cached check, which is the point: an app pays for a round trip on the few
|
|
80
|
-
# actions that cannot be undone, and nowhere else.
|
|
81
|
-
def clowk_require_fresh_session(**options)
|
|
82
|
-
before_action(**options) { clowk_enforce_fresh_session! }
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
70
|
# Per-request credentials — for apps whose keys are not a boot constant:
|
|
87
71
|
# an operator pastes a publishable key into a settings screen, or one
|
|
88
72
|
# process serves several tenants.
|
|
@@ -143,7 +127,10 @@ module Clowk
|
|
|
143
127
|
# rotating a secret, deleting an account, removing a member. Everything else
|
|
144
128
|
# should take the cached check — this is a round trip, on purpose.
|
|
145
129
|
#
|
|
146
|
-
#
|
|
130
|
+
# before_action :clowk_enforce_fresh_session!, only: [:destroy]
|
|
131
|
+
#
|
|
132
|
+
# Under a configured prefix_by it is named for the scope, like every other
|
|
133
|
+
# method here: `clowk_user_enforce_fresh_session!`.
|
|
147
134
|
#
|
|
148
135
|
# Before 0.7 the only way to get this was `session_status_ttl = 0`, which
|
|
149
136
|
# bought freshness here by paying a round trip on every page instead.
|
|
@@ -153,6 +140,14 @@ module Clowk
|
|
|
153
140
|
|
|
154
141
|
# @param force [Boolean] see {#clowk_session_status}
|
|
155
142
|
def clowk_enforce_session!(force: false)
|
|
143
|
+
# Nothing to enforce against a request that carries no session. Reached
|
|
144
|
+
# through clowk_authenticate! this is already true, but the method is also
|
|
145
|
+
# a before_action in its own right — and called that way with no session it
|
|
146
|
+
# read "not active" and ended one that never existed. On a page that skips
|
|
147
|
+
# the identity gate on purpose (an invite link, a public page that shows
|
|
148
|
+
# more when signed in) that threw away whatever the redirect was carrying.
|
|
149
|
+
return unless clowk_signed_in?
|
|
150
|
+
|
|
156
151
|
return clowk_expire_session!(nil) if clowk_session_beyond_max_age?
|
|
157
152
|
return if clowk_session_active?(force: force)
|
|
158
153
|
|
data/lib/clowk/version.rb
CHANGED