You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2025/09/28 18:23:45 UTC

(steve) branch trunk updated (43e44b7 -> 9048d3b)

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

gstein pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git


    from 43e44b7  Add some query APIs to help populate the UX.
     new 626fdf8  fix calls to use .perform()
     new e008e18  remove content dupliated in header/footer.ezt. Tweak text and add vertical margin
     new 5079a26  Various improvements when running the server.
     new 9048d3b  Beging some page content work, and authz.

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:
 v3/server/main.py             | 21 ++++++++++++++++++++-
 v3/server/pages.py            | 27 +++++++++++++++++++++++++++
 v3/server/templates/home.ezt  | 24 ++++++------------------
 v3/server/templates/voter.ezt |  9 ++++++++-
 v3/steve/election.py          |  4 ++--
 5 files changed, 63 insertions(+), 22 deletions(-)


(steve) 04/04: Beging some page content work, and authz.

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 9048d3bd828273aab96368ecf538db5f0ea1586b
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun Sep 28 13:23:34 2025 -0500

    Beging some page content work, and authz.
---
 v3/server/pages.py            | 27 +++++++++++++++++++++++++++
 v3/server/templates/voter.ezt |  9 ++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/v3/server/pages.py b/v3/server/pages.py
index d06ff41..757745e 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -15,10 +15,23 @@
 # limitations under the License.
 #
 
+import sys
+import pathlib
+
+from easydict import EasyDict as edict
+import asfpy.stopwatch
 import quart
 import asfquart
+from asfquart.auth import Requirements as R
+
 APP = asfquart.APP
 
+THIS_DIR = pathlib.Path(__file__).resolve().parent
+DB_FNAME = THIS_DIR / APP.cfg.db
+
+sys.path.insert(0, str(THIS_DIR.parent))
+import steve.election
+
 
 @APP.get('/')
 @APP.use_template('templates/home.ezt')
@@ -29,14 +42,25 @@ async def home_page():
 
 
 @APP.get('/voter')
+@asfquart.auth.require({R.committer})
 @APP.use_template('templates/voter.ezt')
 async def voter_page():
+    with asfpy.stopwatch.Stopwatch():
+        election = steve.election.Election.open_to_pid(DB_FNAME, 'gstein')
+        owned = steve.election.Election.owned_elections(DB_FNAME, 'gstein')
+
+    election = [ edict(eid='123', title='test election') ]
+    owned = [ edict(eid='456', title='another', authz=None, closed=None) ]
+
     return {
         'title': 'Voting',
+        'election': election,
+        'owned': owned,
     }
 
 
 @APP.get('/admin')
+@asfquart.auth.require({R.committer})
 @APP.use_template('templates/admin.ezt')
 async def admin_page():
     return {
@@ -45,6 +69,7 @@ async def admin_page():
 
 
 @APP.get('/profile')
+@asfquart.auth.require  # Bare decorator means just require a valid session
 @APP.use_template('templates/profile.ezt')
 async def profile_page():
     return {
@@ -53,6 +78,7 @@ async def profile_page():
 
 
 @APP.get('/settings')
+@asfquart.auth.require  # Bare decorator means just require a valid session
 @APP.use_template('templates/settings.ezt')
 async def settings_page():
     return {
@@ -61,6 +87,7 @@ async def settings_page():
 
 
 @APP.get('/sign-out')
+@asfquart.auth.require  # Bare decorator means just require a valid session
 async def sign_out():
     ### clear the cookie?
     return '', 204
diff --git a/v3/server/templates/voter.ezt b/v3/server/templates/voter.ezt
index 4d95432..2fadefe 100644
--- a/v3/server/templates/voter.ezt
+++ b/v3/server/templates/voter.ezt
@@ -2,7 +2,14 @@
     <div class="container">
         <h1>[title]</h1>
         <p>
-            TBD
+          [for election]
+            [election.eid] [election.title]
+          [end]
+        </p>
+        <p>
+          [for owned]
+            [owned.eid] [owned.title] [owned.authz] [owned.closed]
+          [end]
         </p>
     </div>
 [include "footer.ezt"]


(steve) 02/04: remove content dupliated in header/footer.ezt. Tweak text and add vertical margin

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit e008e187733fc7b9770e14d9d891ce1bf72d7691
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun Sep 28 13:09:59 2025 -0500

    remove content dupliated in header/footer.ezt. Tweak text and add vertical margin
---
 v3/server/templates/home.ezt | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/v3/server/templates/home.ezt b/v3/server/templates/home.ezt
index c405974..dd0bdf0 100644
--- a/v3/server/templates/home.ezt
+++ b/v3/server/templates/home.ezt
@@ -1,13 +1,4 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Apache STeVe</title>
-    <link href="/static/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9">
-</head>
-<body>
-    [include "header.ezt"]
+[include "header.ezt"]
     <div class="container">
         <p class="my-3">
           Welcome! What are you here for? Select an option below.
@@ -48,15 +39,12 @@
             </div>
         </div>
 
-        <p>
-          This site is being served using the
-          <a href="https://steve.apache.org/">Apache STeVe</a>
-          codebase, from the
+        <p class="mt-3">
+          This site is being served using
+          <a href="https://steve.apache.org/">Apache STeVe</a>,
+          from the
           <a href="https://www.apache.org/">Apache Software Foundation</a>.
         </p>
     </div>
 
-    [include "footer.ezt"]
-    <script src="/static/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"></script>
-</body>
-</html>
+[include "footer.ezt"]


(steve) 01/04: fix calls to use .perform()

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 626fdf84ebccffa131ababb0fc3864e0bc614c31
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun Sep 28 13:09:15 2025 -0500

    fix calls to use .perform()
---
 v3/steve/election.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/v3/steve/election.py b/v3/steve/election.py
index 6508fc0..3b9bbe3 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -394,7 +394,7 @@ class Election:
         db = cls.open_database(db_fname)
 
         # Run the generator to get all rows. Returned as EasyDicts.
-        db.q_open_to_me(pid,)
+        db.q_open_to_me.perform(pid,)
         return [ row for row in db.q_open_to_me.fetchall() ]
 
     @classmethod
@@ -407,5 +407,5 @@ class Election:
         #       SALT or OPENED_KEY values.
         #
         # Run the generator to get all rows. Returned as EasyDicts.
-        db.q_owned(pid,)
+        db.q_owned.perform(pid,)
         return [ row for row in db.q_owned.fetchall() ]


(steve) 03/04: Various improvements when running the server.

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 5079a262a5fa8f4409b86d34ab40be353fc120b9
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Sun Sep 28 13:11:36 2025 -0500

    Various improvements when running the server.
    
    * tweak some logging for less DEBUG in a few modules
    * switch to regular OAuth2 rather than OIDC
    * allow for TLS operation, if a cert/key is configured
    * adjust .runx() for above
---
 v3/server/main.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/v3/server/main.py b/v3/server/main.py
index 1c1ce29..5c2369c 100755
--- a/v3/server/main.py
+++ b/v3/server/main.py
@@ -34,6 +34,17 @@ def main():
                         datefmt=DATE_FORMAT,
                         )
 
+    # Switch some loggers to INFO, rather than DEBUG
+    logging.getLogger('selector_events').setLevel(logging.INFO)
+    logging.getLogger('hpack').setLevel(logging.INFO)
+    logging.getLogger('sslproto').setLevel(logging.INFO)
+
+    ### is this really needed right now?
+    # Avoid OIDC
+    import asfquart.generics
+    asfquart.generics.OAUTH_URL_INIT = "https://oauth.apache.org/auth?state=%s&redirect_uri=%s"
+    asfquart.generics.OAUTH_URL_CALLBACK = "https://oauth.apache.org/token?code=%s"
+
     app = asfquart.construct('steve')
 
     # Now that we have an APP, import modules that will add page
@@ -41,8 +52,16 @@ def main():
     import pages  # pylint: disable=unused-import
     import api  # pylint: disable=unused-import
 
+    kwargs = { }
+    if app.cfg.server.certfile:
+        kwargs['certfile'] = THIS_DIR / app.cfg.server.certfile
+        kwargs['keyfile'] = THIS_DIR / app.cfg.server.keyfile
+
     # Spool up the app!
-    app.runx(port=app.cfg.port)
+    app.runx(port=app.cfg.server.port, **kwargs)
+
+    #print('LOGGERS:', sorted(_LOGGER.manager.loggerDict.keys()))
+    #print(_LOGGER.manager.loggerDict['sslproto'])
 
 
 if __name__ == '__main__':