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

Menu options should not be displayed without a permission check #98

Open
simonw opened this issue Sep 7, 2023 · 1 comment
Open

Menu options should not be displayed without a permission check #98

simonw opened this issue Sep 7, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@simonw
Copy link
Owner

simonw commented Sep 7, 2023

I spotted this:

CleanShot 2023-09-07 at 10 45 04@2x

That's a public table on a private instance - the GraphQL link shows a permission denied error, so that link should not be there (for the database or table or main menu).

This isn't a security bug since actually clicking the link doesn't do anything useful, but it's a usability bug.

@simonw simonw added the bug Something isn't working label Sep 7, 2023
@simonw
Copy link
Owner Author

simonw commented Sep 7, 2023

Relevant code:

@hookimpl
def menu_links(datasette, actor):
graphql_path = _graphql_path(datasette)
return [
{"href": datasette.urls.path(graphql_path), "label": "GraphQL API"},
]

@hookimpl
def table_actions(datasette, actor, database, table):
async def inner():
graphql_path = datasette.urls.path(
"{}/{}".format(_graphql_path(datasette), database)
)
db_schema = await schema_for_database_via_cache(datasette, database=database)
try:

@hookimpl
def database_actions(datasette, actor, database):
graphql_path = _graphql_path(datasette)
if len(datasette.databases) > 1:
return [
{
"href": datasette.urls.path("{}/{}".format(graphql_path, database)),
"label": "GraphQL API for {}".format(database),
}
]

Should use this method to check permissions:

async def check_permissions(request, datasette, database):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant