Allow user to manage user pools - #4
Conversation
| update_params = pool_params | ||
| update_params[:active] = update_params.has_key?(:active) && | ||
| update_params[:active] == "true" | ||
| if @pool.update(update_params) |
| end | ||
| else | ||
| # for non-admin allow only updating active state to prevent | ||
| # pools stealing and other mistakes |
There was a problem hiding this comment.
I am not really sure this logic is even necessary here. See my comment about auth.
| if params["controller"] == "locks" && | ||
| ["create", "update", "lock_from_pool"].include?(params["action"]) | ||
| ["create", "update", "lock_from_pool"].include?(params["action"]) || | ||
| params["controller"] == "pools" && |
There was a problem hiding this comment.
I don't think we should allow user to modify the pools. Should we? The most we should allow user IMO is to disable an entry (as a separate safe action). But any other pools modifications should be only allowed to the master user as far as I can tell.
This would ensure user can at most do a DoS attack but not mess up everything.
I am not against having API access to modify pools in all possible ways. It just makes more sense to me to do that with master auth.
There was a problem hiding this comment.
Totally agreed. Added separate method to just disable pool, will modify update method so API could be used to update any info with master credentials..
|
Hi, it's nice that you look at this. See my line comments. wrt your suggestion, the requirement to pass all params to locks was for some safety checking to avoid stealing locks from each other. |
| post '/locks/from_pool(.:format)' => 'locks#lock_from_pool', as: "create_from_pool" | ||
|
|
||
| match '/pools/disable(.:format)' => 'pools#disable', via: [:put, :patch], as: "disable_pool" | ||
| resources :pools |
There was a problem hiding this comment.
@akostadinov I was confused here a bit, when I'm changing the order of these two lines request on /pools/disable redirected to pools#update method..
Will need more time to become familiar with all RoR stuff..
There was a problem hiding this comment.
Probably order of precedence. Because put and patch are used for update usually. You need to list routes with both orders to see what's the difference. bin/rails routes
There was a problem hiding this comment.
@akostadinov Yeah, exactly. Just was confused that it works for locks fine, but in locks you changing the same update method..
|
Do you have any proposal how to make deactivation of pools on the CucuShift side? |
|
If I understand the question correctly, if login fails, then we can make user manages issue a disable call. Not sure if it will be straightforward to catch this when trying to use user. If not, we can use the clean-up in user manager to disable any users that cannot be cleaned-up properly. This btw makes sense anyway. If we fail to clean-up user, then it might be invalid. |
|
@akostadinov Actually I wanted to deactivate only tokens, because Can you review changes in this PR? Let me know if anything need to be fixed! |
|
@maybelinot , just recently you added ldap pool. With LDAP, same pool can be used for multiple environments. If for some reason a user becomes broken in one env and we want it disabled, but if we disable the pool entry, then we will effectively disable it for all of the environments using that LDAP pool. That's why having a long lock will allow locking for particular env only. Does this make more sense to you now? P.S. and that's why I suggested call to disable pool entry to be allowed only for admin |
|
@akostadinov Yeah, now it makes more sense.. But I expected this to be more kind of helpful or .. I don't know..
And third option is yours(this one would be the most infrequent, I think):
I would suggest to add another parameter for pool:
And lock only pools with |
|
If idea is to catch invalid pools (or incomplete env user setup), then doing disable operations would make little to no sense. But I see your primary use case is to detect expired tokens in pools with tokens. But how do you know if token expired or you used wrong pool? How about including the config in pool specification. e.g. |
|
Lets discuss this pull in a short meeting. |
| # concurrency issue or not matching name/resource specification | ||
| @persisted = false | ||
| @errors = ["conflict with existing pool or not matching name/resource"] | ||
| render status: :conflict |
There was a problem hiding this comment.
I think that this condition can only happen when pool entry is not found. Perhaps change to :not_found and the respective @errors message. I don't see any possibility to be a conflict. Probably using this update approach instead of normal Rails update is an overkill. But I think all we need is nod_found and a proper @error.
|
One question - you want to disable pool entries from cucushift automatically or just have a call to run manually? |
|
I imagine this to be automatically |
@akostadinov can you review changes please?
one question: Would it be better to update only those values which were provided with request? For example if
:noteparameter was skipped then ownthat will not rewrite its value on empty, WDYT?PS: will add unit tests soon