Browse Source

Merge branch 'DIV-1031' into master

pull/172/head
Michael Olund 5 years ago
parent
commit
7aa156731c
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      edivorce/apps/core/middleware/bceid_middleware.py

+ 7
- 1
edivorce/apps/core/middleware/bceid_middleware.py View File

@ -70,6 +70,7 @@ class BceidMiddleware(MiddlewareMixin): # pylint: disable=too-few-public-method
In a local development environment, we generate a guid based on the login In a local development environment, we generate a guid based on the login
name and treat that guid/login name as guid/display name. name and treat that guid/login name as guid/display name.
""" """
def process_request(self, request): # pylint: disable=too-many-branches def process_request(self, request): # pylint: disable=too-many-branches
""" """
Return None after populating request.user, or necessary redirects. Return None after populating request.user, or necessary redirects.
@ -162,13 +163,18 @@ class BceidMiddleware(MiddlewareMixin): # pylint: disable=too-few-public-method
Health checks and static resources are allowed from any source. The Health checks and static resources are allowed from any source. The
latter is mainly so WeasyPrint can request CSS. latter is mainly so WeasyPrint can request CSS.
""" """
if request.path == settings.FORCE_SCRIPT_NAME + 'health': if request.path == settings.FORCE_SCRIPT_NAME + 'health':
return True return True
if request.path.startswith(settings.FORCE_SCRIPT_NAME[:-1] + settings.STATIC_URL): if request.path.startswith(settings.FORCE_SCRIPT_NAME[:-1] + settings.STATIC_URL):
return True return True
# If the request didn't come through NGINX then we allow it. These requests
# are coming from other OpenShift pods (e.g. WeasyPrint fetching image files).
# The only public route to the application comes through the NGINX service.
if not request.META.get('X-Real-IP', None):
return True
bcgov_network = ip_network(settings.BCGOV_NETWORK) bcgov_network = ip_network(settings.BCGOV_NETWORK)
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',') x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')
forwarded_for = [ip.strip() for ip in x_forwarded_for if ip.strip() != ''] forwarded_for = [ip.strip() for ip in x_forwarded_for if ip.strip() != '']


Loading…
Cancel
Save