p3lib 1.1.66__py3-none-any.whl → 1.1.67__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- p3lib/bokeh_auth.py +29 -26
- {p3lib-1.1.66.dist-info → p3lib-1.1.67.dist-info}/METADATA +1 -1
- {p3lib-1.1.66.dist-info → p3lib-1.1.67.dist-info}/RECORD +6 -6
- {p3lib-1.1.66.dist-info → p3lib-1.1.67.dist-info}/LICENSE +0 -0
- {p3lib-1.1.66.dist-info → p3lib-1.1.67.dist-info}/WHEEL +0 -0
- {p3lib-1.1.66.dist-info → p3lib-1.1.67.dist-info}/top_level.txt +0 -0
p3lib/bokeh_auth.py
CHANGED
@@ -15,18 +15,22 @@ from argon2 import PasswordHasher
|
|
15
15
|
from argon2.exceptions import VerificationError
|
16
16
|
from datetime import datetime
|
17
17
|
|
18
|
+
# could also define get_login_url function (but must give up LoginHandler)
|
19
|
+
login_url = "/login"
|
20
|
+
|
18
21
|
CRED_FILE_KEY = "CRED_FILE"
|
19
22
|
LOGIN_HTML_FILE_KEY = "LOGIN_HTML_FILE"
|
20
23
|
ACCESS_LOG_FILE = "ACCESS_LOG_FILE"
|
21
24
|
|
22
25
|
# could define get_user_async instead
|
23
26
|
def get_user(request_handler):
|
27
|
+
# Record the get request
|
28
|
+
LoginHandler.RecordGet(request_handler.request.remote_ip)
|
24
29
|
user = request_handler.get_cookie("user")
|
30
|
+
# Record the user making the request
|
31
|
+
LoginHandler.SaveInfoAccessLogMessage(f"USER={user}")
|
25
32
|
return user
|
26
33
|
|
27
|
-
# could also define get_login_url function (but must give up LoginHandler)
|
28
|
-
login_url = "/login"
|
29
|
-
|
30
34
|
def GetAuthAttrFile():
|
31
35
|
"""@brief Get the file that is used to pass parameters (credentials file and login.html file) to the tornado server.
|
32
36
|
There must be a better way of passing the credentials file to the tornado login handler than this..."""
|
@@ -73,19 +77,22 @@ def GetAccessLogFile():
|
|
73
77
|
# optional login page for login_url
|
74
78
|
class LoginHandler(RequestHandler):
|
75
79
|
|
76
|
-
|
77
|
-
|
78
|
-
|
80
|
+
@staticmethod
|
81
|
+
def RecordGet(remoteIP):
|
82
|
+
"""@brief Record an HHTP get on the login page.
|
83
|
+
@param remoteIP The IP address of the client."""
|
84
|
+
msg = f"HTTP GET from {remoteIP}"
|
85
|
+
LoginHandler.SaveInfoAccessLogMessage(msg)
|
79
86
|
try:
|
80
87
|
# We import here so that the p3lib module will import even if ip2geotools
|
81
|
-
# is not available as pip install ip2geotools adds in
|
88
|
+
# is not available as pip install ip2geotools adds in ~ 70 python modules !!!
|
82
89
|
from ip2geotools.databases.noncommercial import DbIpCity
|
83
|
-
response = DbIpCity.get(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
90
|
+
response = DbIpCity.get(remoteIP, api_key='free')
|
91
|
+
LoginHandler.SaveInfoAccessLogMessage(f"HTTP GET country = {response.country}")
|
92
|
+
LoginHandler.SaveInfoAccessLogMessage(f"HTTP GET region = {response.region}")
|
93
|
+
LoginHandler.SaveInfoAccessLogMessage(f"HTTP GET city = {response.city}")
|
94
|
+
LoginHandler.SaveInfoAccessLogMessage(f"HTTP GET latitude = {response.latitude}")
|
95
|
+
LoginHandler.SaveInfoAccessLogMessage(f"HTTP GET longitude = {response.longitude}")
|
89
96
|
except:
|
90
97
|
pass
|
91
98
|
|
@@ -94,26 +101,23 @@ class LoginHandler(RequestHandler):
|
|
94
101
|
@param username The username entered.
|
95
102
|
@param password The password entered."""
|
96
103
|
pw = "*"*len(password)
|
97
|
-
|
104
|
+
LoginHandler.SaveInfoAccessLogMessage(f"Login attempt from {self.request.remote_ip}: username = {username}, password={pw}")
|
98
105
|
|
99
106
|
def _recordLoginSuccess(self, username, password):
|
100
107
|
"""@brief Record a successful login to the server.
|
101
108
|
@param username The username entered.
|
102
109
|
@param password The password entered."""
|
103
110
|
pw = "*"*len(password)
|
104
|
-
|
105
|
-
|
106
|
-
def _saveInfoAccessLogMessage(self, msg):
|
107
|
-
"""@brief Save an info level access log message.
|
108
|
-
@param msg The message to save to the access log."""
|
109
|
-
self._saveAccessLogMessage("INFO: "+str(msg))
|
111
|
+
LoginHandler.SaveInfoAccessLogMessage(f"Login success from {self.request.remote_ip}: username = {username}, password={pw}")
|
110
112
|
|
111
|
-
|
113
|
+
@staticmethod
|
114
|
+
def SaveInfoAccessLogMessage(msg):
|
112
115
|
"""@brief Save an info level access log message.
|
113
116
|
@param msg The message to save to the access log."""
|
114
|
-
|
117
|
+
LoginHandler.SaveAccessLogMessage("INFO: "+str(msg))
|
115
118
|
|
116
|
-
|
119
|
+
@staticmethod
|
120
|
+
def SaveAccessLogMessage(msg):
|
117
121
|
"""@brief Save an access log message.
|
118
122
|
@param msg The message to save to the access log."""
|
119
123
|
now = datetime.now()
|
@@ -132,7 +136,6 @@ class LoginHandler(RequestHandler):
|
|
132
136
|
pass
|
133
137
|
|
134
138
|
def get(self):
|
135
|
-
self._recordGet()
|
136
139
|
try:
|
137
140
|
errormessage = self.get_argument("error")
|
138
141
|
except Exception:
|
@@ -166,10 +169,10 @@ class LoginHandler(RequestHandler):
|
|
166
169
|
def set_current_user(self, user):
|
167
170
|
if user:
|
168
171
|
self.set_cookie("user", tornado.escape.json_encode(user))
|
169
|
-
|
172
|
+
LoginHandler.SaveInfoAccessLogMessage(f"Set user cookie: user={user}")
|
170
173
|
else:
|
171
174
|
self.clear_cookie("user")
|
172
|
-
|
175
|
+
LoginHandler.SaveInfoAccessLogMessage("Cleared user cookie")
|
173
176
|
|
174
177
|
# optional logout_url, available as curdoc().session_context.logout_url
|
175
178
|
logout_url = "/logout"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p3lib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.67
|
4
4
|
Summary: A group of python modules for networking, plotting data, config storage, automating boot scripts, ssh access and user input output.
|
5
5
|
Home-page: https://github.com/pjaos/p3lib
|
6
6
|
Author: Paul Austen
|
@@ -1,6 +1,6 @@
|
|
1
1
|
p3lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
p3lib/ate.py,sha256=_BiqMUYNAlp4O8MkP_PAUe62Bzd8dzV4Ipv62OFS6Ok,4759
|
3
|
-
p3lib/bokeh_auth.py,sha256=
|
3
|
+
p3lib/bokeh_auth.py,sha256=XqdCLOalHL3dkyrMPqQoVQBSziVnqlfjB9YAWhZUd_U,14769
|
4
4
|
p3lib/bokeh_gui.py,sha256=MNapLctSncZ9YyKGzNcUICMwpI5_h7a7bH3QdMd2UxI,40393
|
5
5
|
p3lib/boot_manager.py,sha256=-kbfYbFpO-ktKv_heUgYdvvIQrntfCQ7pBcPWqS3C0s,12551
|
6
6
|
p3lib/conduit.py,sha256=jPkjdtyCx2I6SFqcEo8y2g7rgnZ-jNY7oCuYIETzT5Q,6046
|
@@ -13,8 +13,8 @@ p3lib/netplotly.py,sha256=PMDx-w1jtRVW6Od5u_kuKbBxNpTS_Y88mMF60puMxLM,9363
|
|
13
13
|
p3lib/pconfig.py,sha256=_ri9w3aauHXZp8u2YLYHBVroFR_iCqaTCwj_MRa3rHo,30153
|
14
14
|
p3lib/ssh.py,sha256=YE1ddgiEt9EeBM8evuxCV8Gnj4jz1Sv52vEKidvjrJA,38369
|
15
15
|
p3lib/uio.py,sha256=hMarPnYXnqVF23HUIeDfzREo7TMdBjrupXMY_ffuCbI,23133
|
16
|
-
p3lib-1.1.
|
17
|
-
p3lib-1.1.
|
18
|
-
p3lib-1.1.
|
19
|
-
p3lib-1.1.
|
20
|
-
p3lib-1.1.
|
16
|
+
p3lib-1.1.67.dist-info/LICENSE,sha256=igqTy5u0kVWM1n-NUZMvAlinY6lVjAXKoag0okkS8V8,1067
|
17
|
+
p3lib-1.1.67.dist-info/METADATA,sha256=3SZVksgoZrtT2NwfrYK0Q2VOq6Yh_j31A9pYB7042y8,920
|
18
|
+
p3lib-1.1.67.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
19
|
+
p3lib-1.1.67.dist-info/top_level.txt,sha256=SDCpXYh-19yCFp4Z8ZK4B-3J4NvTCJElZ42NPgcR6-U,6
|
20
|
+
p3lib-1.1.67.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|