studio-engine 0.4.2 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2cff93b3aa059d4b0542abe34622157f0d0928f758b4f656878cfab6e4e25a2
4
- data.tar.gz: fb784e5e6ace872de9d92d3a035e85caaa2085b6b72e18b1f380459f997221c5
3
+ metadata.gz: 288a5cb85deb7c2c43a77b24e4d5bc1b958fd5652e2860bbe88a12d43c22f21e
4
+ data.tar.gz: 1c6ee3b69613649611963e56ba681d066dfeda518bc1010e764ac560e9c308af
5
5
  SHA512:
6
- metadata.gz: 7862911114e91fde7662c540229703184be955af01116c8ced37160751b8d1b09093ebba1fe410602d03b6f562e261e995884e78041fea02b720fafbfd027bf1
7
- data.tar.gz: e7424e7e280e8ba717807d3b690fad5929d150e6c3c298a8ace724a4e1ebdec8fd261f8bf9f40b8abff2f299d223a8954cc3a7abd5a0493f0cc0def677fc7649
6
+ metadata.gz: c930ecdf8f851eaaff0d14db9661dc434132a877a08deec34745e66817e77292dbc95fd1d661769c566d74180cae623f3cfeb76f94ce7690bf4ca71a1e0fe649
7
+ data.tar.gz: b3e2862a52d75a9bc7e122865dd1e9222859a17dbbf19f837f50f5e44a90e25bb1a01ec92afe77621a827cbfccda370e6235e8b60ae05ce01855c5f76a8e55ec
data/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  The format is [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html) — `MAJOR.MINOR.PATCH`. Both consumer Rails apps pin to a tag in their `Gemfile`; bumping the tag is a release.
4
4
 
5
+ ## v0.4.4 (2026-05-20)
6
+
7
+ Sticky-navbar scroll fixes — bounce-free for every consuming app, no migration required.
8
+
9
+ ### Fixed
10
+ - **Navbar scroll-collapse bounce.** A `position: sticky` navbar that shrinks on scroll changes layout above the fold; Chrome/Firefox scroll-anchoring then compensates by moving `scrollY`, which re-crosses the collapse threshold and oscillates. `_head.html.erb` now ships `body { overflow-anchor: none }`, so the navbar resize no longer drags `scrollY`. Every app that renders `layouts/studio/head` gets this automatically.
11
+ - **Navbar unscroll threshold `20 → 5`** in `_navbar.html.erb` — widens the hysteresis dead zone (5/60) so a height change can't push `scrollY` back across the lower bound.
12
+
13
+ ### Added
14
+ - **`--nav-h` CSS variable.** `_head.html.erb` ships a `ResizeObserver` that publishes the page header's live height to `--nav-h` on `:root` — updated on every resize (including the collapse animation) and re-attached after Turbo navigations. Fixed/sticky elements below the navbar can position off `var(--nav-h)` instead of hardcoded px (e.g. `style="top: var(--nav-h)"`). Auto-detects the page `<header>`; no markup changes needed.
15
+
16
+ ## v0.4.3 (2026-05-19)
17
+
18
+ Tier-3 fix from the turf-monster pre-prod opsec audit (OPSEC-016).
19
+
20
+ ### Fixed (security)
21
+ - **`GET /sso_login` no longer mutates the session (OPSEC-016).** The action previously called `authenticate_sso_user!` directly — starting a session on a GET. GETs are not CSRF-covered and are prefetchable (`<img>`, `<link rel=prefetch>`, browser prefetch), so an XSS on any `*.mcritchie.studio` subdomain that wrote `session[:sso_email]` could have a forged `/sso_login` hit silently start a session as that user. `sso_login` now only redirects to the login page; the session mutation happens exclusively through the CSRF-protected `POST /sso_continue` ("Continue as …" button).
22
+
23
+ ### Changed
24
+ - The hub's one-click SSO link to a satellite's `/sso_login` now lands the user on the satellite login page with the "Continue as …" button instead of logging them in directly — one extra click, and the GET endpoint is no longer a session-mutation vector.
25
+
5
26
  ## v0.4.2 (2026-05-19)
