Upgrade kaya to 0.0.6
kaya-oidc 0.0.6 namespaces its session state per provider as
oidc:{provider}:user (the default provider is "default", so the key is
oidc:default:user). The unprefixed oidc_user key is no longer written:
left unadapted, every websocket upgrade would be rejected with 401 and
traced requests would silently lose their user.id attribute. Adopt it
with a session_user helper on tavolo.platform.auth that finds any
provider's user, used by both get_ws_user and telemetry's
session_tag_hook. Websocket and route handlers keep their signatures.
kaya-otel 0.0.6 only enriches websocket spans with standard URL, network
and peer attributes (plus error.type), which needs no application change.
Regenerate the lock: the eight kaya pins move to 0.0.6 and, the wheels'
declared metadata being unchanged, nothing else moves. tavolo-platform
now floors kaya-core>=0.0.6 (it reads the new session layout) and
tavolo-app floors kaya-otel>=0.0.6.
As kaya documents, the session-key move signs existing logged-in users
out once; they simply log in again.
This commit is contained in:
@@ -151,7 +151,7 @@ class SessionTagHookTest(unittest.TestCase):
|
||||
def test_tags_authenticated_session(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
carrier = SimpleNamespace(
|
||||
session=Session("sid", {"oidc_user": {"sub": "alice"}})
|
||||
session=Session("sid", {"oidc:default:user": {"sub": "alice"}})
|
||||
)
|
||||
session_tag_hook(span, carrier)
|
||||
self.assertEqual(
|
||||
@@ -160,6 +160,23 @@ class SessionTagHookTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual("alice", span.attributes["user.id"])
|
||||
|
||||
def test_tags_user_of_any_provider(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
carrier = SimpleNamespace(
|
||||
session=Session("sid", {"oidc:google:user": {"sub": "alice"}})
|
||||
)
|
||||
session_tag_hook(span, carrier)
|
||||
self.assertEqual("alice", span.attributes["user.id"])
|
||||
|
||||
def test_ignores_legacy_unprefixed_user_key(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
carrier = SimpleNamespace(
|
||||
session=Session("sid", {"oidc_user": {"sub": "alice"}})
|
||||
)
|
||||
session_tag_hook(span, carrier)
|
||||
self.assertIn("session.id", span.attributes)
|
||||
self.assertNotIn("user.id", span.attributes)
|
||||
|
||||
def test_tags_session_without_user(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
session_tag_hook(span, SimpleNamespace(session=Session("sid", {})))
|
||||
@@ -169,7 +186,7 @@ class SessionTagHookTest(unittest.TestCase):
|
||||
def test_tags_user_when_session_id_not_yet_minted(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
carrier = SimpleNamespace(
|
||||
session=Session(None, {"oidc_user": {"sub": "alice"}})
|
||||
session=Session(None, {"oidc:default:user": {"sub": "alice"}})
|
||||
)
|
||||
session_tag_hook(span, carrier)
|
||||
self.assertNotIn("session.id", span.attributes)
|
||||
@@ -182,7 +199,7 @@ class SessionTagHookTest(unittest.TestCase):
|
||||
|
||||
def test_malformed_user_is_ignored(self) -> None:
|
||||
span = _RecordedSpan()
|
||||
carrier = SimpleNamespace(session=Session("sid", {"oidc_user": "alice"}))
|
||||
carrier = SimpleNamespace(session=Session("sid", {"oidc:default:user": "alice"}))
|
||||
session_tag_hook(span, carrier)
|
||||
self.assertIn("session.id", span.attributes)
|
||||
self.assertNotIn("user.id", span.attributes)
|
||||
@@ -224,7 +241,7 @@ class SessionTagIntegrationTest(unittest.TestCase):
|
||||
async def login(ctx: HttpContext) -> None:
|
||||
session = ctx.session
|
||||
assert session is not None
|
||||
session["oidc_user"] = {"sub": "alice"}
|
||||
session["oidc:default:user"] = {"sub": "alice"}
|
||||
await ctx.send_str(200, "ok")
|
||||
|
||||
@app.GET("/me")
|
||||
|
||||
Reference in New Issue
Block a user