Browse Source

Added minishift configuration

pull/160/head
Mike Olund 7 years ago
parent
commit
b4cb2c7d49
10 changed files with 110 additions and 15 deletions
  1. +1
    -1
      edivorce/apps/core/context_processors.py
  2. +2
    -2
      edivorce/apps/core/middleware/bceid_middleware.py
  3. +1
    -1
      edivorce/apps/core/views/localdev.py
  4. +3
    -3
      edivorce/apps/core/views/main.py
  5. +1
    -1
      edivorce/apps/core/views/system.py
  6. +1
    -1
      edivorce/settings/base.py
  7. +10
    -3
      edivorce/settings/openshift.py
  8. +2
    -2
      edivorce/urls.py
  9. +88
    -0
      openshift/MINISHIFT.md
  10. +1
    -1
      openshift/templates/edivorce-environment-template.yaml

+ 1
- 1
edivorce/apps/core/context_processors.py View File

@ -6,5 +6,5 @@ def settings_processor(request):
return { return {
'gtm_id': settings.GTM_ID, 'gtm_id': settings.GTM_ID,
'proxy_root_path': settings.FORCE_SCRIPT_NAME, 'proxy_root_path': settings.FORCE_SCRIPT_NAME,
'show_debug': settings.ENVIRONMENT in ['localdev', 'dev', 'test']
'show_debug': settings.ENVIRONMENT in ['localdev', 'dev', 'test', 'minishift']
} }

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

@ -78,7 +78,7 @@ class BceidMiddleware(object): # pylint: disable=too-few-public-methods
""" """
# make sure the request didn't bypass the proxy # make sure the request didn't bypass the proxy
if (settings.DEPLOYMENT_TYPE != 'localdev' and
if (settings.DEPLOYMENT_TYPE not in ['localdev', 'minishift'] and
not self.__request_came_from_proxy(request)): not self.__request_came_from_proxy(request)):
return redirect(settings.PROXY_BASE_URL + request.path) return redirect(settings.PROXY_BASE_URL + request.path)
@ -92,7 +92,7 @@ class BceidMiddleware(object): # pylint: disable=too-few-public-methods
# link on our app or closing the browser. This is an extreme edge case, # link on our app or closing the browser. This is an extreme edge case,
# and it's not pragmatic to code against it at this time. # and it's not pragmatic to code against it at this time.
siteminder_user = request.META.get('HTTP_SM_USER', '') siteminder_user = request.META.get('HTTP_SM_USER', '')
is_localdev = settings.DEPLOYMENT_TYPE == 'localdev'
is_localdev = settings.DEPLOYMENT_TYPE in ['localdev', 'minishift']
update_user = False update_user = False
guid = request.META.get('HTTP_SMGOV_USERGUID', '') guid = request.META.get('HTTP_SMGOV_USERGUID', '')


+ 1
- 1
edivorce/apps/core/views/localdev.py View File

@ -20,7 +20,7 @@ def bceid(request):
# convert the login name to a guid # convert the login name to a guid
hex_name = decode(binascii.hexlify(str.encode(login_name)))[0] hex_name = decode(binascii.hexlify(str.encode(login_name)))[0]
fake_guid = uuid.UUID(hex_name.rjust(32, '0')).urn[9:]
fake_guid = hex_name.rjust(32, '0')
# save the guid in a session variable # save the guid in a session variable
request.session['login_name'] = login_name request.session['login_name'] = login_name


+ 3
- 3
edivorce/apps/core/views/main.py View File

@ -82,7 +82,7 @@ def register(request):
""" """
Sets a session variable and redirects users to register for BCeID Sets a session variable and redirects users to register for BCeID
""" """
if settings.DEPLOYMENT_TYPE == 'localdev':
if settings.DEPLOYMENT_TYPE in ['localdev', 'minishift']:
return render(request, 'localdev/register.html') return render(request, 'localdev/register.html')
request.session['went_to_register'] = True request.session['went_to_register'] = True
@ -95,7 +95,7 @@ def login(request):
logged into BCeID will get a login page. Users who are logged into logged into BCeID will get a login page. Users who are logged into
BCeID will be redirected to the dashboard BCeID will be redirected to the dashboard
""" """
if settings.DEPLOYMENT_TYPE == 'localdev' and not request.session.get('fake_bceid_guid'):
if settings.DEPLOYMENT_TYPE in ['localdev', 'minishift'] and not request.session.get('fake_bceid_guid'):
return redirect(settings.PROXY_BASE_URL + settings.FORCE_SCRIPT_NAME[:-1] + '/bceid') return redirect(settings.PROXY_BASE_URL + settings.FORCE_SCRIPT_NAME[:-1] + '/bceid')
if not request.user.is_authenticated(): if not request.user.is_authenticated():
@ -133,7 +133,7 @@ def logout(request):
response = redirect(settings.LOGOUT_URL) response = redirect(settings.LOGOUT_URL)
if settings.DEPLOYMENT_TYPE == 'localdev':
if settings.DEPLOYMENT_TYPE in ['localdev', 'minishift']:
response = redirect('/') response = redirect('/')
return response return response