6
27
 
7
28
  Security follow-up to v0.4.1 — closes a cross-app session-fixation surface.
@@ -15,15 +15,20 @@ class SessionsController < ApplicationController
15
15
  end
16
16
  end
17
17
 
18
- # GET /sso_login — one-click SSO entry point (linked from hub app nav)
18
+ # GET /sso_login — one-click SSO entry point (linked from hub app nav).
19
+ #
20
+ # OPSEC-016: this previously called authenticate_sso_user! directly, mutating
21
+ # the session on a GET. GETs are not CSRF-covered and are prefetchable
22
+ # (browser prefetch, <img>, <link rel=prefetch>), so an XSS on any
23
+ # *.mcritchie.studio subdomain could write session[:sso_email] and a forged
24
+ # GET /sso_login would silently start a session as that user. It now only
25
+ # redirects to the login page — the session mutation happens exclusively via
26
+ # the CSRF-protected POST /sso_continue ("Continue as …" button rendered
27
+ # there when sso_user_available?).
19
28
  def sso_login
20
29
  return redirect_to root_path if logged_in?
21
- return redirect_to login_path unless sso_user_available?
22
30
 
23
- authenticate_sso_user!
24
- rescue StandardError => e
25
- create_error_log(e)
26
- redirect_to login_path, alert: "Could not continue session. Please log in."
31
+ redirect_to login_path
27
32
  end
28
33
 
29
34
  # POST /sso_continue — form-based SSO from login page button
@@ -18,7 +18,7 @@
18
18
  logo_path = Studio.logo_for("Navbar Logo")
19
19
  %>
20
20
 
21
- <header x-data="{ scrolled: false }" <%= '@scroll.window="scrolled = scrolled ? (window.scrollY > 20) : (window.scrollY > 60)"'.html_safe unless is_preview %>
21
+ <header x-data="{ scrolled: false }" <%= '@scroll.window="scrolled = scrolled ? (window.scrollY > 5) : (window.scrollY > 60)"'.html_safe unless is_preview %>
22
22
  class="<%= is_preview ? 'bg-page' : 'sticky top-0 z-50 bg-page transition-shadow duration-300' %>"
23
23
  :class="scrolled && 'shadow-lg border-b border-subtle is-scrolled'">
24
24
  <style>
@@ -73,6 +73,38 @@
73
73
  });
74
74
  </script>
75
75
 
76
+ <style>
77
+ /* studio-engine: a sticky navbar that shrinks on scroll changes layout
78
+ above the fold — Chrome/Firefox scroll-anchoring then compensates by
79
+ moving scrollY, which re-crosses the collapse threshold and bounces.
80
+ Disabling anchoring document-wide stops scrollY being dragged by the
81
+ navbar resize. */
82
+ body { overflow-anchor: none; }
83
+ </style>
84
+ <script>
85
+ // studio-engine: publish the sticky header's live height as the --nav-h
86
+ // CSS variable so fixed/sticky elements below the navbar can position off
87
+ // it (e.g. top: var(--nav-h)) without hardcoded px. Tracks every resize,
88
+ // including scroll-collapse animations, and re-attaches after Turbo nav.
89
+ (function () {
90
+ if (!window.ResizeObserver) return;
91
+ var ro = null;
92
+ function publish(header) {
93
+ document.documentElement.style.setProperty('--nav-h', header.offsetHeight + 'px');
94
+ }
95
+ function attach() {
96
+ var header = document.querySelector('header');
97
+ if (!header) return;
98
+ if (ro) ro.disconnect();
99
+ ro = new ResizeObserver(function () { publish(header); });
100
+ ro.observe(header);
101
+ publish(header);
102
+ }
103
+ document.addEventListener('DOMContentLoaded', attach);
104
+ document.addEventListener('turbo:load', attach);
105
+ })();
106
+ </script>
107
+
76
108
  <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
77
109
  <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
78
110
  <%= javascript_importmap_tags %>
@@ -1,3 +1,3 @@
1
1
  module Studio
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: studio-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McRitchie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-19 00:00:00.000000000 Z
11
+ date: 2026-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails