Lists: | Postg젠 토토SQL : |
---|
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Parametrization minimum password lenght |
Date: | 2024-11-12 13:41:00 |
Message-ID: | CA+ugDNyYtHOtWCqVD3YkSVYDWD_1fO8Jm_ahsDGA5dXhbDPwrQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
The goal about this patch is to parameterize the minimum password lenght on
users database and apply it on the general code.
The patch is applicable to the master branch.
We already tested it: it build and works as expected and nothing is found
broken,
Settings in postgresql.conf parametrization like following:
shared_preload_libraries = 'passwordcheck'
min_password_lenght = 12
example:
postgres=# create user prova with password 'eftghaki';
ERROR: password is too short
postgres=# create user prova with password 'eftghaki1234';
CREATE ROLE
In attach the file patch.
Best regards
Emanuele Musella & Maurizio Boriani
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v1.patch | application/octet-stream | 1.7 KB |
From: | Tomas Vondra <tomas(at)vondra(dot)me> |
---|---|
To: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-12 13:48:28 |
Message-ID: | 5702ea42-3599-4062-bd15-3e3c7cc67e6e@vondra.me |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On 11/12/24 14:41, Emanuele Musella wrote:
> The goal about this patch is to parameterize the minimum password lenght
> on users database and apply it on the general code.
> The patch is applicable to the master branch.
> We already tested it: it build and works as expected and nothing is
> found broken,
>
> Settings in postgresql.conf parametrization like following:
>
> shared_preload_libraries = 'passwordcheck'
> min_password_lenght = 12
>
> example:
>
> postgres=# create user prova with password 'eftghaki';
> ERROR: password is too short
> postgres=# create user prova with password 'eftghaki1234';
> CREATE ROLE
>
>
> In attach the file patch.
>
Thanks for the patch, seems like a useful feature. Please add the patch
to the next commitfest (2025-01) at https://commitfest.postgresql.org/
A couple comments:
1) The proper spelling is "length" (not "lenght").
2) The GUC should be added to the "passwordcheck" extension, not to the
core GUC file. See how auto_explain defines options in _PG_init() using
DefineCustomIntVariable.
3) It might be a good idea to add a test to passwordcheck.sql.
regards
--
Tomas Vondra
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-13 16:54:56 |
Message-ID: | CA+ugDNyPNMqFADM20J6+qeAqmc1=Kxiuff29xz93-3k2zWFu3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi Tomas,
we have done the fixes that you have suggested us in the last mail.
1) Modified passwordcheck.sql with a_nice_long_password and also
passwordcheck.out
2) we added the documentation in the doc/src/sgml/passwordcheck.sgml.
3) we have done make check successfully.
If you have other suggestions to share with us will be welcommed.
Thank you
Best regards
Il giorno mar 12 nov 2024 alle ore 16:49 Tomas Vondra <tomas(at)vondra(dot)me> ha
scritto:
> On 11/12/24 16:36, Emanuele Musella wrote:
> > Hi Tomas,
> >
> > thank you for you feedback.
> >
> > We have implemented you suggestion in the patch. I attached you the
> > latest version.
> >
>
> Please always reply to the mailing list, not just directly to individual
> people. Otherwise others won't see your new messages, it won't get into
> mailing list archives, etc.
>
> > We are waiting for your last feedback to upload the patch on Commitfest.
> >
>
> Not sure I follow. You can add the patch to the commitfest on your own,
> and there's no need to wait for my feedback before doing so.
>
> A couple quick comments for the patch, though:
>
> 1) You modified just the SQL script for the test, not the expected
> output in expected/passwordcheck.out. This means running "make check"
> for this extension will fail.
>
> 2) It's not clear to me why you removed the first ALTER TABLE with
> a_nice_long_password. Seems wrong.
>
> 3) The test doesn't change the new GUC at all, so how would this show
> the setting actually affects anything? And you only test the "positive"
> case, maybe it'd be good to change the GUC and then test that it rejects
> a password.
>
> 4) The new GUC needs to be added to doc/src/sgml/passwordcheck.sgml.
>
>
> regards
>
> --
> Tomas Vondra
>
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v4.patch | application/octet-stream | 3.8 KB |
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Tomas Vondra <tomas(at)vondra(dot)me> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-18 09:01:41 |
Message-ID: | CA+ugDNz7nGan_zjX__ZzDMxnPviaRWrtrNicTZseF4wskbu2hw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg젠 토토SQL : |
Hi all,
we have fixed the following warning from the CFbot:
[07:14:29.637] passwordcheck.c:37:5: error: no previous extern declaration
for non-static variable 'min_password_length'
[-Werror,-Wmissing-variable-declarations]
In attach the fixed patch.
Best regards
Il giorno mer 13 nov 2024 alle ore 17:54 Emanuele Musella <
emamuse86(at)gmail(dot)com> ha scritto:
> Hi Tomas,
>
> we have done the fixes that you have suggested us in the last mail.
>
> 1) Modified passwordcheck.sql with a_nice_long_password and also
> passwordcheck.out
>
> 2) we added the documentation in the doc/src/sgml/passwordcheck.sgml.
>
> 3) we have done make check successfully.
>
> If you have other suggestions to share with us will be welcommed.
>
> Thank you
>
> Best regards
>
>
>
> Il giorno mar 12 nov 2024 alle ore 16:49 Tomas Vondra <tomas(at)vondra(dot)me>
> ha scritto:
>
>> On 11/12/24 16:36, Emanuele Musella wrote:
>> > Hi Tomas,
>> >
>> > thank you for you feedback.
>> >
>> > We have implemented you suggestion in the patch. I attached you the
>> > latest version.
>> >
>>
>> Please always reply to the mailing list, not just directly to individual
>> people. Otherwise others won't see your new messages, it won't get into
>> mailing list archives, etc.
>>
>> > We are waiting for your last feedback to upload the patch on Commitfest.
>> >
>>
>> Not sure I follow. You can add the patch to the commitfest on your own,
>> and there's no need to wait for my feedback before doing so.
>>
>> A couple quick comments for the patch, though:
>>
>> 1) You modified just the SQL script for the test, not the expected
>> output in expected/passwordcheck.out. This means running "make check"
>> for this extension will fail.
>>
>> 2) It's not clear to me why you removed the first ALTER TABLE with
>> a_nice_long_password. Seems wrong.
>>
>> 3) The test doesn't change the new GUC at all, so how would this show
>> the setting actually affects anything? And you only test the "positive"
>> case, maybe it'd be good to change the GUC and then test that it rejects
>> a password.
>>
>> 4) The new GUC needs to be added to doc/src/sgml/passwordcheck.sgml.
>>
>>
>> regards
>>
>> --
>> Tomas Vondra
>>
>>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v5.patch | application/octet-stream | 3.8 KB |
From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Tomas Vondra <tomas(at)vondra(dot)me> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-18 10:39:33 |
Message-ID: | ZzsZZY3YrO6hinnT@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Mon, Nov 18, 2024 at 10:01:41AM +0100, Emanuele Musella wrote:
> Hi all,
>
> we have fixed the following warning from the CFbot:
>
> [07:14:29.637] passwordcheck.c:37:5: error: no previous extern declaration
> for non-static variable 'min_password_length'
> [-Werror,-Wmissing-variable-declarations]
>
>
> In attach the fixed patch.
Thanks for the patch, that looks like a useful feature!
A few random comments:
=== 1
+ * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
+ * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
I'm not sure we do that usually. For example, in cb3384a0cb, Fabien Coelho has
not been mentioned as an author in contrib/isn/isn.c.
=== 2
#include "commands/user.h"
#include "fmgr.h"
#include "libpq/crypt.h"
+#include "commands/explain.h"
+#include "utils/guc.h"
The "includes" should be in the order based on their ASCII value (see 7e735035f2).
=== 3
+/* min_password_length minimum password length */
I think "/* Minimum password length */ is "enough" for the comment.
Also what about adding "/* GUC variables */" on top of it?
=== 4 (Nit)
+static int min_password_length;
What about "min_pwd_len" to make it consistent with pwd_has_letter and pwd_has_nonletter
for example?
=== 5
prev_check_password_hook = check_password_hook;
check_password_hook = check_password;
+
+ /* Define custom GUC variables. */
+ DefineCustomIntVariable("passwordcheck.min_password_length",
What about moving the DefineCustomIntVariable before the hooks? (that would be
consistent with auto_explain.c, auth_delay.c, autoprewarm.c and pg_stat_statements.c
to name a few).
=== 6
+ "8 is default.",
I don't think that's needed (that would be visible from pg_settings.extra_desc
while it already provides the information through the boot_val field).
=== 7
+ GUC_UNIT_MS,
Not the right unit, that should be GUC_UNIT_BYTE because...
=== 8
postgres=# SET passwordcheck.min_password_length = 4;
SET
postgres=# create user test with password 'ab1';
ERROR: password is too short
But with multibyte in play:
postgres=# create user test with password 'äb1';
CREATE ROLE.
That's because "strlen(password);" returns the number of bytes.
We could make it based on the characters instead by using "pg_mbstrlen()"
but that would break the behavior as compared to now. So, I think we
just need to make it clear that's bytes instead.
=== 9
I think that a call to MarkGUCPrefixReserved() is missing (see auto_explain.c
for example).
=== 10
+ <para>
+ In <filename>postgresql.conf</filename> you may set the minimum password length
+ by setting passwordcheck.min_password_length = INT.
I think that would make sense to add a "Configuration Parameters" section and
follow the format done in auto-explain or pg_prewarm for example.
=== 11
+ The default minimum password length if not setted passwordcheck.min_password_length is 8 chars.
s/chars/bytes/ (as per === 8 above)
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-18 15:59:53 |
Message-ID: | CA+ugDNw4KR+j98Lp=GX6gnra=1cshQQuDp5shQw=gBVKZiebHw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello Bertrand,
thank you for your feedbacks.
We have done every fixes required.
In attach the last version.
Best regards
Il giorno lun 18 nov 2024 alle ore 11:39 Bertrand Drouvot <
bertranddrouvot(dot)pg(at)gmail(dot)com> ha scritto:
> Hi,
>
> On Mon, Nov 18, 2024 at 10:01:41AM +0100, Emanuele Musella wrote:
> > Hi all,
> >
> > we have fixed the following warning from the CFbot:
> >
> > [07:14:29.637] passwordcheck.c:37:5: error: no previous extern
> declaration
> > for non-static variable 'min_password_length'
> > [-Werror,-Wmissing-variable-declarations]
> >
> >
> > In attach the fixed patch.
>
> Thanks for the patch, that looks like a useful feature!
>
> A few random comments:
>
> === 1
>
> + * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
> + * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
>
> I'm not sure we do that usually. For example, in cb3384a0cb, Fabien Coelho
> has
> not been mentioned as an author in contrib/isn/isn.c.
>
> === 2
>
> #include "commands/user.h"
> #include "fmgr.h"
> #include "libpq/crypt.h"
> +#include "commands/explain.h"
> +#include "utils/guc.h"
>
> The "includes" should be in the order based on their ASCII value (see
> 7e735035f2).
>
> === 3
>
> +/* min_password_length minimum password length */
>
> I think "/* Minimum password length */ is "enough" for the comment.
>
> Also what about adding "/* GUC variables */" on top of it?
>
> === 4 (Nit)
>
> +static int min_password_length;
>
> What about "min_pwd_len" to make it consistent with pwd_has_letter and
> pwd_has_nonletter
> for example?
>
> === 5
>
> prev_check_password_hook = check_password_hook;
> check_password_hook = check_password;
> +
> + /* Define custom GUC variables. */
> + DefineCustomIntVariable("passwordcheck.min_password_length",
>
> What about moving the DefineCustomIntVariable before the hooks? (that
> would be
> consistent with auto_explain.c, auth_delay.c, autoprewarm.c and
> pg_stat_statements.c
> to name a few).
>
> === 6
>
> + "8 is default.",
>
> I don't think that's needed (that would be visible from
> pg_settings.extra_desc
> while it already provides the information through the boot_val field).
>
> === 7
>
> + GUC_UNIT_MS,
>
> Not the right unit, that should be GUC_UNIT_BYTE because...
>
> === 8
>
> postgres=# SET passwordcheck.min_password_length = 4;
> SET
> postgres=# create user test with password 'ab1';
> ERROR: password is too short
>
> But with multibyte in play:
>
> postgres=# create user test with password 'äb1';
> CREATE ROLE.
>
> That's because "strlen(password);" returns the number of bytes.
>
> We could make it based on the characters instead by using "pg_mbstrlen()"
> but that would break the behavior as compared to now. So, I think we
> just need to make it clear that's bytes instead.
>
> === 9
>
> I think that a call to MarkGUCPrefixReserved() is missing (see
> auto_explain.c
> for example).
>
> === 10
>
> + <para>
> + In <filename>postgresql.conf</filename> you may set the minimum
> password length
> + by setting passwordcheck.min_password_length = INT.
>
> I think that would make sense to add a "Configuration Parameters" section
> and
> follow the format done in auto-explain or pg_prewarm for example.
>
> === 11
>
> + The default minimum password length if not setted
> passwordcheck.min_password_length is 8 chars.
>
> s/chars/bytes/ (as per === 8 above)
>
> Regards,
>
> --
> Bertrand Drouvot
> PostgreSQL Contributors Team
> RDS Open Source Databases
> Amazon Web Services: https://aws.amazon.com
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v6.patch | application/octet-stream | 4.9 KB |
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-18 16:21:18 |
Message-ID: | CA+ugDNzcEEgcLvC2w-LMjfWXKSb9btEBcRnDTkfgviT_eVEkAA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
We notice some errors on CFBot results.
In attached the errors fixed
Il giorno lun 18 nov 2024 alle ore 16:59 Emanuele Musella <
emamuse86(at)gmail(dot)com> ha scritto:
> Hello Bertrand,
>
> thank you for your feedbacks.
>
> We have done every fixes required.
>
> In attach the last version.
>
> Best regards
>
> Il giorno lun 18 nov 2024 alle ore 11:39 Bertrand Drouvot <
> bertranddrouvot(dot)pg(at)gmail(dot)com> ha scritto:
>
>> Hi,
>>
>> On Mon, Nov 18, 2024 at 10:01:41AM +0100, Emanuele Musella wrote:
>> > Hi all,
>> >
>> > we have fixed the following warning from the CFbot:
>> >
>> > [07:14:29.637] passwordcheck.c:37:5: error: no previous extern
>> declaration
>> > for non-static variable 'min_password_length'
>> > [-Werror,-Wmissing-variable-declarations]
>> >
>> >
>> > In attach the fixed patch.
>>
>> Thanks for the patch, that looks like a useful feature!
>>
>> A few random comments:
>>
>> === 1
>>
>> + * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
>> + * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
>>
>> I'm not sure we do that usually. For example, in cb3384a0cb, Fabien
>> Coelho has
>> not been mentioned as an author in contrib/isn/isn.c.
>>
>> === 2
>>
>> #include "commands/user.h"
>> #include "fmgr.h"
>> #include "libpq/crypt.h"
>> +#include "commands/explain.h"
>> +#include "utils/guc.h"
>>
>> The "includes" should be in the order based on their ASCII value (see
>> 7e735035f2).
>>
>> === 3
>>
>> +/* min_password_length minimum password length */
>>
>> I think "/* Minimum password length */ is "enough" for the comment.
>>
>> Also what about adding "/* GUC variables */" on top of it?
>>
>> === 4 (Nit)
>>
>> +static int min_password_length;
>>
>> What about "min_pwd_len" to make it consistent with pwd_has_letter and
>> pwd_has_nonletter
>> for example?
>>
>> === 5
>>
>> prev_check_password_hook = check_password_hook;
>> check_password_hook = check_password;
>> +
>> + /* Define custom GUC variables. */
>> + DefineCustomIntVariable("passwordcheck.min_password_length",
>>
>> What about moving the DefineCustomIntVariable before the hooks? (that
>> would be
>> consistent with auto_explain.c, auth_delay.c, autoprewarm.c and
>> pg_stat_statements.c
>> to name a few).
>>
>> === 6
>>
>> + "8 is default.",
>>
>> I don't think that's needed (that would be visible from
>> pg_settings.extra_desc
>> while it already provides the information through the boot_val field).
>>
>> === 7
>>
>> + GUC_UNIT_MS,
>>
>> Not the right unit, that should be GUC_UNIT_BYTE because...
>>
>> === 8
>>
>> postgres=# SET passwordcheck.min_password_length = 4;
>> SET
>> postgres=# create user test with password 'ab1';
>> ERROR: password is too short
>>
>> But with multibyte in play:
>>
>> postgres=# create user test with password 'äb1';
>> CREATE ROLE.
>>
>> That's because "strlen(password);" returns the number of bytes.
>>
>> We could make it based on the characters instead by using "pg_mbstrlen()"
>> but that would break the behavior as compared to now. So, I think we
>> just need to make it clear that's bytes instead.
>>
>> === 9
>>
>> I think that a call to MarkGUCPrefixReserved() is missing (see
>> auto_explain.c
>> for example).
>>
>> === 10
>>
>> + <para>
>> + In <filename>postgresql.conf</filename> you may set the minimum
>> password length
>> + by setting passwordcheck.min_password_length = INT.
>>
>> I think that would make sense to add a "Configuration Parameters" section
>> and
>> follow the format done in auto-explain or pg_prewarm for example.
>>
>> === 11
>>
>> + The default minimum password length if not setted
>> passwordcheck.min_password_length is 8 chars.
>>
>> s/chars/bytes/ (as per === 8 above)
>>
>> Regards,
>>
>> --
>> Bertrand Drouvot
>> PostgreSQL Contributors Team
>> RDS Open Source Databases
>> Amazon Web Services: https://aws.amazon.com
>>
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v7.patch | application/octet-stream | 5.0 KB |
From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-19 19:28:03 |
Message-ID: | Zzzmw4IAvrypmFO4@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Mon, Nov 18, 2024 at 05:21:18PM +0100, Emanuele Musella wrote:
> We notice some errors on CFBot results.
FWIW, you can run "cfbot like" tests on your own repo (see [1]).
> In attached the errors fixed
Thanks for the updated version!
A few random comments:
=== 1
trailing whitespace:
$ git apply min_password_length_v7.patch
min_password_length_v7.patch:130: trailing whitespace.
There is a configuration parameter that control the behavior
warning: 1 line adds whitespace errors.
=== 2
+ * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
+ * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
Same comment as in [2].
=== 3
- int pwdlen = strlen(password);
+ int pwdlen = pg_mbstrlen(password);
Sorry if I was not clear in [2], but I meant to say to keep using strlen() to be
consistent with the current behavior.
=== 4
+ GUC_UNIT_BYTE,
this is correct if strlen() is used (see above comment).
=== 5
+ 0, INT_MAX,
INT_MAX seems too large and 0 too low. Maybe we should not allow less than it
was before the patch (8). For the max, maybe something like PG_MAX_AUTH_TOKEN_LENGTH?
(see the comment in src/backend/libpq/auth.c)
=== 6
+ There is a configuration parameter that control the behavior
+ <filename>passwordcheck</filename>
s/behavior/behavior of/?
=== 7
+ <varname>passwordcheck.min_password_length</varname> is the minimum length
+ of accepted password on database users.
+ If not setted the default is 8 bytes.
What about? "is the minimum password length in bytes. The default is 8."
=== 7
+
+<programlisting>
+# postgresql.conf
+session_preload_libraries = 'passwordcheck'
+passwordcheck.min_password_length = 12
+
+</programlisting>
What about a sentence before? Something like for auto_explain means "In ordinary
usage, these parameters are set in postgresql.conf,............"
[1]: https://github.com/postgres/postgres/blob/master/src/tools/ci/README
[2]: /message-id/ZzsZZY3YrO6hinnT%40ip-10-97-1-34.eu-west-3.compute.internal
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Tomas Vondra <tomas(at)vondra(dot)me> |
Cc: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-19 22:45:40 |
Message-ID: | Zz0VFNPmIkn_dRcV@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Nov 12, 2024 at 02:48:28PM +0100, Tomas Vondra wrote:
> Thanks for the patch, seems like a useful feature. Please add the patch
> to the next commitfest (2025-01) at https://commitfest.postgresql.org/
FYI, I have a large set of such things in my own repo with a clone of
passwordcheck:
https://github.com/michaelpq/pg_plugins/tree/main/passwordcheck_extra
Not all of them may be useful, still the minimal length is one of
them:
- passwordcheck_extra.special_chars, to define a list of special characters
with the password needing at least one. Default is "!(at)#$%^&*()_+{}|<>?=".
- passwordcheck_extra.restrict_lower, to enforce the use of at least one
lower-case character.
- passwordcheck_extra.restrict_upper, to enforce the use of at least one
upper-case character.
- passwordcheck_extra.restrict_numbers, to enforce the use of at least
one number.
- passwordcheck_extra.restrict_special, to enforce the use of at least
one special character listed in \"passwordcheck_extra.special_chars\".
- passwordcheck_extra.minimum_length, minimum length of password allowed.
Default is 8, which likely sucks.
- passwordcheck_extra.maximum_length, maximum length of password allowed.
Default is 15, which definitely sucks, but it is useful for tests.
I would not mind if you just copy-paste some of this stuff, and the
code is released under the PostgreSQL license. Feel free to not worry
about the authorship part as well, I'm fine even if my name is
discarded.
--
Michael
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Tomas Vondra <tomas(at)vondra(dot)me>, Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-21 22:25:38 |
Message-ID: | Zz-zYk7OCTK8k_Jp@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Nov 20, 2024 at 07:45:40AM +0900, Michael Paquier wrote:
> On Tue, Nov 12, 2024 at 02:48:28PM +0100, Tomas Vondra wrote:
>> Thanks for the patch, seems like a useful feature. Please add the patch
>> to the next commitfest (2025-01) at https://commitfest.postgresql.org/
>
> FYI, I have a large set of such things in my own repo with a clone of
> passwordcheck:
> https://github.com/michaelpq/pg_plugins/tree/main/passwordcheck_extra
Here is some previous discussion about passwordcheck that may be of
interest:
/message-id/flat/D960CB61B694CF459DCFB4B0128514C203937F49%40exadv11.host.magwien.gv.at
/message-id/flat/AC785D69-41EC-4D0A-AC37-1F9FF55C9E34%40amazon.com
--
nathan
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-25 10:15:51 |
Message-ID: | CA+ugDNzwu_8_ZMfj4oGOfqMEJJii1u3tLg2a2o5+PVnk8zYcQQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Thank you Bertrand for your feedbacks. We are looking for CFbot part so we
can compile it like CFbot.
For now we have fixed all points.
Thank you
Il giorno mar 19 nov 2024 alle ore 20:28 Bertrand Drouvot <
bertranddrouvot(dot)pg(at)gmail(dot)com> ha scritto:
> Hi,
>
> On Mon, Nov 18, 2024 at 05:21:18PM +0100, Emanuele Musella wrote:
> > We notice some errors on CFBot results.
>
> FWIW, you can run "cfbot like" tests on your own repo (see [1]).
>
> > In attached the errors fixed
>
> Thanks for the updated version!
>
> A few random comments:
>
> === 1
>
> trailing whitespace:
>
> $ git apply min_password_length_v7.patch
> min_password_length_v7.patch:130: trailing whitespace.
> There is a configuration parameter that control the behavior
> warning: 1 line adds whitespace errors.
>
> === 2
>
> + * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
> + * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
>
> Same comment as in [2].
>
> === 3
>
> - int pwdlen = strlen(password);
> + int pwdlen = pg_mbstrlen(password);
>
> Sorry if I was not clear in [2], but I meant to say to keep using strlen()
> to be
> consistent with the current behavior.
>
> === 4
>
> + GUC_UNIT_BYTE,
>
> this is correct if strlen() is used (see above comment).
>
> === 5
>
> + 0, INT_MAX,
>
> INT_MAX seems too large and 0 too low. Maybe we should not allow less than
> it
> was before the patch (8). For the max, maybe something like
> PG_MAX_AUTH_TOKEN_LENGTH?
> (see the comment in src/backend/libpq/auth.c)
>
> === 6
>
> + There is a configuration parameter that control the behavior
> + <filename>passwordcheck</filename>
>
> s/behavior/behavior of/?
>
> === 7
>
> + <varname>passwordcheck.min_password_length</varname> is the minimum
> length
> + of accepted password on database users.
> + If not setted the default is 8 bytes.
>
> What about? "is the minimum password length in bytes. The default is 8."
>
> === 7
>
> +
> +<programlisting>
> +# postgresql.conf
> +session_preload_libraries = 'passwordcheck'
> +passwordcheck.min_password_length = 12
> +
> +</programlisting>
>
> What about a sentence before? Something like for auto_explain means "In
> ordinary
> usage, these parameters are set in postgresql.conf,............"
>
> [1]: https://github.com/postgres/postgres/blob/master/src/tools/ci/README
> [2]:
> /message-id/ZzsZZY3YrO6hinnT%40ip-10-97-1-34.eu-west-3.compute.internal
>
> Regards,
>
> --
> Bertrand Drouvot
> PostgreSQL Contributors Team
> RDS Open Source Databases
> Amazon Web Services: https://aws.amazon.com
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v8.patch | application/octet-stream | 4.4 KB |
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-11-25 17:35:49 |
Message-ID: | CA+ugDNzgsF49E2qZ_aPUyV3EepS9RcD4Lp91pnbR4Z8+=FTFRQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Sorry here the right attachment
Il giorno lun 25 nov 2024 alle ore 11:15 Emanuele Musella <
emamuse86(at)gmail(dot)com> ha scritto:
> Thank you Bertrand for your feedbacks. We are looking for CFbot part so we
> can compile it like CFbot.
>
> For now we have fixed all points.
>
> Thank you
>
> Il giorno mar 19 nov 2024 alle ore 20:28 Bertrand Drouvot <
> bertranddrouvot(dot)pg(at)gmail(dot)com> ha scritto:
>
>> Hi,
>>
>> On Mon, Nov 18, 2024 at 05:21:18PM +0100, Emanuele Musella wrote:
>> > We notice some errors on CFBot results.
>>
>> FWIW, you can run "cfbot like" tests on your own repo (see [1]).
>>
>> > In attached the errors fixed
>>
>> Thanks for the updated version!
>>
>> A few random comments:
>>
>> === 1
>>
>> trailing whitespace:
>>
>> $ git apply min_password_length_v7.patch
>> min_password_length_v7.patch:130: trailing whitespace.
>> There is a configuration parameter that control the behavior
>> warning: 1 line adds whitespace errors.
>>
>> === 2
>>
>> + * Author: Maurizio Boriani <maurizio(at)boriani(dot)cloud>
>> + * Author: Emanuele Musella <emamuse86(at)gmail(dot)com>
>>
>> Same comment as in [2].
>>
>> === 3
>>
>> - int pwdlen = strlen(password);
>> + int pwdlen = pg_mbstrlen(password);
>>
>> Sorry if I was not clear in [2], but I meant to say to keep using
>> strlen() to be
>> consistent with the current behavior.
>>
>> === 4
>>
>> + GUC_UNIT_BYTE,
>>
>> this is correct if strlen() is used (see above comment).
>>
>> === 5
>>
>> + 0, INT_MAX,
>>
>> INT_MAX seems too large and 0 too low. Maybe we should not allow less
>> than it
>> was before the patch (8). For the max, maybe something like
>> PG_MAX_AUTH_TOKEN_LENGTH?
>> (see the comment in src/backend/libpq/auth.c)
>>
>> === 6
>>
>> + There is a configuration parameter that control the behavior
>> + <filename>passwordcheck</filename>
>>
>> s/behavior/behavior of/?
>>
>> === 7
>>
>> + <varname>passwordcheck.min_password_length</varname> is the
>> minimum length
>> + of accepted password on database users.
>> + If not setted the default is 8 bytes.
>>
>> What about? "is the minimum password length in bytes. The default is 8."
>>
>> === 7
>>
>> +
>> +<programlisting>
>> +# postgresql.conf
>> +session_preload_libraries = 'passwordcheck'
>> +passwordcheck.min_password_length = 12
>> +
>> +</programlisting>
>>
>> What about a sentence before? Something like for auto_explain means "In
>> ordinary
>> usage, these parameters are set in postgresql.conf,............"
>>
>> [1]: https://github.com/postgres/postgres/blob/master/src/tools/ci/README
>> [2]:
>> /message-id/ZzsZZY3YrO6hinnT%40ip-10-97-1-34.eu-west-3.compute.internal
>>
>> Regards,
>>
>> --
>> Bertrand Drouvot
>> PostgreSQL Contributors Team
>> RDS Open Source Databases
>> Amazon Web Services: https://aws.amazon.com
>>
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v9.patch | application/octet-stream | 4.1 KB |
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-18 20:56:24 |
Message-ID: | Z2M2-CoenHUsqz2G@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Here is what I have staged for commit.
--
nathan
Attachment | Content-Type | Size |
---|---|---|
v10-0001-Add-passwordcheck.min_password_length.patch | text/plain | 5.8 KB |
From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-19 07:25:30 |
Message-ID: | Z2PKagtsPVs4wTNf@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
On Wed, Dec 18, 2024 at 02:56:24PM -0600, Nathan Bossart wrote:
> Here is what I have staged for commit.
Thanks!
A few comments:
=== 1
+ if (pwdlen < min_password_length)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("password is too short")));
Now that the minimum password length is not "hardcoded" anymore, I wonder if it
wouldn't be better to provide more details here (pwdlen and min_password_length).
Suggestion in on_top_of_0001.txt attached.
=== 2
+ /* Define custom GUC variables. */
+ DefineCustomIntVariable("passwordcheck.min_password_length",
+ "Minimum allowed password length.",
+ NULL,
+ &min_password_length,
+ 8,
+ 0, INT_MAX,
Since password must contain both letters and nonletters, 0 seems too low. I
wonder if 2 is not a better value (done in on_top_of_0001.txt attached).
Also, it seems to me that INT_MAX is too large (as mentioned in [1]), but that's
probably a nit.
[1]: /message-id/Zzzmw4IAvrypmFO4%40ip-10-97-1-34.eu-west-3.compute.internal
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
on_top_of_0001.txt | text/plain | 1.4 KB |
From: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-19 10:22:02 |
Message-ID: | CA+ugDNx=c7MFQJHXaOaeYwz-viBjEt7EcY-apYFgHZoT4V76Og@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi Nathan,
thank you.
It seems to me you are working on an older version of patch.
In attached the latest one for your reference.
Thanks for your support
Best regards
Emanuele Musella
Il giorno mer 18 dic 2024 alle ore 21:56 Nathan Bossart <
nathandbossart(at)gmail(dot)com> ha scritto:
> Here is what I have staged for commit.
>
> --
> nathan
>
Attachment | Content-Type | Size |
---|---|---|
min_password_length_v9.patch | application/octet-stream | 4.1 KB |
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Cc: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-19 15:36:17 |
Message-ID: | Z2Q9cQFqFpEnTqDm@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Dec 19, 2024 at 07:25:30AM +0000, Bertrand Drouvot wrote:
> + if (pwdlen < min_password_length)
> ereport(ERROR,
> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
> errmsg("password is too short")));
>
> Now that the minimum password length is not "hardcoded" anymore, I wonder if it
> wouldn't be better to provide more details here (pwdlen and min_password_length).
>
> Suggestion in on_top_of_0001.txt attached.
Yeah, good point.
> + /* Define custom GUC variables. */
> + DefineCustomIntVariable("passwordcheck.min_password_length",
> + "Minimum allowed password length.",
> + NULL,
> + &min_password_length,
> + 8,
> + 0, INT_MAX,
>
> Since password must contain both letters and nonletters, 0 seems too low. I
> wonder if 2 is not a better value (done in on_top_of_0001.txt attached).
>
> Also, it seems to me that INT_MAX is too large (as mentioned in [1]), but that's
> probably a nit.
I don't think we need to restrict the allowed values here. It's true that
the lower bound will be effectively 2 due to the other checks, but that's
not the responsibility of this one to enforce. Those other checks will
likely become configurable at some point, too.
> - errmsg("password is too short")));
> + errmsg("password is too short: %d (< %d)", pwdlen, min_password_length)));
I think we should explicitly point to the parameter and note its current
value.
--
nathan
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Emanuele Musella <emamuse86(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-19 15:40:25 |
Message-ID: | Z2Q-aWnaSP7Uw2N3@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Dec 19, 2024 at 11:22:02AM +0100, Emanuele Musella wrote:
> It seems to me you are working on an older version of patch.
>
> In attached the latest one for your reference.
I used the v9 patch as the basis for v10. There are a few small edits,
such as removing the upper bound for the parameter and expanding the
documentation, but the feature itself remains intact.
--
nathan
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
Cc: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-19 15:57:31 |
Message-ID: | Z2RCa15Qut91n43u@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Dec 19, 2024 at 09:36:17AM -0600, Nathan Bossart wrote:
> On Thu, Dec 19, 2024 at 07:25:30AM +0000, Bertrand Drouvot wrote:
>> - errmsg("password is too short")));
>> + errmsg("password is too short: %d (< %d)", pwdlen, min_password_length)));
>
> I think we should explicitly point to the parameter and note its current
> value.
Like so.
--
nathan
Attachment | Content-Type | Size |
---|---|---|
v11-0001-Add-passwordcheck.min_password_length.patch | text/plain | 6.2 KB |
From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-20 09:15:28 |
Message-ID: | Z2U1sMCSAIcexeae@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Dec 19, 2024 at 09:57:31AM -0600, Nathan Bossart wrote:
> On Thu, Dec 19, 2024 at 09:36:17AM -0600, Nathan Bossart wrote:
> > On Thu, Dec 19, 2024 at 07:25:30AM +0000, Bertrand Drouvot wrote:
> >> - errmsg("password is too short")));
> >> + errmsg("password is too short: %d (< %d)", pwdlen, min_password_length)));
> >
> > I think we should explicitly point to the parameter and note its current
> > value.
>
> Like so.
LGTM.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From: | Japin Li <japinli(at)hotmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2024-12-25 05:15:53 |
Message-ID: | SY8P300MB04425EC0A61A59347C56380DB60C2@SY8P300MB0442.AUSP300.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, 19 Dec 2024 at 09:57, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> On Thu, Dec 19, 2024 at 09:36:17AM -0600, Nathan Bossart wrote:
>> On Thu, Dec 19, 2024 at 07:25:30AM +0000, Bertrand Drouvot wrote:
>>> - errmsg("password is too short")));
>>> + errmsg("password is too short: %d (< %d)", pwdlen, min_password_length)));
>>
>> I think we should explicitly point to the parameter and note its current
>> value.
>
> Like so.
It seems that the v11 cannot apply on master since 7f97b4734, and rebase is needed.
$ git am ~/v11-0001-Add-passwordcheck.min_password_length.patch
Applying: Add passwordcheck.min_password_length.
error: patch failed: contrib/passwordcheck/passwordcheck.c:26
error: contrib/passwordcheck/passwordcheck.c: patch does not apply
Patch failed at 0001 Add passwordcheck.min_password_length.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
The comment of prev_check_password_hook has been changed which case the apply failed.
--
Regrads,
Japin Li
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Japin Li <japinli(at)hotmail(dot)com> |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2025-01-06 19:32:16 |
Message-ID: | Z3wvwLceb6brtR0P@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Dec 25, 2024 at 01:15:53PM +0800, Japin Li wrote:
> It seems that the v11 cannot apply on master since 7f97b4734, and rebase is needed.
>
> $ git am ~/v11-0001-Add-passwordcheck.min_password_length.patch
> Applying: Add passwordcheck.min_password_length.
> error: patch failed: contrib/passwordcheck/passwordcheck.c:26
> error: contrib/passwordcheck/passwordcheck.c: patch does not apply
> Patch failed at 0001 Add passwordcheck.min_password_length.
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
>
> The comment of prev_check_password_hook has been changed which case the apply failed.
Here is a rebased version of the patch. Barring objections, I am planning
to commit this soon.
--
nathan
Attachment | Content-Type | Size |
---|---|---|
v12-0001-Add-passwordcheck.min_password_length.patch | text/plain | 6.2 KB |
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Japin Li <japinli(at)hotmail(dot)com> |
Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Emanuele Musella <emamuse86(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Parametrization minimum password lenght |
Date: | 2025-01-07 21:08:57 |
Message-ID: | Z32X6cnA2CimeHw-@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Committed.
--
nathan