uploadserver 5.1.0__tar.gz → 5.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uploadserver
3
- Version: 5.1.0
3
+ Version: 5.2.0
4
4
  Summary: Python's http.server extended to include a file upload page
5
5
  Home-page: https://github.com/Densaugeo/uploadserver
6
6
  Author: Densaugeo
@@ -64,9 +64,7 @@ Now you can upload with basic authentication. For example:
64
64
  curl -X POST http://127.0.0.1:8000/upload -F 'files=@basicauth-example.txt' -u hello:world
65
65
  ~~~
66
66
 
67
- Uploads without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
68
-
69
- The server checks credentials before it handles the body of the request, so this mode of operation is not susceptible to DoS attack mentioned in the previous section.
67
+ All requests without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
70
68
 
71
69
  ## Basic Authentication (uploads only)
72
70
 
@@ -76,7 +74,7 @@ python3 -m uploadserver --basic-auth-upload hello:world
76
74
 
77
75
  The same as above, but authentication is only required for upload operations.
78
76
 
79
- If both --basic-auth and --basic-auth-upload are specified, first one will be used for downloads and the second one for uploads.
77
+ If both `--basic-auth` and `--basic-auth-upload` are specified, all requests will require one of the two credentials, but only the `--basic-auth-upload` credentials will be able to upload files.
80
78
 
81
79
  ## Theme Option
82
80
 
@@ -132,7 +130,7 @@ Note: This uses a self-signed server certificate which clients such as web brows
132
130
 
133
131
  ## Breaking Changes in 4.0.0
134
132
 
135
- - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allowreplace`.
133
+ - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allow-replace`.
136
134
  - File uploads with no files in them are rejected with 400 Bad Request instead of 500 Internal Server Error, with a more informative error message.
137
135
  - Handling of large uploads has been improved. Theoretically this should not cause any breaking changes, but filesystems are black magic and should be viewed with suspicion.
138
136
 
@@ -50,9 +50,7 @@ Now you can upload with basic authentication. For example:
50
50
  curl -X POST http://127.0.0.1:8000/upload -F 'files=@basicauth-example.txt' -u hello:world
51
51
  ~~~
52
52
 
53
- Uploads without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
54
-
55
- The server checks credentials before it handles the body of the request, so this mode of operation is not susceptible to DoS attack mentioned in the previous section.
53
+ All requests without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
56
54
 
57
55
  ## Basic Authentication (uploads only)
58
56
 
@@ -62,7 +60,7 @@ python3 -m uploadserver --basic-auth-upload hello:world
62
60
 
63
61
  The same as above, but authentication is only required for upload operations.
64
62
 
65
- If both --basic-auth and --basic-auth-upload are specified, first one will be used for downloads and the second one for uploads.
63
+ If both `--basic-auth` and `--basic-auth-upload` are specified, all requests will require one of the two credentials, but only the `--basic-auth-upload` credentials will be able to upload files.
66
64
 
67
65
  ## Theme Option
68
66
 
@@ -118,7 +116,7 @@ Note: This uses a self-signed server certificate which clients such as web brows
118
116
 
119
117
  ## Breaking Changes in 4.0.0
120
118
 
121
- - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allowreplace`.
119
+ - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allow-replace`.
122
120
  - File uploads with no files in them are rejected with 400 Bad Request instead of 500 Internal Server Error, with a more informative error message.
123
121
  - Handling of large uploads has been improved. Theoretically this should not cause any breaking changes, but filesystems are black magic and should be viewed with suspicion.
124
122
 
@@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name='uploadserver',
8
- version='5.1.0',
8
+ version='5.2.0',
9
9
  author='Densaugeo',
10
10
  author_email='author@example.com',
11
11
  description='Python\'s http.server extended to include a file upload page',
