You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/07 02:40:48 UTC
[incubator-ponymail-foal] 03/05: Add very generic OAuth plugin
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit a94db38b1d18efd1f832b8d07751a5ec3bf74057
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 04:30:22 2020 +0200
Add very generic OAuth plugin
---
server/plugins/oauthGeneric.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/server/plugins/oauthGeneric.py b/server/plugins/oauthGeneric.py
new file mode 100644
index 0000000..e3eb57b
--- /dev/null
+++ b/server/plugins/oauthGeneric.py
@@ -0,0 +1,18 @@
+# Generic OAuth plugin
+import re
+import requests
+
+
+def process(formdata, session):
+ js = None
+ m = re.match(r"https?://(.+)/", formdata["oauth_token"])
+ if m:
+ oauth_domain = m.group(1)
+ headers = {"User-Agent": "Pony Mail OAuth Agent/0.1"}
+ rv = requests.post(formdata["oauth_token"], headers=headers, data=formdata)
+ # try:
+ js = rv.json()
+ js["oauth_domain"] = oauth_domain
+ js['authoritative'] = True
+
+ return js