+ 1
- 1
edivorce/apps/core/views/system.py View File

@ -21,7 +21,7 @@ def current(request):
""" """
Debug tool usable in dev and test environments, available at /current Debug tool usable in dev and test environments, available at /current
""" """
if settings.ENVIRONMENT not in ['localdev', 'dev', 'test']:
if settings.ENVIRONMENT not in ['localdev', 'dev', 'test', 'minishift']:
raise Http404() raise Http404()
if request.GET.get('reset', False): if request.GET.get('reset', False):


+ 1
- 1
edivorce/settings/base.py View File

@ -136,7 +136,7 @@ GTM_ID = 'GTM-NJLR7LT'
def show_toolbar(request): def show_toolbar(request):
return ENVIRONMENT in ['localdev', 'dev', 'test']
return ENVIRONMENT in ['localdev', 'dev', 'test', 'minishift']
DEBUG_TOOLBAR_CONFIG = { DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': show_toolbar, 'SHOW_TOOLBAR_CALLBACK': show_toolbar,


+ 10
- 3
edivorce/settings/openshift.py View File

@ -48,6 +48,7 @@ COMPRESS_OFFLINE = True
DEPLOYMENT_TYPE = os.getenv('ENVIRONMENT_TYPE') DEPLOYMENT_TYPE = os.getenv('ENVIRONMENT_TYPE')
PROXY_URL_PREFIX = '' PROXY_URL_PREFIX = ''
PROXY_BASE_URL = 'https://justice.gov.bc.ca'
if DEPLOYMENT_TYPE == 'dev': if DEPLOYMENT_TYPE == 'dev':
PROXY_URL_PREFIX = "/divorce-dev" PROXY_URL_PREFIX = "/divorce-dev"
@ -64,6 +65,11 @@ if DEPLOYMENT_TYPE == 'prod':
# Google Tag Manager (Production) # Google Tag Manager (Production)
GTM_ID = 'GTM-W4Z2SPS' GTM_ID = 'GTM-W4Z2SPS'
if DEPLOYMENT_TYPE == 'minishift':
DEBUG = True
REGISTER_URL = '#'
PROXY_BASE_URL = ''
# Internal Relative Urls # Internal Relative Urls
FORCE_SCRIPT_NAME = PROXY_URL_PREFIX + '/' FORCE_SCRIPT_NAME = PROXY_URL_PREFIX + '/'
STATIC_URL = PROXY_URL_PREFIX + '/static/' STATIC_URL = PROXY_URL_PREFIX + '/static/'
@ -74,7 +80,6 @@ WEASYPRINT_CSS_LOOPBACK = 'http://edivorce-django:8080'
WEASYPRINT_CSS_LOOPBACK += PROXY_URL_PREFIX WEASYPRINT_CSS_LOOPBACK += PROXY_URL_PREFIX
# External URLs # External URLs
PROXY_BASE_URL = 'https://justice.gov.bc.ca'
LOGOUT_URL_TEMPLATE = 'https://logon.gov.bc.ca/clp-cgi/logoff.cgi?returl=%s%s&retnow=1' LOGOUT_URL_TEMPLATE = 'https://logon.gov.bc.ca/clp-cgi/logoff.cgi?returl=%s%s&retnow=1'
LOGOUT_URL = LOGOUT_URL_TEMPLATE % (PROXY_BASE_URL, PROXY_URL_PREFIX) LOGOUT_URL = LOGOUT_URL_TEMPLATE % (PROXY_BASE_URL, PROXY_URL_PREFIX)
@ -84,6 +89,8 @@ BASICAUTH_USERNAME = os.getenv('BASICAUTH_USERNAME', '')
BASICAUTH_PASSWORD = os.getenv('BASICAUTH_PASSWORD', '') BASICAUTH_PASSWORD = os.getenv('BASICAUTH_PASSWORD', '')
# Lock down the session cookie settings # Lock down the session cookie settings
SESSION_COOKIE_SECURE=True
SESSION_COOKIE_PATH = PROXY_URL_PREFIX
SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True
if DEPLOYMENT_TYPE != 'minishift':
SESSION_COOKIE_PATH = PROXY_URL_PREFIX
SESSION_COOKIE_SECURE=True

+ 2
- 2
edivorce/urls.py View File

@ -4,11 +4,11 @@ from django.contrib import admin
urlpatterns = [] urlpatterns = []
if settings.ENVIRONMENT in ['localdev', 'dev', 'test']:
if settings.ENVIRONMENT in ['localdev', 'dev', 'test', 'minishift']:
import debug_toolbar import debug_toolbar
urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)),) urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls)),)
if settings.ENVIRONMENT == 'localdev':
if settings.ENVIRONMENT in ['localdev', 'minishift']:
urlpatterns.append(url(r'^admin/', admin.site.urls)) urlpatterns.append(url(r'^admin/', admin.site.urls))
urlpatterns.append(url(r'^', include('edivorce.apps.core.urls'))) urlpatterns.append(url(r'^', include('edivorce.apps.core.urls')))