@@ -62,7 +62,7 @@ document.getElementsByTagName('form')[0].addEventListener('submit', async e => {
62
62
  document.getElementById('status').textContent = (e.loaded === e.total ?
63
63
  'Saving…' :
64
64
  `${Math.floor(100*e.loaded/e.total)}% ` +
65
- `[${e.loaded >> 10} / ${e.total >> 10}KiB]`
65
+ `[${Math.floor(e.loaded/1024)} / ${Math.floor(e.total/1024)}KiB]`
66
66
  )
67
67
  }
68
68
 
@@ -191,15 +191,31 @@ def check_http_authentication(handler):
191
191
  It validates Authorization header and sends back 401 response on failure.
192
192
  It returns False if this happens.
193
193
  """
194
- if handler.path == '/upload':
195
- auth = args.basic_auth or args.basic_auth_upload
194
+ if not args.basic_auth_upload:
195
+ # If no auth settings apply, check always passes
196
+ if not args.basic_auth:
197
+ return True
198
+
199
+ # If only --basic-auth is supplied, it's used for all requests
200
+ valid, message = check_http_authentication_header(handler, args.basic_auth)
196
201
  else:
197
- auth = args.basic_auth
198
-
199
- # If no auth settings apply, check always passes
200
- if not auth: return True
201
-
202
- valid, message = check_http_authentication_header(handler, auth)
202
+ # If --basic-auth-upload is supplied, it's always required for /upload
203
+ if handler.path == '/upload':
204
+ valid, message = check_http_authentication_header(handler,
205
+ args.basic_auth_upload)
206
+ else:
207
+ # For paths outside /upload, no auth is required when --basic-auth
208
+ # is not supplied
209
+ if not args.basic_auth:
210
+ return True
211
+
212
+ # For paths outise /upload, if both auths are supplied both are
213
+ # accepted
214
+ else:
215
+ valid, message = check_http_authentication_header(handler, args.basic_auth)
216
+
217
+ if not valid:
218
+ valid, message = check_http_authentication_header(handler, args.basic_auth_upload)
203
219
 
204
220
  if not valid:
205
221
  handler.log_message(f'Request rejected ({message})')
@@ -421,8 +437,4 @@ def main():
421
437
  args = parser.parse_args()
422
438
  if not hasattr(args, 'directory'): args.directory = os.getcwd()
423
439
 
424
- if args.basic_auth and args.basic_auth_upload:
425
- print('Cannot set both --basic--auth and --basic-auth-upload')
426
- sys.exit(6)
427
-
428
440
  serve_forever()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uploadserver
3
- Version: 5.1.0
3
+ Version: 5.2.0
4
4
  Summary: Python's http.server extended to include a file upload page
5
5
  Home-page: https://github.com/Densaugeo/uploadserver
6
6
  Author: Densaugeo
@@ -64,9 +64,7 @@ Now you can upload with basic authentication. For example:
64
64
  curl -X POST http://127.0.0.1:8000/upload -F 'files=@basicauth-example.txt' -u hello:world
65
65
  ~~~
66
66
 
67
- Uploads without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
68
-
69
- The server checks credentials before it handles the body of the request, so this mode of operation is not susceptible to DoS attack mentioned in the previous section.
67
+ All requests without authentication will be rejected. Note that basic authentication credentials can be stolen if sent over plain HTTP, so this option is best used with HTTPS.
70
68
 
71
69
  ## Basic Authentication (uploads only)
72
70
 
@@ -76,7 +74,7 @@ python3 -m uploadserver --basic-auth-upload hello:world
76
74
 
77
75
  The same as above, but authentication is only required for upload operations.
78
76
 
79
- If both --basic-auth and --basic-auth-upload are specified, first one will be used for downloads and the second one for uploads.
77
+ If both `--basic-auth` and `--basic-auth-upload` are specified, all requests will require one of the two credentials, but only the `--basic-auth-upload` credentials will be able to upload files.
80
78
 
81
79
  ## Theme Option
82
80
 
@@ -132,7 +130,7 @@ Note: This uses a self-signed server certificate which clients such as web brows
132
130
 
133
131
  ## Breaking Changes in 4.0.0
134
132
 
135
- - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allowreplace`.
133
+ - By default, uploaded files which have the same name as an existing file are renamed. To restore the previous behavior of overwriting them, pass `--allow-replace`.
136
134
  - File uploads with no files in them are rejected with 400 Bad Request instead of 500 Internal Server Error, with a more informative error message.
137
135
  - Handling of large uploads has been improved. Theoretically this should not cause any breaking changes, but filesystems are black magic and should be viewed with suspicion.
138
136
 
File without changes
File without changes