Skip to content

wordpress: replace the dbPassword option with dbPasswordFile#24146

Merged
qknight merged 1 commit intoNixOS:masterfrom
LumiGuide:wordpress-dbPasswordFile
Mar 28, 2017
Merged

wordpress: replace the dbPassword option with dbPasswordFile#24146
qknight merged 1 commit intoNixOS:masterfrom
LumiGuide:wordpress-dbPasswordFile

Conversation

@basvandijk
Copy link
Copy Markdown
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
Copy Markdown

@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
Copy Markdown
Member

globin commented Mar 21, 2017

I'd prefer to have both options.

@basvandijk
Copy link
Copy Markdown
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 basvandijk force-pushed the wordpress-dbPasswordFile branch from b5f1ffc to bc52e9b Compare March 21, 2017 02:12
@basvandijk
Copy link
Copy Markdown
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.

@basvandijk basvandijk force-pushed the wordpress-dbPasswordFile branch from bc52e9b to cc191ef Compare March 21, 2017 02:16
@LnL7
Copy link
Copy Markdown
Member

LnL7 commented Mar 21, 2017

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

@fpletz fpletz added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Mar 22, 2017
@RonnyPfannschmidt
Copy link
Copy Markdown
Contributor

RonnyPfannschmidt commented Mar 22, 2017

btw, as is, this one is a breaking change

@basvandijk
Copy link
Copy Markdown
Member Author

@RonnyPfannschmidt what breaks because of this change?

@RonnyPfannschmidt
Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

@RonnyPfannschmidt
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

@basvandijk basvandijk force-pushed the wordpress-dbPasswordFile branch from cc191ef to 29f5d7f Compare March 22, 2017 22:30
We shouldn't force users to store passwords in the world-readable Nix store.
@basvandijk basvandijk force-pushed the wordpress-dbPasswordFile branch from 29f5d7f to d6c2c3c Compare March 22, 2017 22:33
@basvandijk
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@qknight
Copy link
Copy Markdown
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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants