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

feat(web): Added admin user config to user settings #15380

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nosajthenitram
Copy link

Noticed a lack of ability to create an admin user without having to dump to psql in docker. This adds the admin user switch to the bottom of the user settings.

image

It also prevents the current user from removing their admin privilege by disabling the user admin switch.

@bo0tzz
Copy link
Member

bo0tzz commented Jan 16, 2025

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

@danieldietzler
Copy link
Member

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

Yup. And your diff of the generated files looks pretty broken, please fix that and your tests @nosajthenitram

@nosajthenitram
Copy link
Author

nosajthenitram commented Jan 16, 2025

I believe currently with this it would be possible for the last admin to remove their own admin permissions, right?

Yup. And your diff of the generated files looks pretty broken, please fix that and your tests @nosajthenitram

It shouldn't be possible for the last admin to remove admin rights for themselves, as there's a disable switch condition based on whether or not the current user is equal to the selected user. Would need to think through the race condition of two admins removing one another's rights at the same time.

Will clean up the generated file as well as look at some test augmentation.

@alextran1502
Copy link
Contributor

Would need to think through the race condition of two admins removing one another's rights at the same time.

You can probably put this in a queue and check for the database before making the changes in the database

@bo0tzz
Copy link
Member

bo0tzz commented Jan 16, 2025

A database lock could be appropriate, I think doing it through a queue is unnecessarily complex. What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

@alextran1502
Copy link
Contributor

What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

I like this idea, @nosajthenitram. Can we go with this instead?

@nosajthenitram
Copy link
Author

nosajthenitram commented Jan 16, 2025

A database lock could be appropriate, I think doing it through a queue is unnecessarily complex. What I think would be a better/more useful safety measure is to add an immich-admin subcommand to promote a user to admin.

The immich-admin commands utilizes the same underlying psql queries, which doesn't offer any additional atomic database access. Why is this the preferred method? Seems as though the same race condition would exist, just moving it from the web to the server?

@alextran1502 Can you elaborate on the immich-admin as the preferred method?

@bo0tzz
Copy link
Member

bo0tzz commented Jan 16, 2025

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

@nosajthenitram
Copy link
Author

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

Gotcha, in addition to the Web control a command to grant admin access to a user. Not necessarily the primary use case, but a CYA.

@nosajthenitram
Copy link
Author

The idea is to not try all too hard to prevent the problem (disabling the toggle like you already do should make it exceedingly rare already), but make it really easy to fix instead with an admin command.

Gotcha, in addition to the Web control a command to grant admin access to a user. Not necessarily the primary use case, but a CYA.

@danieldietzler prefer a single branch with the immich-admin command and web interface updates? Or multi-branch since someone else is responsible for server features?

@danieldietzler
Copy link
Member

@nosajthenitram if you're happy to do both, feel free to put it all in this PR. It shouldn't be too much in total.

@nosajthenitram
Copy link
Author

@nosajthenitram if you're happy to do both, feel free to put it all in this PR. It shouldn't be too much in total.

@danieldietzler I've added commands for grant and remove admin (figured why bother with a one way street, someone may find the remove command useful in automation), and it's a not a huge changeset

@bo0tzz
Copy link
Member

bo0tzz commented Jan 17, 2025

I think you may have forgotten to push your changes?

@nosajthenitram
Copy link
Author

I think you may have forgotten to push your changes?

No, I'm trying to figure out why server tests are failing (storage related, nothing I've changed) and adding some tests as recommended above. I'm completely new to this code base, so it's taking some time to understand how it's all thrown together.

@bo0tzz
Copy link
Member

bo0tzz commented Jan 17, 2025

All good, no rush!

@nosajthenitram
Copy link
Author

ok, tests added and files cleaned up. let's see how this goes :D

Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good overall, just some minor nits :)

e2e/src/web/specs/useradmin.e2e-spec.ts Outdated Show resolved Hide resolved
server/src/services/cli.service.ts Outdated Show resolved Hide resolved
i18n/en.json Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants