From 1289422f6bf213b0ce229472d5e77bfff0a4ce37 Mon Sep 17 00:00:00 2001 From: xrendan Date: Sat, 15 Nov 2025 16:26:17 -0700 Subject: [PATCH 1/2] Add id field to actor object for consistency with Datasette actor format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds an "id" field to the actor object returned by the GitHub authentication callback. The id field follows the format "github:{user_id}" which is consistent with Datasette's actor format conventions and ensures unique identification of authenticated users. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- datasette_auth_github/views.py | 1 + tests/test_datasette_auth_github.py | 1 + 2 files changed, 2 insertions(+) diff --git a/datasette_auth_github/views.py b/datasette_auth_github/views.py index 1758e5b..db9ecf5 100644 --- a/datasette_auth_github/views.py +++ b/datasette_auth_github/views.py @@ -76,6 +76,7 @@ async def github_auth_callback(datasette, request, scope, receive, send): except ValueError: return await response_error(datasette, "Could not load GitHub profile") actor = { + "id": "github:{}".format(profile["id"]), "display": profile["login"], "gh_id": str(profile["id"]), "gh_name": profile["name"], diff --git a/tests/test_datasette_auth_github.py b/tests/test_datasette_auth_github.py index fb9d2af..019542c 100644 --- a/tests/test_datasette_auth_github.py +++ b/tests/test_datasette_auth_github.py @@ -154,6 +154,7 @@ async def test_github_auth_callback(ds, mocked_github_api): ) actor = ds.unsign(response.cookies["ds_actor"], "actor")["a"] assert { + "id": "github:123", "display": "demouser", "gh_id": "123", "gh_name": "GitHub User", From b865312c35fac639b1ea797b8e338afd69ba4ab4 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 15 Nov 2025 15:42:20 -0800 Subject: [PATCH 2/2] Extra docs for 'id' key, refs #77 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a95a299..2c4643d 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Visit `/-/actor` when signed in to see the shape of the authenticated actor. It ```json { "actor": { + "id": "github:9599", "display": "simonw", "gh_id": "9599", "gh_name": "Simon Willison", @@ -106,7 +107,7 @@ Note that GitHub allows users to change their username, and it is possible for o ```json { "allow": { - "gh_id": "9599" + "id": "github:9599" } } ```