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

Way to enable a default=False permission for anonymous users #825

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

Way to enable a default=False permission for anonymous users #825

simonw opened this issue Jun 9, 2020 · 6 comments

Comments

@simonw
Copy link
Owner

simonw commented Jun 9, 2020

I'd like plugins to be able to ship with a default that says "anonymous users cannot do this", but allow site administrators to over-ride that such that anonymous users can use the feature after all.

This is tricky because right now the anonymous user doesn't have an actor dictionary at all, so there's no key to match to an allow block.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

Idea: the anonymous actor could be passed to actor_matches_allow() as:

{"anonymous": true}

Then allow blocks like this could be used to allow them:

{
    "plugins": {
        "datasette-upload-csvs": {
            "allow": {
                 "anonymous": true
            }
        }
    }
}

simonw added a commit that referenced this issue Jun 9, 2020
@simonw simonw changed the title Way to open a default False permission to anonymous users Way to enable a default=False permission for anonymous users Jun 9, 2020
@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

I'm torn between anonymous and anon - because the latter is less typing, and I envisage people writing a lot of code like this:

    if actor.get("anonymous"):
        # ...

I'm going with anonymous because it's that tiny bit clearer than anon.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

Alternative design: leave actor alone. Instead specify that allow blocks can look like this:

{
    "allow": {
        "unauthenticated": true
    }
}

I like this: the above block is very self-documenting.

The "id": "*" mechanism means there is already precedent for allow keys with special meaning.

I'm going with this design.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

When I implement this I should also document default allow vs default deny as a concept, and specify that default next to every documented permission.

@simonw simonw closed this as completed in 7633b9a Jun 9, 2020
@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

simonw added a commit that referenced this issue Jun 9, 2020
simonw added a commit that referenced this issue Jun 12, 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