+ 88
- 0
openshift/MINISHIFT.md View File

@ -0,0 +1,88 @@
# A Quickstart Guide to Setting Up eDivorce on MiniShift
These instructions assume you have 2 EMPTY projects created in MiniShift:
- jag-csb-edivorce-tools (BUILD)
- jag-csb-edivorce-dev (DEV)
For Minishift deployments we won't bother setting up Jenkins or NGINX.
## Uploading Templates into OpenShift
1. Clone the project from Github, and then ```cd``` into the openshift/templates directory.
2. Log into the OpenShift console to get your command line token. Then log into OpenShift from the command line.
3. Upload the templates into OpenShift with the following commands
Tools templates
```
oc create -f edivorce-build-template.yaml -n jag-csb-edivorce-tools
```
Main eDivorce environment template
```
oc create -f edivorce-environment-template.yaml -n jag-csb-edivorce-dev
```
## Setting up the Tools Project
### Process the templates in the 'tools' project
#### These can be processed from the commandline
```
oc project jag-csb-edivorce-tools
oc process edivorce-build | oc create -f -
```
You can monitor the process of the build in the OpenShift console on Minishift. You'll need to wait for it to finish before you can start the next step.
## Setting up Dev
Tag the builds in the tools project so they can be deployed to dev
```
oc project jag-csb-edivorce-tools
```
Give the dev project access to Docker images stored in the tools project
```
oc project jag-csb-edivorce-dev
oc policy add-role-to-user system:image-puller system:serviceaccount:jag-csb-edivorce-dev:default -n jag-csb-edivorce-tools
oc policy add-role-to-user edit system:serviceaccount:jag-csb-edivorce-tools:default -n jag-csb-edivorce-dev
```
Deploy the Django app and the Postgresql DB (Read the section about "Important Configuration Options" above!)
```
oc process edivorce -v ENVIRONMENT_TYPE=minishift,PROXY_NETWORK=0.0.0.0/0 | oc create -f -
```
Edit the yaml for the edivorce-django deployment config through the web console
Find:
kind: ImageStreamTag
name: 'edivorce-django:deploy-to-dev'
Change to:
kind: ImageStreamTag
name: 'edivorce-django:latest'
Deploy Weasyprint
```
oc deploy weasyprint --latest
```
## Create a Route
Using the web console, create a new route called "minishift" in the jag-csb-edivorce-dev project. The only thing you need to change is the name. Otherwise just use default settings.
## Log into eDivorce
You should be able to find your route in the edivorce-django deployment of the jag-csb-edivorce-dev project. When you are prompted for a username and password you can use the password 'dovorce' with any username you choose.

+ 1
- 1
openshift/templates/edivorce-environment-template.yaml View File

@ -334,7 +334,7 @@ parameters:
value: jag-csb-edivorce-tools value: jag-csb-edivorce-tools
required: true required: true
- name: ENVIRONMENT_TYPE - name: ENVIRONMENT_TYPE
displayName: Type of environnment (dev,test or prod).
displayName: Type of environnment (dev,test,prod or minishift).
required: true required: true
- name: PROXY_NETWORK - name: PROXY_NETWORK
displayName: Network of upstream proxy (CIDR notation 0.0.0.0/0) displayName: Network of upstream proxy (CIDR notation 0.0.0.0/0)


Loading…
Cancel
Save