diff --git a/.docker/ember-dev/Dockerfile b/.docker/ember-dev/Dockerfile deleted file mode 100644 index 8d331522..00000000 --- a/.docker/ember-dev/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM node:12-alpine - -WORKDIR /app - -CMD yarn install && ./node_modules/ember-cli/bin/ember server --port $EMBER_PORT diff --git a/.docker/nginx-template.conf b/.docker/nginx-template.conf index 3e085091..ed098eec 100644 --- a/.docker/nginx-template.conf +++ b/.docker/nginx-template.conf @@ -5,31 +5,8 @@ server { #charset utf-8; #access_log /var/log/nginx/host.access.log main; - # Add Content Security Policy - add_header Content-Security-Policy "$CSP_HEADERS"; - location / { root /usr/share/nginx/html; index index.html index.htm; - add_header Content-Security-Policy "$CSP_HEADERS"; - } - - # This is important, any 404 will cause the ember - # app to re-load. This is because all ember URLs - # (e.g. https://pass/grants/foo), when issued as an HTTP - # request, have nothing that 'serves' them. Instead, the - # ember app, when loaded, inspects the URL and renders the - # correct page client-side. So we want the ember app to load - # and parse all these 404 URLs. - # - # Note, the equals sign means that a 200 is returned - # instead of a 404 - error_page 404 = ${PASS_UI_ROOT_URL}/index.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; } } diff --git a/app/authenticators/http-only.js b/app/authenticators/http-only.js index 616c74b5..06893c44 100644 --- a/app/authenticators/http-only.js +++ b/app/authenticators/http-only.js @@ -18,9 +18,6 @@ export default class HttpOnly extends Base { */ restore(data) { return new RSVP.Promise((resolve, reject) => { - if (window.location.pathname === '/app/auth-callback') { - return reject('Could not restore session.'); - } if (!this._validateData(data)) { return reject('Could not restore session.'); } @@ -35,7 +32,7 @@ export default class HttpOnly extends Base { * @public */ async authenticate() { - const url = `${window.location.origin}/authenticated`; + const url = `/user/whoami`; let response = await fetch(url); @@ -61,16 +58,16 @@ export default class HttpOnly extends Base { async _validateData(data) { // see https://tools.ietf.org/html/rfc6749#section-4.2.2 - if (isEmpty(data) || isEmpty(data.user.id)) return false; + if (isEmpty(data) || isEmpty(data.id)) return false; - const url = `${window.location.origin}/authenticated`; + const url = `/user/whoami`; let response = await fetch(url); if (response.ok) { const refreshedData = await response.json(); - return data.user.id === refreshedData.user.id; + return data.id === refreshedData.id; } else { return false; } diff --git a/app/index.html b/app/index.html index a9ed6cf8..d8388fde 100644 --- a/app/index.html +++ b/app/index.html @@ -8,6 +8,7 @@ {{content-for "head"}} + diff --git a/app/router.js b/app/router.js index f7c8d5a9..ba14f45b 100644 --- a/app/router.js +++ b/app/router.js @@ -28,8 +28,6 @@ Router.map(function () { }); this.route('not-found-error', { path: '/*path' }); this.route('thanks'); - this.route('auth-callback'); - this.route('authenticated'); }); export default Router; diff --git a/app/routes/auth-callback.js b/app/routes/auth-callback.js deleted file mode 100644 index 321c71ec..00000000 --- a/app/routes/auth-callback.js +++ /dev/null @@ -1,15 +0,0 @@ -import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; - -export default class AuthCallbackRoute extends Route { - @service session; - @service router; - - async beforeModel() { - try { - await this.session.authenticate('authenticator:http-only'); - } catch (error) { - window.location.replace(`${window.location.origin}/logout`); - } - } -} diff --git a/app/services/app-static-config.js b/app/services/app-static-config.js index b56b6138..3495b421 100644 --- a/app/services/app-static-config.js +++ b/app/services/app-static-config.js @@ -32,10 +32,6 @@ export default class AppStaticConfigService extends Service { const overrides = `${this._config.branding.overrides}`; this.addCSS(overrides); } - if (this._config.branding.favicon) { - const favicon = `${this._config.branding.favicon}`; - this.addFavicon(favicon); - } } } @@ -85,17 +81,4 @@ export default class AppStaticConfigService extends Service { window.document.head.appendChild(newLink); } - - addFavicon(uri) { - const fav = document.querySelector('head link[rel="icon"]'); - if (fav || !uri) { - return; - } - - const newFav = window.document.createElement('link'); - newFav.setAttribute('rel', 'icon'); - newFav.setAttribute('href', uri); - - window.document.head.appendChild(newFav); - } } diff --git a/app/services/current-user.js b/app/services/current-user.js index d36f060a..bc25f3db 100644 --- a/app/services/current-user.js +++ b/app/services/current-user.js @@ -21,7 +21,7 @@ export default class CurrentUserService extends Service { */ @task load = function* () { - let userId = this.session.data.authenticated.user.id; + let userId = this.session.data.authenticated.id; if (userId) { let user = yield this.store.findRecord('user', userId); diff --git a/mirage/config.js b/mirage/config.js index d46def22..19f899c6 100644 --- a/mirage/config.js +++ b/mirage/config.js @@ -42,17 +42,6 @@ export default function (config) { }; }); - /** Auth Service */ - this.get('/authenticated', (schema, request) => { - const user = schema.find('user', 0); - - return { - user: { - id: user.id, - }, - }; - }); - /** User Service */ this.get('/pass-user-service/whoami', (schema, request) => { const userId = request.queryParams.userToken; diff --git a/tests/acceptance/app-test.js b/tests/acceptance/app-test.js index 1fe4c387..b66c4f55 100644 --- a/tests/acceptance/app-test.js +++ b/tests/acceptance/app-test.js @@ -11,7 +11,7 @@ module('Acceptance | application', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { - await authenticateSession({ user: { id: '0' } }); + await authenticateSession({ id: '0' }); }); test('Make sure app loads outside of root', async function (assert) { diff --git a/tests/acceptance/nih-submission-test.js b/tests/acceptance/nih-submission-test.js index 732986fb..e278e283 100644 --- a/tests/acceptance/nih-submission-test.js +++ b/tests/acceptance/nih-submission-test.js @@ -12,9 +12,7 @@ module('Acceptance | submission', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { - await authenticateSession({ - user: { id: '0' }, - }); + await authenticateSession({ id: '0' }); }); test('can walk through an nih submission workflow and make a submission - base case', async function (assert) { diff --git a/tests/acceptance/proxy-submission-test.js b/tests/acceptance/proxy-submission-test.js index 6a0968ad..cb0b099c 100644 --- a/tests/acceptance/proxy-submission-test.js +++ b/tests/acceptance/proxy-submission-test.js @@ -33,9 +33,7 @@ module('Acceptance | proxy submission', function (hooks) { this.server.create('user', attrs); - await authenticateSession({ - user: { id: '0' }, - }); + await authenticateSession({ id: '0' }); }); test('can walk through a proxy submission workflow and make a submission – with pass account', async function (assert) { diff --git a/tests/unit/services/current-user-test.js b/tests/unit/services/current-user-test.js index 3b7528de..63525075 100644 --- a/tests/unit/services/current-user-test.js +++ b/tests/unit/services/current-user-test.js @@ -19,7 +19,7 @@ module('Unit | Service | current-user', (hooks) => { '@id': user.get('id'), }; - service.set('session', { data: { authenticated: { user: { id: '000' } } } }); + service.set('session', { data: { authenticated: { id: '000' } } }); service.set( 'store',