home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

7 rows where "created_at" is on date 2022-10-24, issue = 1421552095 and user = 9599 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • simonw · 7 ✖

issue 1

  • Default API token authentication mechanism · 7 ✖

author_association 1

  • OWNER 7
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1289776707 https://github.com/simonw/datasette/issues/1852#issuecomment-1289776707 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M4G5D simonw 9599 2022-10-24T23:29:03Z 2022-10-24T23:29:03Z OWNER

I'm going to implement the first version of this token mechanism using permissions that exist already. Right now that's:

https://docs.datasette.io/en/0.62/authentication.html#built-in-permissions

Here are the shortcuts I'll use for them:

  • view-instance - vi
  • view-database - vd
  • view-database-download - vdd
  • view-table - vt
  • view-query - vq
  • execute-sql - es
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289775162 https://github.com/simonw/datasette/issues/1852#issuecomment-1289775162 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M4Gg6 simonw 9599 2022-10-24T23:27:00Z 2022-10-24T23:27:00Z OWNER

Might be neat for API tokens to be signed with an additional secret than can be rotated independently of DATASETTE_SECRET itself, in order to invalidate all tokens without needing to invalidate logged in users too.

But again, I don't want to implement something like that until I see an actual need for it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289774183 https://github.com/simonw/datasette/issues/1852#issuecomment-1289774183 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M4GRn simonw 9599 2022-10-24T23:25:52Z 2022-10-24T23:25:52Z OWNER

... also, maybe there should be a UI (perhaps on that page) for resetting the Datasette secret? Useful for emergency invalidation of all tokens.

No, I'm not going to build that unless someone asks for it. Restarting the server with a fresh secret should be easy enough.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289773634 https://github.com/simonw/datasette/issues/1852#issuecomment-1289773634 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M4GJC simonw 9599 2022-10-24T23:25:06Z 2022-10-24T23:25:06Z OWNER

If you start Datasette without providing a DATASETTE_SECRET environment variable of --secret option it creates a random signing secret that only lasts for the lifetime of the server.

This means any signed API tokens you create will stop working if the server restarts.

I think the /-/create-token UI should know when this happens and show a warning message about it, to avoid confusion.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289766513 https://github.com/simonw/datasette/issues/1852#issuecomment-1289766513 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M4EZx simonw 9599 2022-10-24T23:16:00Z 2022-10-24T23:16:00Z OWNER

Here's what that example looks like signed: python from datasette.app import Datasette ds = Datasette() ds.sign('{"t":{"a":["ir","ur","dr"],"d":{"fixtures":["ir","ur","dr"]},"t":{"fixtures":{"searchable":["ir"]}}}}') .eJxTqo5RKolRsgJSiUAqOkYpsyhGSSdGqRRCpQCpWBANUZOWWVFSWpRajFNprQ7cPCS1QF5xamJRckZiUk4qQm9sLRAoAQCC8yph.O0Gaej6-VOLbbtPq7xU6T77jEO0 That's 129 characters.

Note that Datasette doesn't have its own mechanism for signing things for a specific duration yet: https://docs.datasette.io/en/stable/internals.html#sign-value-namespace-default

So I'll need to add a "e": 1666739744 field with the UTC timestamp at which the token should expire.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289733483 https://github.com/simonw/datasette/issues/1852#issuecomment-1289733483 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M38Vr simonw 9599 2022-10-24T22:54:37Z 2022-10-24T23:12:10Z OWNER

Token design concept: json { "t": { "a": ["ir", "ur", "dr"], "d": { "fixtures": ["ir", "ur", "dr"] }, "t": { "fixtures": { "searchable": ["ir"] } } } } That JSON would be minified and signed.

Minified version of the above looks like this (101 characters):

{"t":{"a":["ir","ur","dr"],"d":{"fixtures":["ir","ur","dr"]},"t":{"fixtures":{"searchable":["ir"]}}}}

The "t" key shows this is a token that as a default API key.

"a" means "all" - these are permissions that have been granted on all tables and databases.

"d" means "databases" - this is a way to set permissions for all tables in a specific database.

"t" means "tables" - this lets you set permissions at a finely grained table level.

Then the permissions themselves are two character codes which are shortened versions - so:

  • ir = insert-row
  • ur = update-row
  • dr = delete-row
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  
1289718660 https://github.com/simonw/datasette/issues/1852#issuecomment-1289718660 https://api.github.com/repos/simonw/datasette/issues/1852 IC_kwDOBm6k_c5M34uE simonw 9599 2022-10-24T22:35:01Z 2022-10-24T22:35:01Z OWNER

Maybe these tokens can be restricted to specific databases and tables when they are first created?

Since they're signed tokens, I could bundle a bunch of extra stuff in them - this token is allowed to do these permissions against these tables/rows for example.

General wisdom seems to be that 8KB is a sensible maximum length for this kind of token, which is easily long enough to fit in a bunch of database / table / permissions.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Default API token authentication mechanism 1421552095  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 590.778ms · About: github-to-sqlite