You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2022/01/31 00:34:51 UTC
[incubator-ponymail-foal] 02/02: Simplify login testing
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit bd65ad8d98e39358562e5094801e5bbaa7317380
Author: Sebb <se...@apache.org>
AuthorDate: Mon Jan 31 00:34:36 2022 +0000
Simplify login testing
---
server/testendpoints/testauth.py | 25 ++++++++++++++++++++-----
webui/images/oauth_admin.png | Bin 0 -> 3689 bytes
webui/images/oauth_user.png | Bin 0 -> 3630 bytes
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/server/testendpoints/testauth.py b/server/testendpoints/testauth.py
index 86ff13b..20ad6b9 100644
--- a/server/testendpoints/testauth.py
+++ b/server/testendpoints/testauth.py
@@ -19,21 +19,35 @@
Simple endpoint that does a local login
To enable:
+- ensure server/ponymail.yaml contains the following in the oauth section:
+
+oauth:
+ ...
+ authoritative_domains:
+ - localhost
+ admins:
+ - admin@apache.org
+
- Add the --testendpoints qualifier to the server startup command
Alternatively copy the files server/test/testauth.[py|.yaml] to the server/endpoints directory
They can be renamed if necessary, so long as they have the same basename;
adjust the URLs below to reflect the new name
- then add the following to config.js under pm_config.oauth:
- test: {
- name: "Test Auth",
+ user: {
+ name: "Test Auth User",
+ oauth_portal: "http://localhost/api/testauth",
+ oauth_url: "http://localhost/api/testauth"
+ },
+ admin: {
+ name: "Test Auth Admin",
oauth_portal: "http://localhost/api/testauth",
oauth_url: "http://localhost/api/testauth"
},
(This assumes that the test installation is at http://localhost/. Adjust as necessary.)
-This will add an extra option to the login screen.
-Clicking on the "Logon with Test Auth" link will automatically login (without prompting)
+This will add two extra options to the login screen.
+Clicking on either "Test sign in as ..." link will automatically login (without prompting)
The data returned by the login can be changed without restarting: just edit the testauth.yaml file.
"""
@@ -63,7 +77,8 @@ async def process(server: plugins.server.BaseServer, session: dict, indata: dict
try:
data = yaml.safe_load(open(datafile))['oauth_data']
debug(server, f'using data from {datafile}')
- user = indata.get('user', 'user')
+ # if the user is not provided, use the key
+ user = indata.get('user', indata.get('key', 'user'))
if user in data:
data = data[user]
data['state'] = indata.get('state')
diff --git a/webui/images/oauth_admin.png b/webui/images/oauth_admin.png
new file mode 100644
index 0000000..0d8371d
Binary files /dev/null and b/webui/images/oauth_admin.png differ
diff --git a/webui/images/oauth_user.png b/webui/images/oauth_user.png
new file mode 100644
index 0000000..a0d98cb
Binary files /dev/null and b/webui/images/oauth_user.png differ