simonw / dclient

A client CLI utility for Datasette instances
Apache License 2.0
11 stars 0 forks source link

`dclient actor` command #26

Closed simonw closed 9 months ago

simonw commented 9 months ago

Useful for testing the permissions that are assigned to a token. Does an authenticated GET against /-/actor.json.

simonw commented 9 months ago

One catch is that the alias is probably set to something like:

https://latest.datasette.io/fixtures

So actually we need to split off that last element and hit /-/actor.json - but I'd like it to do the right thing with respect to Datasette instances that don't have / as the root of the instance.

simonw commented 9 months ago

I'm going to split on / and stick -/actor.json on the last bit.

simonw commented 9 months ago

Got this working:

dclient actor content
{
    "actor": null
}
dclient actor staff  
{
    "actor": {
        "id": "2",
        "token": "dsatok",
        "token_id": 13,
        "_r": {
            "d": {
                "data": [
                    "vd",
                    "vdd",
                    "vt",
                    "vq",
                    "es",
                    "ir",
                    "dr",
                    "ur",
                    "ct",
                    "at",
                    "dt"
                ]
            }
        }
    }
}
simonw commented 9 months ago

Documentation: https://dclient.datasette.io/en/latest/authentication.html#testing-a-token and https://dclient.datasette.io/en/latest/authentication.html#dclient-actor-help