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

wordpress: replace the dbPassword option with dbPasswordFile #24146

Merged
merged 1 commit into from Mar 28, 2017

Conversation

basvandijk
Copy link
Member

We shouldn't force users to store passwords in the world-readable Nix store so this commit replaces the dbPassword option with dbPasswordFile which should be set to a file that contains the wordpress DB password. Users can then provision this file however they want, either by storing it unsafely in the Nix store using pkgs.writeTextFile or safely using something like nixops key management.

It would be great if this can also be cherry-picked on release-17.03.

@mention-bot
Copy link

@basvandijk, thanks for your PR! By analyzing the history of the files in this pull request, we identified @qknight, @grahamc and @ehmry to be potential reviewers.

@globin
Copy link
Member

globin commented Mar 21, 2017

I'd prefer to have both options.

@basvandijk
Copy link
Member Author

basvandijk commented Mar 21, 2017

@globin I prefer to make users conscious about the safety of their keys. An option like dbPassword kind of hides the fact that the key is stored in the world-readable Nix store. Of course documentation can help but not everybody reads that.

The dbPasswordFile option forces users to think where they are going to store the key.

Of course the old unsafe behaviour is easy to recreate using pkgs.writeTextFile as I do in the test.

@basvandijk
Copy link
Member Author

@globin I changed my mind and followed your preference. dbPasswordFile now defaults to a file in the Nix store with the value of dbPassword. I added documentation to warn users about the security issues.

The nice thing is that this is also backwards compatible.

@LnL7
Copy link
Member

LnL7 commented Mar 21, 2017

It's possible to add warnings when using certain options.

@RonnyPfannschmidt
Copy link
Contributor

RonnyPfannschmidt commented Mar 22, 2017

btw, as is, this one is a breaking change

@basvandijk
Copy link
Member Author

@RonnyPfannschmidt what breaks because of this change?

@RonnyPfannschmidt
Copy link
Contributor

@basvandijk any user that has this already configured afterwards has a broken configuration, because the old thing is gone, there is not the slightest hint of a transition help either

@basvandijk
Copy link
Member Author

@RonnyPfannschmidt the old thing isn't gone. The change should be backwards compatible.

@RonnyPfannschmidt
Copy link
Contributor

indeed, i am sorry, i missed the pkgs.writeTextFile bit

example = "wordpress";
};
dbPasswordFile = mkOption {
type = types.str;
default = toString (pkgs.writeTextFile {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, but I think more complex defaults like this are usually moved to the implementation with a mkDefault

Copy link
Member

Choose a reason for hiding this comment

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

Correct, otherwise the manual is rebuilt when dbPassword changes in your config.

Copy link
Member

@LnL7 LnL7 Mar 22, 2017

Choose a reason for hiding this comment

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

Also, where's the config attrset for this module?

Copy link
Member Author

Choose a reason for hiding this comment

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

@globin note that wordpress is not mentioned in the manual.

@LnL7 wordpress.nix is not a traditional NixOS module and doesn't have a config attribute. It should be used as:

{ 
  services.httpd.extraSubservices = [
    { serviceType = "wordpress";
      dbName = "...";
      themes = [];
      plugins = [];
    }
  ];
}

So there's no need and no place to use mkDefault.

Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't force users to store passwords in the world-readable Nix store.
@basvandijk
Copy link
Member Author

basvandijk commented Mar 22, 2017

Similarly to other web-apps I added an example to the dbPasswordFile option: "/run/keys/wordpress-dbpassword".

Is there anything that prevents this being mergeable?

@qknight
Copy link
Member

qknight commented Mar 24, 2017

love this concept, we should not stop at password(s) though. wordpress also contains other key materials as AUTH_KEY, AUTH_SALT, ... shown here:

 https://api.wordpress.org/secret-key/1.1/salt/

same is true for owncloud/nextcloud and so on.

@basvandijk
Copy link
Member Author

basvandijk commented Mar 24, 2017

@qknight thanks and I agree that AUTH_KEY and so forth should not be placed in the Nix store as well. However at the moment the wordpress module doesn't set these parameters so (apart from the dbPassword option) users aren't currently being forced to do something unsafe.

@qknight qknight merged commit 6f2eca1 into NixOS:master Mar 28, 2017
@basvandijk
Copy link
Member Author

@qknight thanks for the merge! Can this also be cherry-picked on release-17.03? I would like to use this in production.

Krofek pushed a commit to Krofek/nixpkgs that referenced this pull request Mar 30, 2017
…4146)

We shouldn't force users to store passwords in the world-readable Nix store.
@basvandijk
Copy link
Member Author

Hi @qknight, it would be great if you can cherry pick this on release-17.03.

@qknight
Copy link
Member

qknight commented May 5, 2017

@basvandijk added it to release-17.03 just now. please check if it works for you.

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.

None yet

7 participants