mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Import subscribe_to_user_changes function to sample auth.py
This was used on git.postgresql.org, but hadn't been propagated upstream.
This commit is contained in:
@ -308,6 +308,30 @@ def user_search(searchterm=None, userid=None):
|
|||||||
return j
|
return j
|
||||||
|
|
||||||
|
|
||||||
|
# Subscribe to any changes about this user on the community auth upstream
|
||||||
|
def subscribe_to_user_changes(userid):
|
||||||
|
socket.setdefaulttimeout(10)
|
||||||
|
|
||||||
|
body = json.dumps({
|
||||||
|
'u': userid,
|
||||||
|
})
|
||||||
|
|
||||||
|
h = hmac.digest(
|
||||||
|
base64.b64decode(settings.PGAUTH_KEY),
|
||||||
|
msg=bytes(body, 'utf-8'),
|
||||||
|
digest='sha512',
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ignore the result code, just post it
|
||||||
|
requests.post(
|
||||||
|
'{0}subscribe/'.format(settings.PGAUTH_REDIRECT),
|
||||||
|
data=body,
|
||||||
|
headers={
|
||||||
|
'X-pgauth-sig': base64.b64encode(h),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Import a user into the local authentication system. Will initially
|
# Import a user into the local authentication system. Will initially
|
||||||
# make a search for it, and if anything other than one entry is returned
|
# make a search for it, and if anything other than one entry is returned
|
||||||
# the import will fail.
|
# the import will fail.
|
||||||
|
Reference in New Issue
Block a user