Skip to content

Conversation

@jiahuili430
Copy link
Contributor

@jiahuili430 jiahuili430 commented May 26, 2021

Overview

Solved conflicts from "cherry-pick" 3.x commit with kdiff3 merge tool.

Testing recommendations

make eunit apps=chttpd suites=chttpd_util_test

Related Issues or Pull Requests

This fixes #3472

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation

@jiahuili430 jiahuili430 marked this pull request as ready for review May 26, 2021 02:35
@jiahuili430 jiahuili430 changed the title move couch_httpd_auth options to chttpd_auth main [WIP] move couch_httpd_auth options to chttpd_auth main May 26, 2021
Solved conflicts from "cherry-pick" 3.x commit with kdiff3 merge tool.
@jiahuili430 jiahuili430 changed the title move couch_httpd_auth options to chttpd_auth main Moved couch_httpd_auth options to chttpd_auth main May 26, 2021
<<"unauthorized">> ->
case config:get("couch_httpd_auth", "authentication_redirect", undefined) of
case chttpd_util:get_chttpd_auth_config(
"authentication_redirect", "/_utils/session.html") of
Copy link
Contributor

Choose a reason for hiding this comment

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

please use undefined as default here to avoid breaking users installations during upgrade.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually never mind. We can update the default on main because it was not released yet. However for 3.x we should preserve existent behavior.

<<"unauthorized">> ->
case config:get("couch_httpd_auth", "authentication_redirect", undefined) of
case chttpd_util:get_chttpd_auth_config(
"authentication_redirect", "/_utils/session.html") of
Copy link
Contributor

@iilyak iilyak May 26, 2021

Choose a reason for hiding this comment

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

please use undefined as default here to avoid breaking users installations during upgrade.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can update the default on main because it was not released yet.

?l2b("-hashed-" ++ couch_util:to_hex(Hash) ++ "," ++ ?b2l(Salt));
hash_admin_password("pbkdf2", ClearPassword) ->
Iterations = config:get("couch_httpd_auth", "iterations", "10000"),
Iterations = chttpd_util:get_chttpd_auth_config("iterations", "10"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the default value back to "10000"

Copy link
Contributor

Choose a reason for hiding this comment

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

On the https://github.com/apache/couchdb/pull/3577/files#diff-47040d0b65ca2cdd2c1a8eea22187c860de02e51bd67ebf14c8287f5b56b26e8R82 the chttpd_util:get_chttpd_auth_config_integer is used. Is it intentional to not use it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Iterations is used in the DerivedKey (line 51 & 54), I need to keep Iterations return String "10" instead of Integer 10.
Thanks for the review, @iilyak

{ClearPassword, "pbkdf2"} ->
ok = validate_password(ClearPassword),
Iterations = list_to_integer(config:get("couch_httpd_auth", "iterations", "1000")),
Iterations = chttpd_util:get_chttpd_auth_config_integer(
Copy link
Contributor

@iilyak iilyak May 26, 2021

Choose a reason for hiding this comment

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

Please change the default value back to 1000.

Copy link
Contributor

Choose a reason for hiding this comment

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

Default work factor was deliberately set to 10 f726bc4. We can switch it to something even higher than 1000 now as replication is using the cookie auth by default, but it probably shouldn't be part of this commit?

If users updated the config value, that value would be in their local.ini or local.d/*.ini files, and it would still be used after this commit.

default.ini file is shipped and replaced by the couchdb packages and users should expect that file to be overwritten [1]. As I understand it, for a while it was the place to store default config settings. Later on we started adding only commented defaults in there and using code default as primary default values. But before that, in some cases, we just forgot to update the code defaults when we updated default.ini value so they got unsynchronized.

[1] https://docs.couchdb.org/en/stable/config/intro.html

Warning: The default.ini file may be overwritten during an upgrade or re-installation, so localised
changes should be made to the local.ini file or files within the local.d directory.

Copy link
Contributor

@iilyak iilyak left a comment

Choose a reason for hiding this comment

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

+1.

@nickva nickva merged commit a19189c into apache:main May 27, 2021
@nickva
Copy link
Contributor

nickva commented May 27, 2021

Thank you for the review @iilyak !

@jiahuili430 jiahuili430 deleted the move-couch_httpd_auth-options-to-chttpd_auth-main branch June 7, 2021 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move all config options out of couch_httpd_auth and httpd

3 participants