-
Notifications
You must be signed in to change notification settings - Fork 823
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
Add buildtask and dev URL permissions #10979
Add buildtask and dev URL permissions #10979
Conversation
@andrewandante Feel free to |
1dedee0
to
41f2f7d
Compare
Thanks @GuySartorelli - I think this is in a good space, aside from the test. I'm having a bit of trouble turning off the While devving this I've noticed that it needs a companion PR |
I think the problem is the environment type. Debug::dump([
'requested' => $requestedDevBuild,
'isDev' => Director::isDev(),
'CLI-and-allowed' => (Director::is_cli() && $allowAllCLI),
'admin' => Permission::check("ADMIN"),
'all-dev' => Permission::check("ALL_DEV_ADMIN"),
]); Looks like just setting the environment variable isn't enough to flip the switch, so we need to call DevelopmentAdmin::config()->set('allow_all_cli', false);
$kernel = Injector::inst()->get(Kernel::class);
$env = $kernel->getEnvironment();
$kernel->setEnvironment(Kernel::LIVE);
try {
// ..... do all your test stuff
} finally {
$kernel->setEnvironment($env);
} |
f319ee3
to
004ee95
Compare
Good job, I like the idea 👍 |
004ee95
to
d43015f
Compare
Thanks team, updated the wording based on your recommendations 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Do you have any thoughts about "see" vs "view", and "run" vs "execute" as per #10979 (review)? I think it might be good to use consistent language there but It's not a deal breaker either way IMO. |
Yeah it should definitely be cleaned up. I think "view" and "execute" feel the most correct. Will consolidate and squash |
ENH add granular dev url permissions
2394dbe
to
3244b44
Compare
With the adjustment to priority 80 in the GraphQL module PR |
Interesting - it looks like the way this works is that it only triggers the confirmation if the user has a permission that it thinks is behind the URL - if I'm understanding correctly, this means this list: /~https://github.com/silverstripe/silverstripe-framework/blob/5/_config/requestprocessors.yml#L100-L101 I could add the list of new permissions to this but it feels a bit flaky? It means that each time a new task/permission or whatever gets added, that would need to also be added to the config - and would be easy to forget. The alternative would be to add some sort of wildcard check, rather than "just" I'm not certain on the best approach to this. It feels like writing a |
We wouldn't be able to set the Possible solutions:
In either of 1 or 2 you're gonna need a way to call the relevant Of all of these I think I like 4 the most, as it feels like the least spaghetti solution. It also has the added bonus of making the permission codes for a given In some of these scenarios, if |
Alright, after a lot of experimentation, I've added a specific DevAdmin middleware. Determining the final controller was too difficult inside the existing middleware implementation so this was cleanest I think, and should "absorb" additional |
fee0f73
to
78444a4
Compare
Looking good - but there's still a few more things to tidy up Problem running some tasksWhen I run a dev/task with someone who does have permissions for That doesn't happen with all tasks - I only tried the "Deletes all temporary test databases" task (which gives that output) and the "Login Session Garbage Collection Task" (which works correctly and gives the normal output). If might just be that the "Deletes all temporary test databases" task doesn't actually work for arbitrary users, and needs a
|
Thanks again for your thorough testing! For the first point, the TestDatabases task has a specific permissions check for For the Last point - good point, will check in on that. Probably need to find some way to check permissions on the parent. Phew! |
Hmm. So I'm working on the dev/build endpoint, and for a reason I haven't tracked down yet, it wants to move me to Edit: it's coming from |
Alright I think with all that, I've resolved those three concerns |
Awesome, nice work! I'll take a proper look on Monday and put it through its paces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only change needed, at a glance.
015ab72
to
b9b891d
Compare
It's veeeeery nearly there. All of the permissions are working great, now the only problem is the one from #10979 (comment) where I still see "Running Task Deletes all temporary test databases". The task doesn't actually run because the |
Ah yep, I see the issue there. The "can view all tasks" permission means that you can see the task, but the My instinct here is to actually update the Actually it kind of feels like the |
There is no I think the if ($task->hasMethod('canView') && !$task->canView()) {
// skip, disallow, can't view it can't run it, not allowed.
} That logic could probably be put into the This should be fine in terms of backwards compatibility, because a |
Exactly, an API break 😉 Yeah I think with what you've proposed it means the task overrides the global permission, which is probably more intuitive. I might have to update one of the descriptions to reflect that, but it does make sense. |
Oh, you were meaning you proposed introducing a new method? It's not an API break to add new methods so long as those methods aren't abstract. But in this case I don't think we need a new init method. |
Test failures seem unrelated to my changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
MariaDB failures are unrelated - see silverstripe/silverstripe-graphql#561 and #11046
Introduces
canInit()
methods on Development admin controllers, and respectscanView()
permission checks onBuildTask
sIssue