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/12/12 11:04:41 UTC

[incubator-ponymail-foal] branch master updated (b47565f -> 0e54755)

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from b47565f  If url_prefix is erroneously set to None, replace with empty string
     new a4432f3  Work in an admin switch for oauth logins, to be used later.
     new 57d441c  Add an admin control button for emails. Does not do anything yet.
     new ee14396  Only show button if admin
     new 0e54755  fix links not firing due to no target

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 server/endpoints/oauth.py       |  6 ++++--
 server/endpoints/preferences.py |  2 ++
 server/plugins/configuration.py |  2 ++
 server/plugins/session.py       |  3 +++
 tools/setup.py                  |  2 ++
 webui/css/scaffolding.css       |  7 +++++++
 webui/js/ponymail.js            | 10 ++++++++--
 webui/js/source/render-email.js | 10 ++++++++--
 8 files changed, 36 insertions(+), 6 deletions(-)


[incubator-ponymail-foal] 04/04: fix links not firing due to no target

Posted by hu...@apache.org.
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 0e5475586e3cefa9822f0a74f60f96bb333e6860
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Dec 1 15:02:14 2020 +0100

    fix links not firing due to no target
---
 webui/js/ponymail.js            | 6 +++---
 webui/js/source/render-email.js | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index 010d2f8..bc18ebe 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -2876,16 +2876,16 @@ async function render_email_chatty(state, json) {
     toolbar.inject(replybutton);
     
     // permalink button
-    let linkbutton = new HTML('a', { href: 'thread/%s'.format(json.mid), title: "Permanent link to this email", class: 'btn toolbar_btn toolbar_button_link'}, new HTML('span', { class: 'glyphicon glyphicon-link'}, ' '));
+    let linkbutton = new HTML('a', { href: 'thread/%s'.format(json.mid), title: "Permanent link to this email", target: '_self', class: 'btn toolbar_btn toolbar_button_link'}, new HTML('span', { class: 'glyphicon glyphicon-link'}, ' '));
     toolbar.inject(linkbutton);
     
     // Source-view button
-    let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
+    let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), target: '_self', title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
     toolbar.inject(sourcebutton);
 
     // Admin button?
     if (ponymail_preferences.login && ponymail_preferences.login.credentials && ponymail_preferences.login.credentials.admin) {
-        let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+        let adminbutton = new HTML('a', { href: 'admin/%s'.format(json.mid), target: '_self', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
         toolbar.inject(adminbutton);
     }
     
diff --git a/webui/js/source/render-email.js b/webui/js/source/render-email.js
index 6aa63bf..bfb1d90 100644
--- a/webui/js/source/render-email.js
+++ b/webui/js/source/render-email.js
@@ -164,16 +164,16 @@ async function render_email_chatty(state, json) {
     toolbar.inject(replybutton);
     
     // permalink button
-    let linkbutton = new HTML('a', { href: 'thread/%s'.format(json.mid), title: "Permanent link to this email", class: 'btn toolbar_btn toolbar_button_link'}, new HTML('span', { class: 'glyphicon glyphicon-link'}, ' '));
+    let linkbutton = new HTML('a', { href: 'thread/%s'.format(json.mid), title: "Permanent link to this email", target: '_self', class: 'btn toolbar_btn toolbar_button_link'}, new HTML('span', { class: 'glyphicon glyphicon-link'}, ' '));
     toolbar.inject(linkbutton);
     
     // Source-view button
-    let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
+    let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), target: '_self', title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
     toolbar.inject(sourcebutton);
 
     // Admin button?
     if (ponymail_preferences.login && ponymail_preferences.login.credentials && ponymail_preferences.login.credentials.admin) {
-        let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+        let adminbutton = new HTML('a', { href: 'admin/%s'.format(json.mid), target: '_self', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
         toolbar.inject(adminbutton);
     }
     


[incubator-ponymail-foal] 01/04: Work in an admin switch for oauth logins, to be used later.

Posted by hu...@apache.org.
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 a4432f3b3a930aa484440e1ae3fe8db9806962d1
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Dec 1 13:01:03 2020 +0100

    Work in an admin switch for oauth logins, to be used later.
---
 server/endpoints/oauth.py       | 6 ++++--
 server/endpoints/preferences.py | 2 ++
 server/plugins/configuration.py | 2 ++
 server/plugins/session.py       | 3 +++
 tools/setup.py                  | 2 ++
 5 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/server/endpoints/oauth.py b/server/endpoints/oauth.py
index 929e2c9..8ab02f6 100644
--- a/server/endpoints/oauth.py
+++ b/server/endpoints/oauth.py
@@ -64,6 +64,8 @@ async def process(
                     "ascii", "ignore"
                 )
             ).hexdigest(16)
+            authoritative = rv.get("oauth_domain", "generic") in server.config.oauth.authoritative_domains
+            admin = authoritative and rv.get('email') in server.config.oauth.admins
             cookie = await plugins.session.set_session(
                 server,
                 cid,
@@ -72,10 +74,10 @@ async def process(
                 email=rv.get("email"),
                 # Authoritative if OAuth domain is in the authoritative oauth section in ponymail.yaml
                 # Required for access to private emails
-                authoritative=rv.get("oauth_domain", "generic")
-                in server.config.oauth.authoritative_domains,
+                authoritative=authoritative,
                 oauth_provider=rv.get("oauth_domain", "generic"),
                 oauth_data=rv,
+                admin=admin
             )
             # This could be improved upon, instead of a raw response return value
             return aiohttp.web.Response(
diff --git a/server/endpoints/preferences.py b/server/endpoints/preferences.py
index 49dcff6..7a473aa 100644
--- a/server/endpoints/preferences.py
+++ b/server/endpoints/preferences.py
@@ -47,6 +47,8 @@ async def process(
                 "fullname": session.credentials.name,
             }
         }
+        if session.credentials.admin is True:
+            prefs['login']['credentials']['admin'] = True
 
     # Logging out??
     if indata.get('logout'):
diff --git a/server/plugins/configuration.py b/server/plugins/configuration.py
index 54417cb..4132511 100644
--- a/server/plugins/configuration.py
+++ b/server/plugins/configuration.py
@@ -33,12 +33,14 @@ class UIConfig:
 
 class OAuthConfig:
     authoritative_domains: list
+    admins: list
     google_client_id: str
     github_client_id: str
     github_client_secret: str
 
     def __init__(self, subyaml: dict):
         self.authoritative_domains = subyaml.get("authoritative_domains", [])
+        self.admins = subyaml.get("admins", [])
         self.google_client_id = subyaml.get("google_client_id", "")
         self.github_client_id = subyaml.get("github_client_id", "")
         self.github_client_secret = subyaml.get("github_client_secret", "")
diff --git a/server/plugins/session.py b/server/plugins/session.py
index e18a449..4ccd526 100644
--- a/server/plugins/session.py
+++ b/server/plugins/session.py
@@ -160,6 +160,8 @@ async def get_session(
                 )
                 creds["oauth_provider"] = internal.get("oauth_provider", "generic")
                 creds["oauth_data"] = internal.get("oauth_data", {})
+                # We update admin boolean whenever we fetch session doc, as they may have changed in yaml but not in ES.
+                creds["admin"] = creds["authoritative"] and creds.get('email') in server.config.oauth.admins
                 session.credentials = SessionCredentials(creds)
 
                 # Save in memory storage
@@ -231,6 +233,7 @@ async def save_credentials(session: SessionObject):
             "internal": {
                 "oauth_provider": session.credentials.oauth_provider,
                 "oauth_data": session.credentials.oauth_data,
+                "admin": session.credentials.admin,
             },
         },
     )
diff --git a/tools/setup.py b/tools/setup.py
index cbbadc9..69df254 100755
--- a/tools/setup.py
+++ b/tools/setup.py
@@ -463,6 +463,8 @@ oauth:
 #  authoritative_domains:
 #    - googleapis.com  # OAuth via google is authoritative
 #    - github.com      # GitHub OAuth is authoritative
+#  admins:
+#    - foo@example.org
   google_client_id:     ~
   github_client_id:     ~
   github_client_secret: ~


[incubator-ponymail-foal] 02/04: Add an admin control button for emails. Does not do anything yet.

Posted by hu...@apache.org.
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 57d441c7fe9ef79929c090db271d7017e789271d
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Dec 1 13:14:42 2020 +0100

    Add an admin control button for emails. Does not do anything yet.
---
 webui/css/scaffolding.css       | 7 +++++++
 webui/js/ponymail.js            | 4 ++++
 webui/js/source/render-email.js | 4 ++++
 3 files changed, 15 insertions(+)

diff --git a/webui/css/scaffolding.css b/webui/css/scaffolding.css
index 04b2b2c..c74953b 100644
--- a/webui/css/scaffolding.css
+++ b/webui/css/scaffolding.css
@@ -1149,6 +1149,13 @@ a.disabled {
   text-indent: 1px;
 }
 
+
+.toolbar_button_admin {
+  background: #e5c30b;
+  color: #FFF !important;
+  text-indent: 1px;
+}
+
 pre {
   word-break:keep-all;
   word-wrap:normal;
diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index 47a3a3e..6e9cd2e 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -2882,6 +2882,10 @@ async function render_email_chatty(state, json) {
     // Source-view button
     let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
     toolbar.inject(sourcebutton);
+
+    // Admin button?
+    let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+    toolbar.inject(adminbutton);
     
     text.inject(toolbar);
 }
diff --git a/webui/js/source/render-email.js b/webui/js/source/render-email.js
index af51496..fe8edd2 100644
--- a/webui/js/source/render-email.js
+++ b/webui/js/source/render-email.js
@@ -170,6 +170,10 @@ async function render_email_chatty(state, json) {
     // Source-view button
     let sourcebutton = new HTML('a', { href: '%sapi/source.lua?id=%s'.format(apiURL, json.mid), title: "View raw source", class: 'btn toolbar_btn toolbar_button_source'}, new HTML('span', { class: 'glyphicon glyphicon-file'}, ' '));
     toolbar.inject(sourcebutton);
+
+    // Admin button?
+    let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+    toolbar.inject(adminbutton);
     
     text.inject(toolbar);
 }


[incubator-ponymail-foal] 03/04: Only show button if admin

Posted by hu...@apache.org.
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 ee1439670670b1e196c5fbd49a575f923d9587a5
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Dec 1 13:22:53 2020 +0100

    Only show button if admin
---
 webui/js/ponymail.js            | 6 ++++--
 webui/js/source/render-email.js | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index 6e9cd2e..010d2f8 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -2884,8 +2884,10 @@ async function render_email_chatty(state, json) {
     toolbar.inject(sourcebutton);
 
     // Admin button?
-    let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
-    toolbar.inject(adminbutton);
+    if (ponymail_preferences.login && ponymail_preferences.login.credentials && ponymail_preferences.login.credentials.admin) {
+        let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+        toolbar.inject(adminbutton);
+    }
     
     text.inject(toolbar);
 }
diff --git a/webui/js/source/render-email.js b/webui/js/source/render-email.js
index fe8edd2..6aa63bf 100644
--- a/webui/js/source/render-email.js
+++ b/webui/js/source/render-email.js
@@ -172,8 +172,10 @@ async function render_email_chatty(state, json) {
     toolbar.inject(sourcebutton);
 
     // Admin button?
-    let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
-    toolbar.inject(adminbutton);
+    if (ponymail_preferences.login && ponymail_preferences.login.credentials && ponymail_preferences.login.credentials.admin) {
+        let adminbutton = new HTML('a', { href: '#', title: "Administrative control", class: 'btn toolbar_btn toolbar_button_admin'}, new HTML('span', { class: 'glyphicon glyphicon-cog'}, ' '));
+        toolbar.inject(adminbutton);
+    }
     
     text.inject(toolbar);
 }