Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example permissions plugin #818

Closed
simonw opened this issue Jun 8, 2020 · 9 comments
Closed

Example permissions plugin #818

simonw opened this issue Jun 8, 2020 · 9 comments

Comments

@simonw
Copy link
Owner

simonw commented Jun 8, 2020

To show how they work. Also useful to confirm how they interact with the default permissions.

@simonw simonw added this to the Datasette 0.44 milestone Jun 8, 2020
simonw added a commit that referenced this issue Jun 8, 2020
Also fixed it so default permission checks run after plugin permission checks, refs #818
@simonw
Copy link
Owner Author

simonw commented Jun 8, 2020

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

I want to build a plugin that does Authorization: Bearer xxx API key authentication.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

datasette-auth-bearer perhaps?

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

Problem with that is it's more of a actor_from_request opportunity than permission_allowed. You could use actor_from_request to authenticate API clients from their Authorization: header, then use the regular "allow" blocks in metadata.json to actually assign their permissions.

The most interesting permissions plugin would be one that implements permissions against some kind of database schema, hence allowing admins to edit permissions through writable canned queries.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

I'm dropping this from the 0.44 milestone.

@simonw simonw modified the milestones: Datasette 0.44, Datasette 1.0 Jun 9, 2020
simonw added a commit that referenced this issue Jun 10, 2020
Also documented policy that plugin hooks should not be shipped without a real example. Refs #818
@simonw
Copy link
Owner Author

simonw commented Jun 10, 2020

New policy in 9f236c4 dictates that this should be in Milestone 0.44 after all:

  • New plugin hooks should only be shipped if accompanied by a separate release of a non-demo plugin that uses them.

@simonw simonw modified the milestones: Datasette 1.0, Datasette 0.44 Jun 10, 2020
@simonw
Copy link
Owner Author

simonw commented Jun 10, 2020

What's a simple but useful plugin I could release that exercises this hook?

Ideally one which executes permission checks against the database somehow.

I could do a simplest-possible implementation of the idea in #801 (allow-by-query).

@simonw simonw added the large label Jun 10, 2020
@simonw
Copy link
Owner Author

simonw commented Jun 10, 2020

datasette-permissions-sql

plugins:
  datasette-permissions-sql:
    view-instance: |-
      select count(*) from users where admin = 1 and id = :id

@simonw
Copy link
Owner Author

simonw commented Jun 11, 2020

@simonw simonw closed this as completed Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant