Browse Source

Updated netipy client to disables console logging + add a security logging instruction to dummy_auth plugin

Yann Weber 8 years ago
parent
commit
1d6dc1ad89
3 changed files with 12 additions and 2 deletions
  1. 2
    0
      install/loader.py
  2. 5
    1
      install/netipy_loader.py
  3. 5
    1
      plugins/dummy_auth.py

+ 2
- 0
install/loader.py View File

@@ -11,6 +11,8 @@ from Lodel.settings import Settings
11 11
 Settings.load_module(instance_settings)
12 12
 globals()['Settings'] = Settings
13 13
 
14
+from Lodel import logger # logger import and initialisation
15
+
14 16
 from plugins import * #Load activated plugins
15 17
 
16 18
 # Import dynamic code

+ 5
- 1
install/netipy_loader.py View File

@@ -1,10 +1,14 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-from loader import *
4 3
 import sys
5 4
 import code
5
+from loader import *
6
+from Lodel import logger
6 7
 from Lodel.user import UserContext
7 8
 
9
+
10
+logger.remove_console_handlers()
11
+
8 12
 if __name__ == '__main__':
9 13
     if len(sys.argv) < 2:
10 14
         raise RuntimeError("Usage : %s client_ip")

+ 5
- 1
plugins/dummy_auth.py View File

@@ -1,13 +1,17 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3 3
 from Lodel.user import authentication_method, identification_method, UserIdentity
4
+from Lodel import logger
4 5
 
5 6
 @authentication_method
6 7
 def dummy_auth(identifier, proof):
7
-    print("Trying to authenticate user %s" % identifier)
8
+    logger.info("User '%s' is trying to authenticate" % identifier)
8 9
     if identifier == proof:
9 10
         print("%s authenticated" % identifier)
10 11
         return UserIdentity(identifier, identifier, "User %s" % identifier, authenticated = True)
12
+    else:
13
+        logger.security("Authentication failed for user '%s'" % identifier)
14
+        
11 15
     return False
12 16
 
13 17
 @identification_method

Loading…
Cancel
Save