Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit cec7986

Browse files
committed
block login and admin-required routes temporarily and update README
1 parent 510405f commit cec7986

4 files changed

Lines changed: 46 additions & 9 deletions

File tree

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
Google Managed VMs Python Runtime
2+
=================================
23

34
Warning
4-
=======
5-
5+
-------
66
The instructions here are for a multi-process version of the Python 2.7 runtime
77
**currently in alpha**. Please do not use this version for production workloads.
88
To use the stable version of the runtime, follow the documentation at
99
https://cloud.google.com/appengine/docs/managed-vms/ instead.
1010

1111
Contents
12-
========
13-
12+
--------
1413
* Using the multi-process runtime
1514
* Configuration
1615
* Building your own version
16+
* Caveats
1717

1818
Using the multi-process runtime
19-
===============================
19+
-------------------------------
2020
*These instructions assume you have a working Python application that has
2121
already been deployed successfully to Managed VMs using the default runtime
2222
version.*
@@ -45,7 +45,7 @@ section.
4545
prebuilt Docker image with no manual Dockerfile modification required.*
4646

4747
Configuration
48-
=============
48+
-------------
4949
By default the multi-process version of the runtime is launched via the Gunicorn
5050
webserver and is configured to use a fixed number of processes and gevent-based
5151
concurrency.
@@ -62,7 +62,7 @@ the number of processes in the Dockerfile to between 1 and 2 times the number of
6262
CPU cores available.
6363

6464
Building your own version
65-
=========================
65+
-------------------------
6666
If you would like to make modifications to the runtime (either for personal use
6767
or to debug or resolve an outstanding issue), you can build and deploy a custom
6868
version with the following steps:
@@ -77,3 +77,20 @@ directory as the Dockerfile.
7777
- Replace the URL in that line with the filename of your generated tar.gz file.
7878
- Deploy your application. A warning during deployment where your tar.gz file is
7979
rejected for addition because it is too large can be ignored.
80+
81+
Caveats
82+
-------
83+
As this is an alpha product, some functionality has not yet been implemented.
84+
85+
- Logging is via stderr only. The default logging view in Google Developers
86+
Console is "Request". Click on the dropdown showing "Request" and select
87+
"stderr" to view the logs. stderr-only logging is temporary and will change
88+
in a future version.
89+
- Log entries are not automatically associated with a specific request.
90+
- Handlers that are flagged as `login: required` or `login: admin` are not
91+
supported. Attemping to access these handlers will result in a 404 as the
92+
handlers will not be registered.
93+
94+
There may be other features that work on the current Python runtime and are not
95+
implemented or not functional in this version. Please open an issue on Github
96+
for any you encounter.

multicore_runtime/wsgi_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from static_files import static_app_for_regex_and_files
2323

24+
from google.appengine.api import appinfo
2425
from google.appengine.api import appinfo_includes
2526
from google.appengine.runtime import wsgi
2627

@@ -139,11 +140,15 @@ def load_user_scripts_into_handlers(handlers):
139140
- script: The script to serve for this handler, as a string.
140141
- app: The fully loaded app corresponding to the script.
141142
"""
143+
# `if x.login == appinfo.LOGIN_OPTIONAL` disables loading handlers
144+
# that require login or admin status entirely. This is a temporary
145+
# measure until handling of login-required handlers is implemented
146+
# securely.
142147
loaded_handlers = [
143148
(x.url if x.script or x.static_files else static_dir_url(x),
144149
x.script.replace('$PYTHON_LIB/', '') if x.script else x.script,
145150
app_for_script(x.script) if x.script else static_app_for_handler(x))
146-
for x in handlers]
151+
for x in handlers if x.login == appinfo.LOGIN_OPTIONAL]
147152
logging.info('Parsed handlers: %s',
148153
[(url, script) for (url, script, _) in loaded_handlers])
149154
return loaded_handlers

multicore_runtime/wsgi_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
appinfo.URLMap(url='/env', script='wsgi_test.dump_os_environ'),
3636
appinfo.URLMap(url='/setenv', script='wsgi_test.add_to_os_environ'),
3737
appinfo.URLMap(url='/wait', script='wsgi_test.wait_on_global_event'),
38+
appinfo.URLMap(url='/login', script='wsgi_test.hello_world',
39+
login=appinfo.LOGIN_REQUIRED),
40+
appinfo.URLMap(url='/admin', script='wsgi_test.hello_world',
41+
login=appinfo.LOGIN_ADMIN),
3842
appinfo.URLMap(url='/favicon.ico', static_files='test_statics/favicon.ico'),
3943
appinfo.URLMap(url='/faketype.ico', static_files='test_statics/favicon.ico',
4044
mime_type='application/fake_type'),
@@ -138,6 +142,16 @@ def test_basic_env(self):
138142
# Assumes PATH will be present in the env in all cases, including tests!
139143
self.assertIn('PATH', json.loads(response.data))
140144

145+
def test_login_required(self):
146+
# Login routes are temporarily disabled.
147+
response = self.client.get('/login')
148+
self.assertEqual(response.status_code, 404)
149+
150+
def test_login_admin(self):
151+
# Login routes are temporarily disabled.
152+
response = self.client.get('/admin')
153+
self.assertEqual(response.status_code, 404)
154+
141155
def test_static_file(self):
142156
response = self.client.get('/favicon.ico')
143157
self.assertEqual(response.status_code, 200)

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
package_dir={'': 'python_vm_runtime',
3434
'google.appengine.vmruntime': 'multicore_runtime',},
3535
include_package_data=True,
36-
packages=find_packages('python_vm_runtime') + ['google.appengine.vmruntime'], # pylint: disable=line-too-long
36+
packages=find_packages('python_vm_runtime',
37+
exclude=['lib.*'])+['google.appengine.vmruntime'],
3738
# namespace_packages=['google'], # This skips google/__init__.py
3839
install_requires=['requests>=2.5.0',
3940
'webapp2>=2.5.2',

0 commit comments

Comments
 (0)