public inbox for [email protected]help / color / mirror / Atom feed
[PATCH] pgweb: auth.py: make it possible to customize email address in error message 5+ messages / 3 participants [nested] [flat]
* [PATCH] pgweb: auth.py: make it possible to customize email address in error message @ 2023-12-19 16:51 Célestin Matte <[email protected]> 0 siblings, 2 replies; 5+ messages in thread From: Célestin Matte @ 2023-12-19 16:51 UTC (permalink / raw) To: pgsql-www auth.py contains an error message with an hardcoded @postgresql.org email address. This patch makes it possible to change it using a variable in the settings. I used ADMINS because it already exists in pgweb with the correct value (and pgarchives), but that can be discussed as it doesn't exist in pglister. -- Célestin Matte Attachments: [text/x-patch] 0001-auth.py-make-it-possible-to-customize-email-address-.patch (1.7K, 2-0001-auth.py-make-it-possible-to-customize-email-address-.patch) download | inline diff: From 0943570f333379bc1235d60f169dc6e9721ec0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]> Date: Tue, 19 Dec 2023 17:47:41 +0100 Subject: [PATCH] auth.py: make it possible to customize email address in error message --- tools/communityauth/sample/django/auth.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py index b6f60674..3cb32387 100644 --- a/tools/communityauth/sample/django/auth.py +++ b/tools/communityauth/sample/django/auth.py @@ -153,16 +153,20 @@ def auth_receive(request): # somehow fix that live, give a proper error message and # have somebody look at it manually. if User.objects.filter(email=data['e'][0]).exists(): + if hasattr(settings, 'ADMINS') and len(settings.ADMINS) > 0: + contact = settings.ADMINS[0][1] + else: + contact = "[email protected]" return HttpResponse("""A user with email %s already exists, but with a different username than %s. This is almost certainly caused by some legacy data in our database. -Please send an email to [email protected], indicating the username +Please send an email to %s, indicating the username and email address from above, and we'll manually merge the two accounts for you. We apologize for the inconvenience. -""" % (data['e'][0], data['u'][0]), content_type='text/plain') +""" % (data['e'][0], data['u'][0], contact), content_type='text/plain') if getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK', None): res = getattr(settings, 'PGAUTH_CREATEUSER_CALLBACK')( -- 2.43.0 ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] pgweb: auth.py: make it possible to customize email address in error message @ 2023-12-20 16:05 Akshat Jaimini <[email protected]> parent: Célestin Matte <[email protected]> 1 sibling, 0 replies; 5+ messages in thread From: Akshat Jaimini @ 2023-12-20 16:05 UTC (permalink / raw) To: Célestin Matte <[email protected]>; [email protected] We actually have a new tool that tests all the functionalities in the website. So just wanted to run it through that before. I'll run the tests against your gitlab mirror. Checkout the harness here: https://github.com/destrex271/pgweb-testing-harness Regards, Akshat Jaimini On Wed, 20 Dec, 2023, 20:11 Célestin Matte, <[email protected]> wrote: > Hello, > > Not sure what you're asking — I don't have access to the pgweb repo > Do you mean a pull request? > My local copy is on gitlab: > https://gitlab.com/cmatte/pgweb/-/tree/auth_email?ref_type=heads > > Regards, > > On 20/12/2023 14:32, Akshat Jaimini wrote: > > Hi! > > It would be great if we could test this patch with the testing harness > to confirm that nothing would break(although I am sure nothing would but > there's no harm in testing). > > > > Is it possible to setup a develop/testing branch on the pgweb repo from > where the harness can pull it? > > > > Regards, > > Akshat Jaimini > > > > On Tue, 19 Dec, 2023, 22:21 Célestin Matte, <[email protected] > <mailto:[email protected]>> wrote: > > > > auth.py contains an error message with an hardcoded @postgresql.org > <http://postgresql.org; email address. > > This patch makes it possible to change it using a variable in the > settings. > > I used ADMINS because it already exists in pgweb with the correct > value (and pgarchives), but that can be discussed as it doesn't exist in > pglister. > > > > -- > > Célestin Matte > > > > -- > Célestin Matte > > ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] pgweb: auth.py: make it possible to customize email address in error message @ 2023-12-20 19:16 Magnus Hagander <[email protected]> parent: Célestin Matte <[email protected]> 1 sibling, 1 reply; 5+ messages in thread From: Magnus Hagander @ 2023-12-20 19:16 UTC (permalink / raw) To: Célestin Matte <[email protected]>; +Cc: pgsql-www On Tue, Dec 19, 2023 at 5:51 PM Célestin Matte <[email protected]> wrote: > > auth.py contains an error message with an hardcoded @postgresql.org email address. > This patch makes it possible to change it using a variable in the settings. > I used ADMINS because it already exists in pgweb with the correct value (and pgarchives), but that can be discussed as it doesn't exist in pglister. Maybe the correct choice is to actually add it to pglister? That said, having a fallback is probably still a good idea since we have loads of servers that run this auth.py plugin, but for the pglister specific thing I think that would be a reasonable thing to expect? -- Magnus Hagander Me: https://www.hagander.net/ Work: https://www.redpill-linpro.com/ ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] pgweb: auth.py: make it possible to customize email address in error message @ 2023-12-21 17:39 Célestin Matte <[email protected]> parent: Magnus Hagander <[email protected]> 0 siblings, 1 reply; 5+ messages in thread From: Célestin Matte @ 2023-12-21 17:39 UTC (permalink / raw) To: Magnus Hagander <[email protected]>; pgsql-www > Maybe the correct choice is to actually add it to pglister? Alright, patched for pglister attached. Also attached a patch for pgarchives, because while ADMINS is defined, there is no default value. (Note: this variable is only used for auth.py) -- Célestin Matte Attachments: [text/x-patch] 0001-Add-ADMINS-to-settings.py-for-error-message-in-auth..patch (783B, 2-0001-Add-ADMINS-to-settings.py-for-error-message-in-auth..patch) download | inline diff: From 60c26a951a459393e45e13eb8544cfec67737013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]> Date: Thu, 21 Dec 2023 18:32:28 +0100 Subject: [PATCH] Add ADMINS to settings.py for error message in auth.py --- web/pglister/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/pglister/settings.py b/web/pglister/settings.py index 122768d..243115f 100644 --- a/web/pglister/settings.py +++ b/web/pglister/settings.py @@ -14,6 +14,10 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ import os import sys +ADMINS = ( + ('PostgreSQL Webmaster', '[email protected]'), +) + BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Import the shared lib directory with non-django stuff -- 2.43.0 [text/x-patch] 0001-Give-default-value-to-ADMINS-in-settings.py-for-erro.patch (724B, 3-0001-Give-default-value-to-ADMINS-in-settings.py-for-erro.patch) download | inline diff: From a7607c761e7ac28b9b59aa6075eef795b76797c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]> Date: Thu, 21 Dec 2023 18:35:49 +0100 Subject: [PATCH] Give default value to ADMINS in settings.py for error message in auth.py --- django/archives/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/archives/settings.py b/django/archives/settings.py index 24861a9..97f17cf 100644 --- a/django/archives/settings.py +++ b/django/archives/settings.py @@ -4,7 +4,7 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( - # ('Your Name', '[email protected]'), + ('PostgreSQL Webmaster', '[email protected]'), ) MANAGERS = ADMINS -- 2.43.0 ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [PATCH] pgweb: auth.py: make it possible to customize email address in error message @ 2025-12-01 20:14 Magnus Hagander <[email protected]> parent: Célestin Matte <[email protected]> 0 siblings, 0 replies; 5+ messages in thread From: Magnus Hagander @ 2025-12-01 20:14 UTC (permalink / raw) To: Célestin Matte <[email protected]>; +Cc: pgsql-www On Thu, 21 Dec 2023 at 18:39, Célestin Matte <[email protected]> wrote: > > Maybe the correct choice is to actually add it to pglister? > > Alright, patched for pglister attached. > Also attached a patch for pgarchives, because while ADMINS is defined, > there is no default value. (Note: this variable is only used for auth.py) > Once again sorry to be ridiculously late :) Realizing that this auth.py code is shared along basically all postgresql.org properties, I think the conditional way is the right way to do it. I don't think we should prepopulate a value of [email protected] into the ADMIN values in the configs -- but we should add an empty one. so I've pushed that change for now. //Magnus ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2025-12-01 20:14 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-12-19 16:51 [PATCH] pgweb: auth.py: make it possible to customize email address in error message Célestin Matte <[email protected]> 2023-12-20 16:05 ` Akshat Jaimini <[email protected]> 2023-12-20 19:16 ` Magnus Hagander <[email protected]> 2023-12-21 17:39 ` Célestin Matte <[email protected]> 2025-12-01 20:14 ` Magnus Hagander <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox