Commits

Alexander Schremmer  committed 7a58e69

Make session permanent, allow setting the username through HTTP basic auth.

  • Participants
  • Parent commits f21a5f4

Comments (0)

Files changed (1)

File domination/main.py

 
 @app.before_request
 def before_request():
+    if request.authorization and app.auth_enabled:
+        session["username"] = request.authorization.user
     if "username" in session and session["username"] not in app.users:
         app.users[session["username"]] = {"games": {}}
+    session.permanent = True
 
 def restore_game(filename):
     f = file(filename, "rb")
             type="string", help='Path to store savegames in', default=None)
     parser.add_option('-D', '--debug', dest='debug', action='store_true',
             help='Debug mode', default=None)
+    parser.add_option('-a', '--auth', dest='auth', action='store_true',
+            help='Use the webservers basic auth information', default=False)
 
     options, args = parser.parse_args()
     if args:
             1/0
         app.secret_key = "insecure"
 
+    app.auth_enabled = options.auth
+
     if options.storagepath:
         # XXX does not really work
         app.game_storage_path = options.storagepath