Commit Graph

34 Commits

Author SHA1 Message Date
de76f82f62 Implement authenticated encryption in community auth
This creates a community auth version 3 (previous one being 2, and 1 is
long gone) trhat uses AES_SIV as the encryption method instead of
regular AES_CBC, and validates the digests on all accounts.

As this gets deployed on servers incrementall, the version has to be
specified in the database record for the site. We could have the site
indicate this itself, but doing it this way seems safer as it will then
just break for any app that accidentally reverts the plugin.

Reviewed by Jacob Champion
2025-06-11 20:26:21 +02:00
02d4fa24cc Update to latest version of auth plugin
For some reason, downstream repos had a newer version but we forgot it
in the upstream repo.
2025-04-01 13:01:31 +02:00
071aad3e6c Add some load-time validation of PGAUTH_KEY in the django sample
Will result in a nicer error when the key is wrong, and in particular a
startup error instead of a runtime error.

Reviewed-by: Célestin Matte
2023-08-28 20:49:33 +02:00
e08139df48 Fix arguments in signal calling 2023-06-07 22:17:55 +02:00
cb6076778f Give nicer error message when URL data is corrupt 2023-06-07 21:54:42 +02:00
1b7c1c922b Add new signal auth_user_created_from_upstream to sample
This signal fires when a new user has been created either from the user
logging in the first time or from an import.
2023-06-07 21:46:04 +02:00
ef5ae7db30 Import subscribe_to_user_changes function to sample auth.py
This was used on git.postgresql.org, but hadn't been propagated
upstream.
2023-06-07 21:38:16 +02:00
3e62af803e Fix typo in comment 2020-09-28 17:31:49 +02:00
c1fb5de080 Implement synchronization for community authentication
This adds the concept of an apiurl to each site that uses community
authentication, that the main website server can make calls to and send
updates. This URL will receive POSTs from the main website when a user
account that has been used on this site gets updated, and can then
optionally update it's local entries with it (the django plugin sample
is updated to handle this fully).

Updates are only sent for users that have a history of having logged
into the specific site -- this way we avoid braodcasting user
information to sites requiring specific constent that the user hasn't
given, and also decreases the amount of updates that have to be sent.

Updates are queued by the system in a table and using listen/notify a
daemon that's running picks up what needs to be updated and posts it to
the endpoints. If this daemon is not running, obviously nothing gets
sent.

Updates are tracked using triggers in the database which push
information into this queue.
2020-08-11 11:33:46 +02:00
d969bd33d8 Make django community auth plugin only save changed fields 2020-08-11 11:33:46 +02:00
b97aa1d581 Make user_import in the django auth plugin return the new user
It's useful to be able to directly get at the user record that was
returned instead of having to re-query it from the database. Since
nothing was previously returned, this is not backwards incompatible.
2020-08-10 13:15:50 +02:00
4f1bf70ea0 Remove unused imports 2020-07-13 14:53:07 +02:00
ccb1282531 Update authentication to be django 2 compatible 2020-04-03 19:05:26 +02:00
fa32eff8ae Sync community auth plugin to be the latest-and-greatest
Combine changes from downstream projects (which were not that many
anymore)
2020-02-26 18:04:40 +01:00
12306255ad Switch to using pycryptodome instead of pycrypto
pycrypto is not being maintained, and pycryptodome is theoretically
a drop-in replacement (in practice, it seems it was close)
2019-11-01 14:52:35 +01:00
9b42500478 Import latest auth.py from pgeu as sample 2019-01-26 16:19:26 +01:00
00ab822ea8 Fix deprecated comparison structs 2019-01-17 21:19:57 +01:00
0883ac6423 Fix whitespace and indentation, per pep8 2019-01-17 20:47:43 +01:00
87237f6536 Tabs, meet your new overlords: spaces
In a quest to reach pep8, use spaces to indent rather than tabs.
2019-01-17 15:35:39 +01:00
e62309a391 Fix typos in comments
Review by Stephen Frost and Jonathan S. Katz
Discussion: https://postgr.es/m/6EEB2B47-D274-4E65-83B1-2EF8C917C55F%40yesql.se
2018-12-04 21:51:08 +01:00
7ed70f1067 Add a createuser callback for cauth django plugin
This callback can prevent new users from being created based on specific
criteria. The plugin is defined in settings.py, so it can be any python
code. For example, it can look up in a specific table if this user is
supposed to be allowed to log in at all.
2018-01-13 18:14:13 +01:00
79659ae1dc Add ability to import user to django cauth example
This has been in used around a number of community sites already,
backpatch it into the upstream master.
2018-01-13 18:11:21 +01:00
38ff645d5d Add possibility to turn off django cauth using settings in sample
This sample is used across most of our other sites, so add functionality
to install without having a local master repo.

Back-patch of pgeu commit 3e4d8c9101c2d309b134c2f5638aa40db8ef2cf5
2018-01-13 18:09:27 +01:00
b8dd050611 Fix typo 2016-03-15 09:58:38 +00:00
51c10ee9df Replace simpljson imports with json
This has been in standard python since 2.6, and we don't really care
about supporting anything older than that (even our old and soon to
be upgraded environments use 2.7)
2015-12-12 17:44:22 +01:00
a80790508c Return proper errorcodes in django auth plugin example
Instead of raising an exception which will cause both a server log
and an email to be sent, return a proper http 400 message when the
incoming authentication request is bad. This will also show the
proper error message to the client, instead of a generic internal
server error.
2015-07-08 13:36:56 +01:00
d15abdc301 Remove unused variables 2015-07-08 13:36:56 +01:00
c6c43c1689 Implement user searching in the community auth system
This lets downstream systems securely search for users that are in
the system, so they can populate their local database with users
before they have logged in if necessary. This can be used for example
for the commitfest management system to be able to flag users as
authors and reviewers even before they have logged in.
2014-07-19 15:12:27 +02:00
e839e38976 Sync up auth demo plugin with what's actually used
The newer version is at least used by the pgeu system and by the
new commitfest one, and has some fallback for the duplicate-email
issue.
2014-07-19 15:12:27 +02:00
137d4295f3 Remove unused code causing warnings 2014-01-01 16:41:27 +01:00
78de94d17c Update community authentication to pass an arbitrary datablock instead of url
This makes it possible to pass URLs that will fail when they end up being double
escaped in some cases, since they contain non-url-safe characters. Instead, they'd
be base64-encoded, and thus safe.

Also update the django community auth provider to do just this, including encrypting
the data with the site secret key to make sure it can't be changed/injected by
tricking the user to go directly to the wrong URL.
2013-06-20 15:16:47 +02:00
4e3dc6c795 Add sample login.html for django admin logins 2011-12-28 15:03:55 +01:00
88d0b6148d Implement single sign-out for community login 2.0
In order to provide a consistent user experience, we must sign the
user out from the main website if the community site provides a logout
button - else that button will appear not to work...
2011-12-27 19:35:51 +01:00
5ef06f359d Add sample django community authentication consumer 2011-12-22 19:25:33 +01:00