studio-engine 0.135.2 → 0.137.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/CHANGELOG.md +64 -11
- data/README.md +10 -0
- data/app/assets/javascripts/studio/cropper-1.6.2.min.js +10 -0
- data/app/assets/javascripts/studio/page_transition_reveal.js +3 -0
- data/app/assets/stylesheets/studio/cropper-1.6.2.min.css +9 -0
- data/app/controllers/concerns/studio/connection_flow.rb +215 -0
- data/app/controllers/concerns/studio/error_handling.rb +58 -1
- data/app/controllers/studio/connections_controller.rb +13 -0
- data/app/helpers/studio/page_header_helper.rb +26 -0
- data/app/helpers/studio_navbar_helper.rb +22 -0
- data/app/javascript/studio/application.js +1 -0
- data/app/javascript/studio/cropper.js +2 -2
- data/app/javascript/studio/page_header_self_styled.js +194 -0
- data/app/javascript/studio/page_transitions.js +42 -11
- data/app/javascript/studio/reload_visits.js +93 -0
- data/app/models/studio/connection.rb +137 -0
- data/app/models/studio/user_session.rb +216 -21
- data/app/views/layouts/_navbar.html.erb +11 -4
- data/app/views/studio/_cropper_assets.html.erb +14 -9
- data/app/views/studio/_legal_page.html.erb +52 -0
- data/app/views/studio/_page_header.html.erb +12 -2
- data/app/views/studio/page_header/_assets.html.erb +151 -0
- data/db/migrate/20261108120000_add_device_revocation_to_studio_user_sessions.rb +28 -0
- data/db/migrate/20261108130000_create_studio_connections.rb +35 -0
- data/lib/generators/studio/connections/connections_generator.rb +93 -0
- data/lib/studio/connections/stand_in.rb +89 -0
- data/lib/studio/connections.rb +483 -0
- data/lib/studio/engine.rb +14 -1
- data/lib/studio/host_schema.rb +53 -2
- data/lib/studio/page_header.rb +11 -2
- data/lib/studio/version.rb +1 -1
- data/lib/studio.rb +70 -0
- metadata +16 -1
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
3
5
|
module Studio
|
|
4
6
|
# One signed-in browser session: who, whether they were an admin, when it
|
|
5
7
|
# started and when it was last seen. It is a cached record for the app's own
|
|
6
8
|
# dashboard, kept on purpose without an IP, a user agent or a path.
|
|
7
9
|
#
|
|
8
10
|
# A new row starts after IDLE without a request. An open row is written at most
|
|
9
|
-
# once per THROTTLE, and the cookie remembers when
|
|
10
|
-
#
|
|
11
|
+
# once per THROTTLE, and the cookie remembers when.
|
|
12
|
+
#
|
|
13
|
+
# A DEVICE SESSION YOU CAN END (docs/DEVICE_SESSIONS.md). The cookie store keeps
|
|
14
|
+
# the whole session in the browser, so a logout used to delete only the
|
|
15
|
+
# browser's copy: a copy of the pre-logout cookie still signed in. Each signed-in
|
|
16
|
+
# cookie now carries a random `sid` in its mark, and every row of that device
|
|
17
|
+
# session carries the same sid. A logout stamps `revoked_at` on those rows, and
|
|
18
|
+
# every signed-in request reads its sid's rows (one indexed query): a revoked
|
|
19
|
+
# row ends the sid for good, and so does no row at all: the request is signed
|
|
20
|
+
# out. Other devices have other sids, so they stay signed in.
|
|
11
21
|
#
|
|
12
|
-
# Nil-safe, because the table
|
|
13
|
-
#
|
|
22
|
+
# Nil-safe, because the table and its columns come from migrations the host
|
|
23
|
+
# runs: an app without them records nothing, checks nothing and serves as
|
|
24
|
+
# before.
|
|
14
25
|
class UserSession < ApplicationRecord
|
|
15
26
|
self.table_name = "studio_user_sessions"
|
|
16
27
|
|
|
17
28
|
IDLE = 30.minutes
|
|
18
29
|
THROTTLE = 5.minutes
|
|
30
|
+
# A device session idle this long has its rows pruned, so its cookie no longer
|
|
31
|
+
# signs in: the user signs in again.
|
|
32
|
+
RETENTION = 90.days
|
|
33
|
+
PRUNE_EVERY = 1.hour
|
|
34
|
+
PRUNE_BATCH = 1_000
|
|
35
|
+
# A failed verdict writes at most one ErrorLog row per this window per
|
|
36
|
+
# process: a database fault fails every request, and the log must not add a
|
|
37
|
+
# write to each of them.
|
|
38
|
+
CHECK_FAILURE_LOG_EVERY = 5.minutes
|
|
19
39
|
|
|
20
40
|
belongs_to :user, class_name: "::User", optional: true
|
|
21
41
|
|
|
@@ -27,50 +47,225 @@ module Studio
|
|
|
27
47
|
def self.cookie_key = :"#{Studio.session_key}_session_mark"
|
|
28
48
|
|
|
29
49
|
# Off under test unless a test asks: the row a first request writes would count in
|
|
30
|
-
|
|
31
50
|
# every host's query-budget test, which measures the page and not this.
|
|
32
|
-
|
|
33
51
|
cattr_accessor :record_in_test, default: false
|
|
34
52
|
|
|
53
|
+
# A signed-in cookie with no sid predates this change. Until this moment it is
|
|
54
|
+
# accepted and given a sid on its request, so the deploy signs nobody out;
|
|
55
|
+
# after it, such a cookie is signed out once. The bound matters: a copy of a
|
|
56
|
+
# pre-deploy cookie carries no sid, so without it that copy would stay
|
|
57
|
+
# replayable after the device logs out.
|
|
58
|
+
cattr_accessor :legacy_grace_until, default: Time.utc(2026, 12, 8)
|
|
35
59
|
|
|
36
|
-
|
|
60
|
+
# When this process last pruned (prune_due!). Per process, so it costs nothing.
|
|
61
|
+
cattr_accessor :pruned_at, default: nil
|
|
37
62
|
|
|
38
|
-
|
|
63
|
+
# When this process last wrote an ErrorLog row for a failed verdict
|
|
64
|
+
# (log_check_failure). Per process, like pruned_at.
|
|
65
|
+
cattr_accessor :check_failure_logged_at, default: nil
|
|
39
66
|
|
|
67
|
+
def self.recording?
|
|
68
|
+
!Rails.env.test? || record_in_test
|
|
40
69
|
end
|
|
41
70
|
|
|
42
|
-
|
|
43
71
|
def self.available?
|
|
44
72
|
connection.data_source_exists?(table_name)
|
|
45
73
|
rescue ActiveRecord::ActiveRecordError, NoMethodError
|
|
46
74
|
false
|
|
47
75
|
end
|
|
48
76
|
|
|
77
|
+
# The table carries the sid and revoked_at columns. The schema cache and the
|
|
78
|
+
# model's column cache answer it, so a request pays no query for it.
|
|
79
|
+
def self.revocable?
|
|
80
|
+
return false unless connection.schema_cache.data_source_exists?(table_name)
|
|
81
|
+
|
|
82
|
+
names = column_names
|
|
83
|
+
names.include?("sid") && names.include?("revoked_at")
|
|
84
|
+
rescue ActiveRecord::ActiveRecordError, NoMethodError
|
|
85
|
+
false
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# This app's mark in `store` (the session, or a plain Hash decoded from the
|
|
89
|
+
# cookie, as a cable connection reads it), as a string-keyed Hash.
|
|
90
|
+
def self.mark_in(store)
|
|
91
|
+
mark = store[cookie_key]
|
|
92
|
+
mark = store[cookie_key.to_s] if mark.nil? && store.is_a?(Hash)
|
|
93
|
+
mark.respond_to?(:to_h) ? mark.to_h.transform_keys(&:to_s) : {}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.new_sid = SecureRandom.urlsafe_base64(24)
|
|
97
|
+
|
|
98
|
+
# The verdict on a signed-in request, read before anything else runs. Answers
|
|
99
|
+
# [verdict, row]:
|
|
100
|
+
#
|
|
101
|
+
# :live the sid names a row that is not revoked (row is that row)
|
|
102
|
+
# :ended any row of the sid is revoked, or the sid has no row (pruned,
|
|
103
|
+
# or never written); also a sid-less cookie past legacy_grace_until
|
|
104
|
+
# :legacy no sid, inside the grace: accepted, and track gives it one
|
|
105
|
+
# :off nothing to check (not recording, or no columns)
|
|
106
|
+
#
|
|
107
|
+
# One indexed query when the cookie carries a sid, none otherwise. A failure
|
|
108
|
+
# answers :off, so a database fault signs nobody out: the request's own user
|
|
109
|
+
# lookup needs the same database, and a copied cookie cannot cause the fault.
|
|
110
|
+
def self.verdict(store, now: Time.current)
|
|
111
|
+
return [:off, nil] unless recording? && revocable?
|
|
112
|
+
|
|
113
|
+
sid = mark_in(store)["sid"].presence
|
|
114
|
+
return [now < legacy_grace_until ? :legacy : :ended, nil] unless sid
|
|
115
|
+
|
|
116
|
+
# A revoked row sorts first: a row a request in flight wrote after the
|
|
117
|
+
# logout cannot bring the sid back.
|
|
118
|
+
row = where(sid: sid.to_s).order(Arel.sql("revoked_at IS NULL"), id: :desc).first
|
|
119
|
+
return [:ended, nil] if row.nil? || row.revoked_at
|
|
120
|
+
|
|
121
|
+
[:live, row]
|
|
122
|
+
rescue StandardError => e
|
|
123
|
+
Rails.logger&.warn("[user_session] verdict #{e.class}: #{e.message}")
|
|
124
|
+
log_check_failure(e, now)
|
|
125
|
+
[:off, nil]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# True when `store` names an ended device session (verdict :ended). The one
|
|
129
|
+
# check a host's ApplicationCable::Connection makes, since /cable reads the
|
|
130
|
+
# cookie outside the controller filter (docs/DEVICE_SESSIONS.md):
|
|
131
|
+
#
|
|
132
|
+
# return nil if Studio::UserSession.respond_to?(:ended?) && Studio::UserSession.ended?(session)
|
|
133
|
+
#
|
|
134
|
+
# `store` is request.session or the Hash decoded from the cookie. :legacy and
|
|
135
|
+
# :off answer false, as they do for a page request. It never writes `store`.
|
|
136
|
+
def self.ended?(store, now: Time.current)
|
|
137
|
+
verdict(store, now: now).first == :ended
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Writes the verdict's failure to ErrorLog, at most once per
|
|
141
|
+
# CHECK_FAILURE_LOG_EVERY per process. The stamp is set before the write, so a
|
|
142
|
+
# write that fails too (the database is down) is not retried on every request.
|
|
143
|
+
# Never raises.
|
|
144
|
+
def self.log_check_failure(exception, now = Time.current)
|
|
145
|
+
return if check_failure_logged_at && check_failure_logged_at > now - CHECK_FAILURE_LOG_EVERY
|
|
146
|
+
|
|
147
|
+
self.check_failure_logged_at = now
|
|
148
|
+
::ErrorLog.capture!(exception) if defined?(::ErrorLog) && ::ErrorLog.respond_to?(:capture!)
|
|
149
|
+
rescue StandardError => e
|
|
150
|
+
Rails.logger&.warn("[user_session] check failure not logged: #{e.class}: #{e.message}")
|
|
151
|
+
nil
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Starts this device's session at a sign-in (ErrorHandling#set_app_session):
|
|
155
|
+
# writes its first row with a new sid and marks `store`, so the very next
|
|
156
|
+
# request is checked. A sign-in by the same user over a live sid keeps it: a
|
|
157
|
+
# re-auth is the same device session. The sid is read again first (one indexed
|
|
158
|
+
# query): a revoked sid, or one with no row, is never reused, so a sign-in on
|
|
159
|
+
# a copied cookie cannot bring an ended session back. A different user gets a
|
|
160
|
+
# new sid; the old one is not revoked, since a sign-in is not a logout. Answers
|
|
161
|
+
# the row, or nil. It raises on a failed write, so the caller can log it.
|
|
162
|
+
def self.start!(store, user, now: Time.current)
|
|
163
|
+
return unless user && recording? && revocable?
|
|
164
|
+
|
|
165
|
+
mark = mark_in(store)
|
|
166
|
+
return if mark["user"] == user.id && live_sid?(mark["sid"], user)
|
|
167
|
+
|
|
168
|
+
admin = user.respond_to?(:admin?) && user.admin?
|
|
169
|
+
row = create!(sid: new_sid, user_id: user.id, admin: admin ? true : false, started_at: now, last_seen_at: now)
|
|
170
|
+
store[cookie_key] = { "id" => row.id, "user" => user.id, "at" => now.to_i, "sid" => row.sid }
|
|
171
|
+
prune_due!(now)
|
|
172
|
+
row
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Ends this device's session: stamps revoked_at on every row of its sid and
|
|
176
|
+
# drops the mark from `store`. Other sids (other devices, and other apps on a
|
|
177
|
+
# shared cookie) are untouched. Answers the rows it revoked. It raises on a
|
|
178
|
+
# failed write, so the caller can log it (ErrorHandling#end_device_session).
|
|
179
|
+
def self.revoke!(store, now: Time.current)
|
|
180
|
+
sid = mark_in(store)["sid"].presence
|
|
181
|
+
store.delete(cookie_key)
|
|
182
|
+
return 0 unless sid && recording? && revocable?
|
|
183
|
+
|
|
184
|
+
where(sid: sid.to_s, revoked_at: nil).update_all(revoked_at: now, updated_at: now)
|
|
185
|
+
end
|
|
186
|
+
|
|
49
187
|
# Records this request for `user`, reading and writing `store` (the session).
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
|
|
188
|
+
# `row` is the row verdict read for this request, so tracking adds no read of
|
|
189
|
+
# its own. Answers the row it wrote, or nil. Never raises: a request must not
|
|
190
|
+
# fail because its bookkeeping did.
|
|
191
|
+
def self.track(store, user, now: Time.current, row: nil)
|
|
53
192
|
return if user.nil? || !recording?
|
|
54
193
|
|
|
55
|
-
mark = store
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
194
|
+
mark = mark_in(store)
|
|
195
|
+
same_user = mark["user"] == user.id
|
|
196
|
+
seen = same_user && mark["at"] ? Time.zone.at(mark["at"].to_i) : nil
|
|
197
|
+
revocable = revocable?
|
|
198
|
+
sid = same_user ? mark["sid"].presence : nil
|
|
199
|
+
# A sid-less cookie does not wait out the throttle: it gets its sid now.
|
|
200
|
+
return if seen && seen > now - THROTTLE && (sid || !revocable)
|
|
60
201
|
return unless available?
|
|
61
202
|
|
|
62
|
-
row =
|
|
203
|
+
row = revocable && sid ? row_for_sid(sid, user, now, row) : legacy_row(mark, same_user, seen, user, now, revocable)
|
|
63
204
|
if row
|
|
64
|
-
|
|
205
|
+
changes = { last_seen_at: now }
|
|
206
|
+
changes[:sid] = sid = new_sid if revocable && sid.nil?
|
|
207
|
+
row.update_columns(changes)
|
|
65
208
|
else
|
|
209
|
+
sid ||= new_sid if revocable
|
|
66
210
|
admin = user.respond_to?(:admin?) && user.admin?
|
|
67
|
-
|
|
211
|
+
attrs = { user_id: user.id, admin: admin ? true : false, started_at: now, last_seen_at: now }
|
|
212
|
+
attrs[:sid] = sid if revocable
|
|
213
|
+
row = create!(attrs)
|
|
214
|
+
prune_due!(now)
|
|
68
215
|
end
|
|
69
|
-
store[cookie_key] = { "id" => row.id, "user" => user.id, "at" => now.to_i }
|
|
216
|
+
store[cookie_key] = { "id" => row.id, "user" => user.id, "at" => now.to_i }.tap { |m| m["sid"] = sid if revocable }
|
|
70
217
|
row
|
|
71
218
|
rescue StandardError => e
|
|
72
219
|
Rails.logger&.warn("[user_session] #{e.class}: #{e.message}")
|
|
73
220
|
nil
|
|
74
221
|
end
|
|
222
|
+
|
|
223
|
+
# True when `sid` has rows, all of them unrevoked, and the latest is `user`'s.
|
|
224
|
+
# One query on the sid index; a revoked row sorts first, as in verdict.
|
|
225
|
+
def self.live_sid?(sid, user)
|
|
226
|
+
return false if sid.blank?
|
|
227
|
+
|
|
228
|
+
row = where(sid: sid.to_s).order(Arel.sql("revoked_at IS NULL"), id: :desc).first
|
|
229
|
+
!row.nil? && row.revoked_at.nil? && row.user_id == user.id
|
|
230
|
+
end
|
|
231
|
+
private_class_method :live_sid?
|
|
232
|
+
|
|
233
|
+
# The open row to move for this sid: the one verdict read, else the latest by
|
|
234
|
+
# sid. Past IDLE nil, so a new row starts with the same sid.
|
|
235
|
+
def self.row_for_sid(sid, user, now, row)
|
|
236
|
+
row = nil unless row && row.sid == sid
|
|
237
|
+
row ||= where(sid: sid).order(id: :desc).first
|
|
238
|
+
row if row && row.user_id == user.id && row.revoked_at.nil? && row.last_seen_at > now - IDLE
|
|
239
|
+
end
|
|
240
|
+
private_class_method :row_for_sid
|
|
241
|
+
|
|
242
|
+
# The row a sid-less mark names (a cookie from before sids, or before this
|
|
243
|
+
# app's columns), inside IDLE. Under sids only a row with no sid of its own
|
|
244
|
+
# qualifies: it takes the cookie's new sid.
|
|
245
|
+
def self.legacy_row(mark, same_user, seen, user, now, revocable)
|
|
246
|
+
return unless same_user && seen && seen > now - IDLE
|
|
247
|
+
|
|
248
|
+
row = find_by(id: mark["id"], user_id: user.id)
|
|
249
|
+
row unless revocable && row&.sid.present?
|
|
250
|
+
end
|
|
251
|
+
private_class_method :legacy_row
|
|
252
|
+
|
|
253
|
+
# Deletes up to `batch` rows last seen before `before`. One statement on the
|
|
254
|
+
# last_seen_at index.
|
|
255
|
+
def self.prune!(now: Time.current, before: now - RETENTION, batch: PRUNE_BATCH)
|
|
256
|
+
where(id: where(arel_table[:last_seen_at].lt(before)).order(:id).limit(batch).select(:id)).delete_all
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Prunes at most once per PRUNE_EVERY per process, from the moment a row is
|
|
260
|
+
# created (a sign-in or a return after IDLE), so no host has to schedule a job.
|
|
261
|
+
def self.prune_due!(now = Time.current)
|
|
262
|
+
return if pruned_at && pruned_at > now - PRUNE_EVERY
|
|
263
|
+
|
|
264
|
+
self.pruned_at = now
|
|
265
|
+
prune!(now: now)
|
|
266
|
+
rescue StandardError => e
|
|
267
|
+
Rails.logger&.warn("[user_session] prune #{e.class}: #{e.message}")
|
|
268
|
+
nil
|
|
269
|
+
end
|
|
75
270
|
end
|
|
76
271
|
end
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
does. extra_icons_slot is rendered here, so the link
|
|
12
12
|
sidebar's trigger still follows it; like the user nav,
|
|
13
13
|
a slot wins over its legacy _html string.
|
|
14
|
-
brand_heading — boolean, draw the brand title as the page's h1
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
brand_heading — boolean, draw the brand title as the page's h1. Default:
|
|
15
|
+
the engine decides. The brand is the h1 unless the page
|
|
16
|
+
has its own (studio_page_has_h1?: studio/_page_header
|
|
17
|
+
recorded one, or the page body holds an h1 tag); then it
|
|
18
|
+
is a div with the same classes and contents. A preview
|
|
19
|
+
keeps the h1. Pass true or false and it wins.
|
|
17
20
|
%>
|
|
18
21
|
<% show_user = local_assigns.fetch(:show_logged_in, logged_in?) %>
|
|
19
22
|
<% is_preview = local_assigns.fetch(:preview, false) %>
|
|
@@ -35,7 +38,11 @@
|
|
|
35
38
|
<% if extra_icons_slot.present? %>
|
|
36
39
|
<% extra_icons_html = extra_icons_slot.is_a?(Hash) ? render(extra_icons_slot[:partial], **extra_icons_slot.fetch(:locals, {})) : render(extra_icons_slot.to_s) %>
|
|
37
40
|
<% end %>
|
|
38
|
-
|
|
41
|
+
<%# One h1 per page: the brand is the h1 only where the page has none of its own.
|
|
42
|
+
The class (.nav-title, or .nav-wordmark-brand for a lockup) is the stable
|
|
43
|
+
selector; the tag is not. %>
|
|
44
|
+
<% brand_heading = local_assigns.fetch(:brand_heading) { is_preview || !(respond_to?(:studio_page_has_h1?) && studio_page_has_h1?) } %>
|
|
45
|
+
<% brand_tag = brand_heading ? "h1" : "div" %>
|
|
39
46
|
<%# Out-of-the-box navigation (engine 0.30): when the host declares
|
|
40
47
|
Studio.sidebar_sections, the navbar mounts the link-sidebar trigger in its
|
|
41
48
|
icon rails and renders the slide-out panels after the header. With no
|
|
@@ -9,16 +9,21 @@
|
|
|
9
9
|
Pair with: the crop-photo and saving modal registrations in your modal-host
|
|
10
10
|
block (see the README and CHANGELOG), and x-data="imageUploadHost({...})".
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
SERVED BY THE HOST'S ASSET PIPELINE, since engine-vendors-cropper-assets.
|
|
13
|
+
The two files were cdnjs tags, and a cdnjs connection that never answered
|
|
14
|
+
held the page's load event (the deferred script) on every page that renders
|
|
15
|
+
this partial. They are the cropperjs 1.6.2 npm package's dist files, byte for
|
|
16
|
+
byte (app/assets/javascripts/studio/cropper-1.6.2.min.js and
|
|
17
|
+
app/assets/stylesheets/studio/cropper-1.6.2.min.css); bin/cropper-sri-live
|
|
18
|
+
checks them against the npm tarball and cdnjs's published SRI.
|
|
19
|
+
|
|
20
|
+
Both tags keep Subresource Integrity, so a changed file fails to load
|
|
21
|
+
rather than running. The hashes are sha384 over the exact files. A version
|
|
22
|
+
bump replaces both files (new names), recomputes both hashes (openssl dgst
|
|
23
|
+
-sha384 -binary FILE | openssl base64 -A) and runs bin/cropper-sri-live. %>
|
|
24
|
+
<link rel="stylesheet" href="<%= asset_path("studio/cropper-1.6.2.min.css") %>"
|
|
20
25
|
integrity="sha384-6LFfkTKLRlzFtgx8xsWyBdKGpcMMQTkv+dB7rAbugeJAu1Ym2q1Aji1cjHBG12Xh"
|
|
21
26
|
crossorigin="anonymous">
|
|
22
|
-
<script defer src="
|
|
27
|
+
<script defer src="<%= asset_path("studio/cropper-1.6.2.min.js") %>"
|
|
23
28
|
integrity="sha384-jrOgQzBlDeUNdmQn3rUt/PZD+pdcRBdWd/HWRqRo+n2OR2QtGyjSaJC0GiCeH+ir"
|
|
24
29
|
crossorigin="anonymous"></script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<%# locals: (title:, updated: nil, crumbs: [], links: [], data: {}) %>
|
|
2
|
+
<%# THE LEGAL PAGE: the standard page header and a readable column, for an app's
|
|
3
|
+
privacy policy and terms (docs/PAGE_HEADER.md, "The legal page"). Render it as a
|
|
4
|
+
layout around the page's sections:
|
|
5
|
+
|
|
6
|
+
render layout: "studio/legal_page", locals: { title: "Privacy Policy", updated: "November 8, 2026" }
|
|
7
|
+
...the sections, each an h2 and its paragraphs...
|
|
8
|
+
|
|
9
|
+
title the page's one h1, in studio/_page_header.
|
|
10
|
+
updated the date the text last changed, as the reader should see it. It is
|
|
11
|
+
printed as "Last updated" and the date, under the row.
|
|
12
|
+
crumbs the row's trail, as studio/_page_header takes it.
|
|
13
|
+
links the row's links line, such as the other legal page.
|
|
14
|
+
data data attributes for the column, such as data-legal-page.
|
|
15
|
+
|
|
16
|
+
SCOPED CSS, NOT UTILITIES, as studio/site_footer/_assets: the column reads the
|
|
17
|
+
theme's custom properties with a fallback beside each, so it reads the same in a
|
|
18
|
+
Tailwind app and in a plain-CSS one. A plain-CSS app also sets
|
|
19
|
+
config.page_header_self_styled, so the row brings its own styles too.
|
|
20
|
+
|
|
21
|
+
The column has a 1rem gutter, which the row's default bleed fits. %>
|
|
22
|
+
<% unless @_studio_legal_page_styled %>
|
|
23
|
+
<% @_studio_legal_page_styled = true %>
|
|
24
|
+
<style <%= tag.attributes(nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce))) %>>
|
|
25
|
+
.legal-page { box-sizing: border-box; max-width: 46rem; margin-inline: auto; padding: 1.5rem 1rem 3rem; }
|
|
26
|
+
.legal-page-updated { margin: .25rem 0 0; font-size: .875rem; line-height: 1.25rem;
|
|
27
|
+
color: var(--color-text-muted, var(--color-text-secondary, currentColor)); }
|
|
28
|
+
.legal-page-body { margin-top: 1.5rem; font-size: 1rem; line-height: 1.7; color: var(--color-text-body, currentColor);
|
|
29
|
+
overflow-wrap: break-word; }
|
|
30
|
+
.legal-page-body > :first-child { margin-top: 0; }
|
|
31
|
+
.legal-page-body :is(h2, h3) { color: var(--color-text, currentColor); line-height: 1.3; letter-spacing: -.01em; }
|
|
32
|
+
.legal-page-body h2 { margin: 2.25rem 0 0; font-size: 1.25rem; font-weight: 700; }
|
|
33
|
+
.legal-page-body h3 { margin: 1.5rem 0 0; font-size: 1.0625rem; font-weight: 700; }
|
|
34
|
+
.legal-page-body :is(p, ul, ol) { margin: .75rem 0 0; }
|
|
35
|
+
.legal-page-body :is(ul, ol) { padding-left: 1.5rem; }
|
|
36
|
+
.legal-page-body ul { list-style: disc; }
|
|
37
|
+
.legal-page-body ol { list-style: decimal; }
|
|
38
|
+
.legal-page-body li + li { margin-top: .375rem; }
|
|
39
|
+
.legal-page-body strong { color: var(--color-text, currentColor); font-weight: 700; }
|
|
40
|
+
.legal-page-body a { color: var(--color-primary-ink, var(--color-primary, currentColor)); text-decoration: underline;
|
|
41
|
+
text-underline-offset: 3px; }
|
|
42
|
+
.legal-page-body a:hover { text-decoration-thickness: 2px; }
|
|
43
|
+
.legal-page-body section + section { margin-top: 0; }
|
|
44
|
+
</style>
|
|
45
|
+
<% end %>
|
|
46
|
+
<%= tag.div(class: "legal-page", data: { studio_legal_page: "" }.merge(data)) do %>
|
|
47
|
+
<%= render "studio/page_header", title: title, crumbs: crumbs, links: links %>
|
|
48
|
+
<% if updated.present? %>
|
|
49
|
+
<p class="legal-page-updated">Last updated <%= updated %></p>
|
|
50
|
+
<% end %>
|
|
51
|
+
<article class="legal-page-body"><%= yield %></article>
|
|
52
|
+
<% end %>
|
|
@@ -66,8 +66,18 @@
|
|
|
66
66
|
parent's start, so the controller measures the row's place from the row. It
|
|
67
67
|
carries the controller, so the row keeps its data-studio-controller for the
|
|
68
68
|
page's own. So the row carries no top margin: the space above it belongs to its
|
|
69
|
-
container.
|
|
70
|
-
|
|
69
|
+
container.
|
|
70
|
+
|
|
71
|
+
SELF-STYLED, IN A PLAIN-CSS APP. studio_page_header_assets renders the row's own
|
|
72
|
+
CSS and script once per page, only where config.page_header_self_styled asks
|
|
73
|
+
(Studio::PageHeaderHelper). Everywhere else it is nil, and it sits on the
|
|
74
|
+
sentinel's line, so a Tailwind app's row is the same to the byte.
|
|
75
|
+
|
|
76
|
+
THE PAGE'S ONE H1 is this row's title, so it records one, and the navbar draws its
|
|
77
|
+
brand as a div (StudioNavbarHelper#studio_page_has_h1?). content_for, not the helper:
|
|
78
|
+
a host renders this partial from views that may not include the engine's helpers. It
|
|
79
|
+
sits on the same line and renders nothing. %>
|
|
80
|
+
<% content_for(:studio_page_h1, "1") unless content_for?(:studio_page_h1) %><%= studio_page_header_assets if respond_to?(:studio_page_header_assets) %><div class="page-header-sentinel" data-studio-controller="page-header" aria-hidden="true"></div>
|
|
71
81
|
<%= tag.div(class: "page-header sticky #{row_class}".strip,
|
|
72
82
|
style: "top: var(--pin-page-top, var(--nav-bottom, var(--nav-h, 0px))); z-index: var(--z-sticky, 30)",
|
|
73
83
|
data: data.merge(pin: "page")) do %>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<%# The self-styled page header's CSS and script. Rendered once per page, by
|
|
2
|
+
studio_page_header_assets, and only where config.page_header_self_styled asks
|
|
3
|
+
(docs/PAGE_HEADER.md, "In a plain-CSS app").
|
|
4
|
+
|
|
5
|
+
SCOPED CSS, NOT UTILITIES, as studio/site_footer/_assets. Everything the row needs
|
|
6
|
+
is here, under .page-header, reading the theme's custom properties with a fallback
|
|
7
|
+
beside each, so the row renders whole in an app whose stylesheet has never seen
|
|
8
|
+
the engine's classes. The rules are the ones engine.css gives the row (its "page
|
|
9
|
+
header" block, the .btn family at .btn-sm, and .label-upper), so the two looks
|
|
10
|
+
are one. Change one, change the other.
|
|
11
|
+
|
|
12
|
+
The default bleed (row_class "-mx-4 px-4") is a pair of Tailwind classes. This
|
|
13
|
+
file defines them on the row alone, so the default fits a plain container with a
|
|
14
|
+
1rem gutter as it fits a Tailwind px-4.
|
|
15
|
+
|
|
16
|
+
THE SCRIPT is studio/page_header_self_styled, a module with no imports, loaded by
|
|
17
|
+
its own tag because a plain app may have no import map and no Stimulus. It is the
|
|
18
|
+
page-header controller's work: the stuck bar, the tab fades, the open tab on a
|
|
19
|
+
phone, each Links menu's aria-expanded, and the menu's place where the browser
|
|
20
|
+
has no anchor positioning. It also publishes --nav-bottom from the app's own
|
|
21
|
+
sticky masthead. The tag carries the request's CSP nonce when the host sets one.
|
|
22
|
+
Without the script the row keeps its bar at all times (the noscript rule), and
|
|
23
|
+
every control is still a link or a popover. %>
|
|
24
|
+
<style <%= tag.attributes(nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce))) %>>
|
|
25
|
+
.page-header { --ph-ink: var(--color-text, currentColor); --ph-body: var(--color-text-body, currentColor);
|
|
26
|
+
--ph-muted: var(--color-text-muted, var(--color-text-secondary, currentColor));
|
|
27
|
+
--ph-surface: var(--color-surface, Canvas); --ph-surface-alt: var(--color-surface-alt, var(--color-surface, Canvas));
|
|
28
|
+
--ph-line: var(--color-border, rgb(127 127 127 / .25));
|
|
29
|
+
--ph-line-strong: var(--color-border-strong, var(--color-border, rgb(127 127 127 / .4)));
|
|
30
|
+
--ph-primary: var(--color-cta-fill, var(--color-cta, var(--color-primary, #6558e5)));
|
|
31
|
+
--ph-primary-hover: var(--color-cta-hover, var(--ph-primary));
|
|
32
|
+
--ph-primary-fg: var(--btn-primary-fg, #fff);
|
|
33
|
+
--ph-focus: var(--color-primary-ink, var(--color-primary, #6558e5));
|
|
34
|
+
--ph-base: var(--type-base, 16px);
|
|
35
|
+
position: sticky; box-sizing: border-box;
|
|
36
|
+
display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; min-width: 0;
|
|
37
|
+
padding-block: .5rem; border-block: 1px solid transparent; background-color: transparent;
|
|
38
|
+
transition: background-color 150ms ease, border-color 150ms ease; }
|
|
39
|
+
.page-header *, .page-header *::before, .page-header *::after { box-sizing: border-box; }
|
|
40
|
+
.page-header[data-stuck] { background-color: var(--ph-surface); border-color: var(--ph-line); }
|
|
41
|
+
.page-header.-mx-4 { margin-inline: -1rem; }
|
|
42
|
+
.page-header.px-4 { padding-inline: 1rem; }
|
|
43
|
+
.page-header-sentinel { position: absolute; width: 0; height: 0; }
|
|
44
|
+
.page-header a { text-decoration: none; }
|
|
45
|
+
|
|
46
|
+
/* The title and the meta. */
|
|
47
|
+
.page-header-lead { display: flex; align-items: baseline; gap: .5rem; flex: 0 1 auto; min-width: 0; }
|
|
48
|
+
.page-header .page-header-title { margin: 0; color: var(--ph-ink); font-size: calc(var(--ph-base) * 1.5);
|
|
49
|
+
font-weight: var(--type-display-weight, 800); line-height: 1.25; min-width: 0; overflow-wrap: anywhere;
|
|
50
|
+
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow-x: visible; overflow-y: clip; }
|
|
51
|
+
@media (width >= 40rem) { .page-header .page-header-title { font-size: 30px; line-height: 1.2; } }
|
|
52
|
+
.page-header :is(.page-header-meta, .label-upper) { margin: 0; white-space: nowrap; color: var(--ph-muted);
|
|
53
|
+
font-size: .75rem; line-height: 1rem; text-transform: uppercase; letter-spacing: .05em; }
|
|
54
|
+
@media (width < 40rem) { .page-header .page-header-meta { display: none; } }
|
|
55
|
+
|
|
56
|
+
/* The buttons, at .btn-sm: every control on the right stands at one height. */
|
|
57
|
+
.page-header .btn { display: inline-flex; align-items: center; justify-content: center; margin: 0;
|
|
58
|
+
font-family: inherit; font-weight: 700; border: 1px solid transparent; border-radius: .5rem;
|
|
59
|
+
white-space: nowrap; cursor: pointer; text-decoration: none;
|
|
60
|
+
transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, filter 150ms ease; }
|
|
61
|
+
.page-header .btn-sm { padding: .375rem .75rem; font-size: .75rem; line-height: 1rem; }
|
|
62
|
+
.page-header .btn-primary { color: var(--ph-primary-fg); background-color: var(--ph-primary); }
|
|
63
|
+
.page-header .btn-primary:hover { color: var(--btn-primary-fg-hover, var(--ph-primary-fg));
|
|
64
|
+
background-color: var(--ph-primary-hover); filter: brightness(.94); }
|
|
65
|
+
.page-header .btn-neutral { color: var(--ph-ink); background-color: var(--btn-neutral-bg, var(--ph-surface-alt));
|
|
66
|
+
border-color: var(--ph-line-strong); }
|
|
67
|
+
.page-header .btn-neutral:hover { color: var(--ph-ink); background-color: var(--btn-neutral-bg-hover, var(--ph-surface));
|
|
68
|
+
filter: var(--btn-neutral-hover-filter, none); }
|
|
69
|
+
.page-header .btn:focus-visible { outline: 2px solid var(--ph-focus); outline-offset: 2px; border-radius: .5rem; }
|
|
70
|
+
|
|
71
|
+
/* The pill group: it scrolls sideways inside the row on a phone, with a fade at an end
|
|
72
|
+
that hides a tab. */
|
|
73
|
+
.page-header .page-header-tabs { --page-header-fade-start: 0px; --page-header-fade-end: 0px;
|
|
74
|
+
flex: 1 1 6rem; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: .25rem; margin: -.25rem;
|
|
75
|
+
-webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--page-header-fade-start), #000 calc(100% - var(--page-header-fade-end)), transparent 100%);
|
|
76
|
+
mask-image: linear-gradient(to right, transparent 0, #000 var(--page-header-fade-start), #000 calc(100% - var(--page-header-fade-end)), transparent 100%); }
|
|
77
|
+
.page-header .page-header-tabs::-webkit-scrollbar { display: none; }
|
|
78
|
+
.page-header .page-header-tabs[data-fade-start] { --page-header-fade-start: 2rem; }
|
|
79
|
+
.page-header .page-header-tabs[data-fade-end] { --page-header-fade-end: 2rem; }
|
|
80
|
+
.page-header-track { display: flex; align-items: center; gap: .5rem; width: max-content; margin-left: auto; }
|
|
81
|
+
.page-header-tab-label { position: relative; z-index: 2; }
|
|
82
|
+
.page-header .page-header-glide { display: none; }
|
|
83
|
+
|
|
84
|
+
/* The cluster: the menu, the action, the tools. */
|
|
85
|
+
.page-header-actions { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
|
|
86
|
+
gap: .5rem; max-width: 100%; margin-left: auto; }
|
|
87
|
+
.page-header-tabs + .page-header-actions { margin-left: 0; }
|
|
88
|
+
.page-header-menu { position: relative; anchor-scope: --page-header-menu; }
|
|
89
|
+
.page-header .page-header-menu-button { gap: .375rem; anchor-name: --page-header-menu; }
|
|
90
|
+
.page-header-menu-caret { width: .375rem; height: .375rem; border-right: 1.5px solid currentColor;
|
|
91
|
+
border-bottom: 1.5px solid currentColor; transform: translateY(-.125rem) rotate(45deg); transition: transform 150ms ease; }
|
|
92
|
+
.page-header-menu:has(> .page-header-menu-list:popover-open) .page-header-menu-caret { transform: translateY(.125rem) rotate(225deg); }
|
|
93
|
+
.page-header .page-header-menu-list { position: fixed; inset: auto; margin: 0; min-width: 10rem;
|
|
94
|
+
max-width: min(20rem, calc(100vw - 2rem)); padding: .25rem; border: 1px solid var(--ph-line); border-radius: .5rem;
|
|
95
|
+
background-color: var(--ph-surface); color: var(--ph-body);
|
|
96
|
+
box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1); }
|
|
97
|
+
.page-header .page-header-menu-list ul { margin: 0; padding: 0; list-style: none; }
|
|
98
|
+
@supports (anchor-name: --a) and (position-anchor: --a) {
|
|
99
|
+
.page-header .page-header-menu-list { position-anchor: --page-header-menu; top: anchor(bottom); right: anchor(right);
|
|
100
|
+
margin-top: .25rem; position-try-fallbacks: flip-block, flip-inline; }
|
|
101
|
+
}
|
|
102
|
+
.page-header .page-header-menu-item { display: block; padding: .5rem .75rem; border-radius: .375rem;
|
|
103
|
+
font-size: calc(var(--ph-base) * .875); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
104
|
+
color: var(--ph-body); }
|
|
105
|
+
.page-header .page-header-menu-item:is(:hover, :focus-visible) { background-color: var(--ph-surface-alt); color: var(--ph-ink); }
|
|
106
|
+
.page-header .page-header-menu-item:focus-visible { outline: 2px solid var(--ph-focus); outline-offset: -2px; }
|
|
107
|
+
.page-header-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-left: .5rem;
|
|
108
|
+
border-left: 1px dashed var(--ph-line); opacity: .7; transition: opacity 150ms ease; }
|
|
109
|
+
.page-header-tools:is(:hover, :focus-within) { opacity: 1; }
|
|
110
|
+
|
|
111
|
+
/* The trail above the title, and the one parent link that stands for it on a phone. */
|
|
112
|
+
.page-header-trail { flex: 1 0 100%; min-width: 0; margin-bottom: -.5rem;
|
|
113
|
+
font-size: calc(var(--ph-base) * .8125); line-height: 1.25; }
|
|
114
|
+
.page-header-crumbs { min-width: 0; }
|
|
115
|
+
.page-header-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; column-gap: .5rem; row-gap: .125rem;
|
|
116
|
+
margin: 0; padding: 0; list-style: none; }
|
|
117
|
+
.page-header-crumbs li { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
|
|
118
|
+
.page-header-crumbs li + li::before { content: "\203A"; content: "\203A" / ""; color: var(--ph-muted); opacity: .6; }
|
|
119
|
+
@media (width < 40rem) { .page-header-crumbs { display: none; } }
|
|
120
|
+
.page-header .page-header-crumb { color: var(--ph-muted); transition: color 150ms ease; }
|
|
121
|
+
.page-header .page-header-crumb-current { color: var(--ph-ink); font-weight: 600; overflow-wrap: anywhere; }
|
|
122
|
+
.page-header .page-header-parent { display: none; color: var(--ph-muted); font-size: calc(var(--ph-base) * .875); }
|
|
123
|
+
@media (width < 40rem) { .page-header .page-header-parent { display: inline-flex; gap: .25rem; align-items: baseline; } }
|
|
124
|
+
|
|
125
|
+
/* The links line at the foot of the row. */
|
|
126
|
+
.page-header-links { flex: 1 0 100%; display: flex; align-items: center; gap: 1rem; min-width: 0; margin-top: -.25rem;
|
|
127
|
+
overflow-x: auto; scrollbar-width: none; white-space: nowrap; font-size: calc(var(--ph-base) * .8125); }
|
|
128
|
+
.page-header .page-header-link { color: var(--ph-muted); transition: color 150ms ease; }
|
|
129
|
+
.page-header .page-header-link[aria-current] { font-weight: 600; }
|
|
130
|
+
.page-header :is(.page-header-crumb, .page-header-parent, .page-header-link):is(:hover, :focus-visible),
|
|
131
|
+
.page-header .page-header-link[aria-current] { color: var(--ph-ink); }
|
|
132
|
+
|
|
133
|
+
/* The gliding pill, where the browser can anchor it (engine.css, "The gliding pill"). */
|
|
134
|
+
@supports (anchor-name: --a) and (position-anchor: --a) and selector(:has(a)) {
|
|
135
|
+
.page-header .page-header-track { position: relative; anchor-scope: --page-header-current; }
|
|
136
|
+
.page-header .page-header-track > [aria-current] { anchor-name: --page-header-current; }
|
|
137
|
+
.page-header .page-header-track:has(> .page-header-tab[aria-current]) > .page-header-glide {
|
|
138
|
+
display: block; position: absolute; position-anchor: --page-header-current;
|
|
139
|
+
top: anchor(top); right: anchor(right); bottom: anchor(bottom); left: anchor(left);
|
|
140
|
+
z-index: 1; margin: 0; padding: 0; pointer-events: none;
|
|
141
|
+
transition: top 320ms cubic-bezier(.2, .8, .2, 1), right 320ms cubic-bezier(.2, .8, .2, 1),
|
|
142
|
+
bottom 320ms cubic-bezier(.2, .8, .2, 1), left 320ms cubic-bezier(.2, .8, .2, 1); }
|
|
143
|
+
.page-header .page-header-track:has(> .page-header-glide) > .page-header-tab[aria-current] {
|
|
144
|
+
background-color: transparent; background-image: none; border-color: transparent; box-shadow: none; filter: none; }
|
|
145
|
+
}
|
|
146
|
+
@media (prefers-reduced-motion: reduce) {
|
|
147
|
+
.page-header, .page-header *, .page-header-menu-caret { transition: none !important; }
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
150
|
+
<noscript><style>.page-header { background-color: var(--ph-surface); border-color: var(--ph-line); }</style></noscript>
|
|
151
|
+
<script type="module" src="<%= asset_path("studio/page_header_self_styled.js") %>" <%= tag.attributes(nonce: (content_security_policy_nonce if respond_to?(:content_security_policy_nonce))) %>></script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Lets a logout end one device's session on the server (Studio::UserSession,
|
|
2
|
+
# docs/DEVICE_SESSIONS.md). `sid` is the random id the device's cookie carries in
|
|
3
|
+
# its mark; every row of that device session carries it. `revoked_at` is stamped
|
|
4
|
+
# on logout, and a request whose sid is revoked is signed out.
|
|
5
|
+
#
|
|
6
|
+
# Both columns are nullable with no default, so the add is a catalog-only change
|
|
7
|
+
# and no existing row is rewritten. Rows from before this migration have no sid;
|
|
8
|
+
# their cookies get one on their next request (Studio::UserSession.track).
|
|
9
|
+
#
|
|
10
|
+
# A host without the table (it has not installed CreateStudioUserSessions) is a
|
|
11
|
+
# no-op here; the model checks for these columns and stays off until they exist.
|
|
12
|
+
class AddDeviceRevocationToStudioUserSessions < ActiveRecord::Migration[7.2]
|
|
13
|
+
def up
|
|
14
|
+
return unless table_exists?(:studio_user_sessions)
|
|
15
|
+
|
|
16
|
+
add_column :studio_user_sessions, :sid, :string, if_not_exists: true
|
|
17
|
+
add_column :studio_user_sessions, :revoked_at, :datetime, if_not_exists: true
|
|
18
|
+
add_index :studio_user_sessions, :sid, if_not_exists: true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def down
|
|
22
|
+
return unless table_exists?(:studio_user_sessions)
|
|
23
|
+
|
|
24
|
+
remove_index :studio_user_sessions, :sid, if_exists: true
|
|
25
|
+
remove_column :studio_user_sessions, :revoked_at, if_exists: true
|
|
26
|
+
remove_column :studio_user_sessions, :sid, if_exists: true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# CONNECTIONS (docs/CONNECTIONS.md): one row per third-party account a host app
|
|
2
|
+
# has connected over OAuth 2.0, for any provider the host declares with
|
|
3
|
+
# Studio.define_connection. The engine names no provider; `provider` is the
|
|
4
|
+
# host's key for one.
|
|
5
|
+
#
|
|
6
|
+
# One row per provider and account (`account_key`, unique within a provider):
|
|
7
|
+
# the account itself (a domain, a company id), or a keyed digest of it when the
|
|
8
|
+
# provider declares the account private, in which case the id is kept only in
|
|
9
|
+
# `account_secret`, encrypted. Every token column is encrypted with the app's
|
|
10
|
+
# Active Record encryption keys; a host without them cannot store a row.
|
|
11
|
+
#
|
|
12
|
+
# Installing the table changes nothing on its own: no route is drawn and no
|
|
13
|
+
# provider exists until the host declares one.
|
|
14
|
+
class CreateStudioConnections < ActiveRecord::Migration[7.2]
|
|
15
|
+
def change
|
|
16
|
+
create_table :studio_connections do |t|
|
|
17
|
+
t.string :provider, null: false
|
|
18
|
+
t.string :account_key, null: false
|
|
19
|
+
t.text :account_secret
|
|
20
|
+
t.string :label
|
|
21
|
+
t.text :access_token
|
|
22
|
+
t.text :refresh_token
|
|
23
|
+
t.datetime :access_expires_at
|
|
24
|
+
t.datetime :refresh_expires_at
|
|
25
|
+
t.json :metadata, null: false, default: {}
|
|
26
|
+
t.string :connected_by
|
|
27
|
+
t.datetime :connected_at, null: false
|
|
28
|
+
t.datetime :last_refreshed_at
|
|
29
|
+
|
|
30
|
+
t.timestamps
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
add_index :studio_connections, [:provider, :account_key], unique: true
|
|
34
|
+
end
|
|
35
|
+
end
|