-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Configuration option to determine permissions with a SQL query #46
Comments
Getting this to work with orgs and teams is a bit less obvious. We don't have a guaranteed efficient method of retrieving ALL of the orgs and teams that a user is a member of - instead, the existing code works by running an HTTP check for "is user X a member of team/org Y" for each of the configured options: datasette-auth-github/datasette_auth_github/github_auth.py Lines 181 to 210 in bf01f8f
So... maybe the SQL query should have an option of returning an instruction that says "check if the user is a member of these orgs/teams". Perhaps it could return results that look like this:
This would mean "behave as if "allow_orgs" was ["myorg"] and "allow_teams" was ["otherorg/team1"] |
In terms of available binding parameters for use in the SQL query, we could use anything in the datasette-auth-github/datasette_auth_github/github_auth.py Lines 254 to 259 in bf01f8f
I think we should only use |
I don't like The
|
I think there are two allowed return types for the SQL query. It can return a single row with a single value of OR it can return one or more rows of two columns, where the first column is a entity type and the second column is an allowed value for that entity. This mirrors the existing In fact, the returned query results should look like this for consistency with the plugin config language:
|
Spotted an implementation challenge: in order to execute a SQL query against an attached database, we need access to a That's not generally available in the It IS available in the plugin hook though (so that we can read the Datasette plugin configuration): datasette-auth-github/datasette_auth_github/__init__.py Lines 6 to 8 in b3aaa4c
So maybe the way to implement this is with a |
This can happen in Datasette core instead: simonw/datasette#801 |
It would be neat if you could add a SQL query to the plugins configuration which helps determine if the current user should be allowed access.
That way users could maintain their own table of allowed GitHub users in one of the attached SQLite databases, hence being able to grant access to new individuals without editing the plugin configuration and restarting the server.
Something like this could work:
The
allow_sql_database
property specifies which attached database the query should be executed against. It would be optional: if you leave it off then the first (or ideally the only) attached database would be used.The text was updated successfully, but these errors were encountered: