-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
nixos/mysql: add authentication option #68353
Conversation
Add an authentication option to be able to create mysql users that do not authenticate using the unix_socket plugin, since this requires the username to exist on the host system. (https://mariadb.com/kb/en/library/authentication-plugin-unix-socket/)
I was under the impression that |
Hm good point how should we deal with that? I could move the hashes to a file or add a warning. I want this option because I want to be able to add users that do not require a unix account on the host |
@Scriptkiddi I'm planning some work on the |
@Scriptkiddi @florianjacob @talyz @ryantm very rough first pass at an addition to the Example usage:
Note this is entirely backwards compatible with existing |
@aanderse Using |
@talyz sounds like a bug. I wonder if @infinisil has any thoughts on that, as I've seen him use it a fair amount. |
|
Thanks @infinisil, that looks better. I'm still hoping to hear more opinions about whether this sort of change is something we actually want in nixos. Clearly @Scriptkiddi wants this change, as they opened this PR. I think I'm in favor of this change. Is anyone against these types of changes to nixos? This might be a good time to ping @danbst, @aszlig, and @thoughtpolice as the idea is that these changes would make their way into the |
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.
As a rule I'm against options which add "best effort", imperative options to Nix. Deleting a user from these settings doesn't delete the user from the system, and I think that is something we want to avoid in NixOS.
A good hint that the option either doesn't belong or doesn't function properly is having the word ensure
in the name.
@grahamc I understand your points and agree. While I think this PR provides value, maybe the value comes at too high a cost, and doesn't fit quite right into nixos? I know @talyz was also interested in this functionality, so I'll ask @talyz and @Scriptkiddi if they have anything to add at this point? |
@grahamc @aanderse I agree that it's definitely not ideal, but find it a necessary evil. The alternatives I can think of seem worse to me:
Am I missing a better alternative? Also, note that this is not actually about |
I am joining the discussion, because I needed to extend the postgresql module to run a script after the creation of a database specified in ensureDatabases. I implemented this option in https://github.com/petabyteboy/nixpkgs/commit/d86208eb4ee23ca1f345c96b04bb0f7ce3a5d0bf and was made aware of this discussion by @aanderse
Fine for me, this was my initial approach, but others did request that the database is created automatically and the schema is loaded into the database after initial creation, which required this change
...
I definitely prefer less duplication of code in the modules => Maybe we can make it an internal option so that it is not directly exposed to users? |
I think manual intervention is probably okay, as long as its well documented. It does feel like it would detract somewhat from NixOS’s value proposition of “write all your configuration in configuration.nix” if a bunch of commands are needed to set up initial state as well, though. |
Alyssa Ross <notifications@github.com> writes:
I think manual intervention is probably okay, as long as its well
documented. It does feel like it would detract somewhat from NixOS’s
value proposition of “write all your configuration in
configuration.nix” if a bunch of commands are needed to set up initial
state as well, though.
To phrase this another way, what's the difference between a package
creating its initial state on startup itself, and us doing it? What
makes one okay and not the other?
|
Since I'm new to NixOs, couldnt we just modify the ensure script to delete users? |
@Scriptkiddi we can't distinguish users that were configured via NixOS previously from users created by an admin, and don't want to delete these by accident, I assume. |
You could add a not delete list or something like it to, protect users that are added another way |
Exactly. My solution to this would be to reimplement the missing functionality in my configuration to not have to do it manually (since I'm deploying systems with NixOps) and I'm sure others would do the same. We'd end up with the same thing, but worse. |
I found out this isn't the first PR to discuss in depth user provisioning for the I'm still hoping @danbst and @aszlig will chime in with their opinions and reasoning on those opinions. @davidak, @copumpkin, and @edolstra may also have opinions on the topic of in depth user creation for the |
Regarding As this was one of my first big NixOS contributions, I chose the defensive prefix If the community decides though that such options don't belong in NixOS and all users and module authors should go back and write their own bash scripts for that, I will accept that and stop proposung such options. Regarding this specific PR: Seems like a good way to handle passwords for remote users (can't see why one should use that for anything that runs on the same host though) if a secure password hashing is used and / or the hash is stored in a non-accessible location. The default unsalted SHA1 hashing really isn't much better than plaintext passwords. MariaDB offers https://mariadb.com/kb/en/authentication-plugin-ed25519/ and MySQL offers authentication-plugin-sha256 (why are both not using or at least offering actual password hashing functions? No idea…) |
@@ -153,6 +153,20 @@ in | |||
Name of the user to ensure. | |||
''; | |||
}; | |||
authentication_option = mkOption { | |||
type = types.str; |
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.
I'd suggest a more specific type:
with types; enum ["socket" "password"]
@@ -406,7 +420,7 @@ in | |||
|
|||
${concatMapStrings (user: | |||
'' | |||
( echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' IDENTIFIED WITH ${if isMariaDB then "unix_socket" else "auth_socket"};" | |||
( echo "CREATE USER IF NOT EXISTS '${user.name}'@'localhost' ${optionalString (user.authentication_option == "password") ''IDENTIFIED BY PASSWORD '${user.password_hash}' ''} ${optionalString (user.authentication_option == "socket") ''IDENTIFIED WITH ${if isMariaDB then "unix_socket" else "auth_socket"} ''};" |
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.
A few issues:
- line too long, should fit 100 columns
- what happens when password is changed? As I understand it, user already exists so his password will silently remain the same. This is bad. Please do run ALTER USER to change password hash when it was changed in NixOS config
- same for
authentication_option
How are the chances of getting this merged? I'm willing to put in the work, but I don't want it to sit there open like the postgresql pr |
@Scriptkiddi sorry for the delay on this. We're scheduling a call to discuss the best way forward. More details to come. |
@aanderse Hey :), any news? |
@Scriptkiddi yes! @grahamc, @flokli, and myself had a chat about this last week. We all agreed that declarative, reproducible database provisioning in the NixOS module system is a good thing. Currently we have declarative provisioning but we decided we want to take this a step further and make it reproducible, so that the To that end we have decided a program/script needs to be written to handle user and database provisioning, in the same way that a program/script exists to manage system user accounts in NixOS. The program/script would take a A couple notes...
I'm really hoping a few people from this thread will be interested in hacking on this. @Scriptkiddi, @talyz, @florianjacob ... maybe @petabyteboy - any interest? PS. @talyz since this is a fairly breaking change it is a great time to design module options from ground up! So all the goodness ( |
Hello, I'm a bot and I thank you in the name of the community for your contributions. Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do: If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list. If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past. If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments. Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel. |
Closing in favor of #94048. |
Add an authentication option to be able to create mysql users that do
not authenticate using the unix_socket plugin, since this requires the
username to exist on the host system.
(https://mariadb.com/kb/en/library/authentication-plugin-unix-socket/)
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @