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

Editing a user doesn't have constraints for the admin user #974

Open
skateman opened this issue Dec 7, 2020 · 7 comments
Open

Editing a user doesn't have constraints for the admin user #974

skateman opened this issue Dec 7, 2020 · 7 comments

Comments

@skateman
Copy link
Member

skateman commented Dec 7, 2020

In the UI the user editing form (and controller) doesn't allow the user to change the name or the assigned groups of the admin user. However, this is not the case in the API and it is possible to rename the admin user or assign it to certain groups which I think might break RBAC stuff.

Ideally these constraints should be in the DB model, but we don't really do that because that might hurt db seeding so I guess we should mimic the behavior of the UI in the API.

@miq-bot assign @gtanzillo
@miq-bot add_label bug
cc @Fryguy

@Fryguy
Copy link
Member

Fryguy commented Dec 7, 2020

Can you link to specific code...I agree it should move to the model, actually, but it depends on the specifics

@Fryguy
Copy link
Member

Fryguy commented Dec 7, 2020

I'd be ok with this in the model. I don't think it will affect specs, but if it does we could, worst case, always wrap the validation in an unless Rails.env.test?

@kbrock
Copy link
Member

kbrock commented Dec 7, 2020

For this case, putting in the model probably make sense.

But we're hitting more and more use cases where we have business logic in the controllers and no good place to duplicate this logic in the api controllers. Not duplicating it would be even better.

I'm ok making a slew of changes across all tests to avoid the one off manner of Rails.env.test?
Specifically with users and requiring tenants and groups, we've (I've) made quite a few changes across the board to make them behave in tests with a test only kludge.

It would be nice if we could keep in mind that we need a more permanent recipe for where we want to put this controller logic in a more sustainable place.

@skateman
Copy link
Member Author

skateman commented Dec 8, 2020

It would be nice if we could keep in mind that we need a more permanent recipe for where we want to put this controller logic in a more sustainable place.

These are more like constrains that should be in the model, at least that's where I'd put them in my own hypothetical Rails app 🤔

@skateman skateman changed the title Editing a user doesn't have constrains for the admin user Editing a user doesn't have constraints for the admin user Dec 8, 2020
@Fryguy
Copy link
Member

Fryguy commented Dec 8, 2020

@skateman I agree. Generally, constraints that apply to all users should be in the model (or even the database)...things like specific value ranges, enums, certain validations. Some things we can't put in the model, particular if they only apply to a subset of users, or if they prevent standard backend usage like deleting records.

In this particular case, while this is a user-specific change, that user in question is well-defined, and I think the model is an appropriate place.

@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2023

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@Fryguy Fryguy removed the stale label Mar 2, 2023
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

6 participants