412eec7f5d
* 6 new components for new login/logout flow, plus SSO support UI Components: 1. AuthDialog: Wraps/orchestrates AuthForm and AuthProfile 2. AuthForm: Authorization form shown when logged out. 3. AuthProfile: Simple presentational component to show the users 'Profile' 4. OidcSelect: A 'select' component for selecting an OIDC provider, dynamically uses either a single select menu or multiple buttons depending on the amount of providers Data Components: 1. JwtSource: Given an OIDC provider URL this component will request a token from the provider and fire an donchange event when it has been retrieved. Used by TokenSource. 2. TokenSource: Given a oidc provider name or a Consul SecretID, TokenSource will use whichever method/API requests required to retrieve Consul ACL Token, which is emitted to the onchange event handler. Very basic README documentation included here, which is likely to be refined somewhat. * CSS required for new auth/SSO UI components * Remaining app code required to tie the new auth/SSO work together * CSS code required to help tie the auth/SSO work together * Test code in order to get current tests passing with new auth/SSO flow ..plus extremely basics/skipped rendering tests for the new components * Treat the secret received from the server as the truth Previously we've always treated what the user typed as the truth, this breaks down when using SSO as the user doesn't type anything to retrieve a token. Therefore we change this so that we use the secret in the API response as the truth. * Make sure removing an dom tree from a buffer only removes its own tree
59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
/* eslint-env node */
|
|
'use strict';
|
|
//
|
|
const $ = process.env;
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const promisify = require('util').promisify;
|
|
const read = promisify(fs.readFile);
|
|
const apiDouble = require('@hashicorp/api-double');
|
|
|
|
const apiDoubleHeaders = require('@hashicorp/api-double/lib/headers');
|
|
const cookieParser = require('cookie-parser');
|
|
const bodyParser = require('body-parser');
|
|
|
|
const express = require('express');
|
|
//
|
|
module.exports = {
|
|
name: 'startup',
|
|
serverMiddleware: function(server) {
|
|
// TODO: see if we can move these into the project specific `/server` directory
|
|
// instead of inside an addon
|
|
|
|
// Serve the coverage folder for easy viewing during development
|
|
server.app.use('/coverage', express.static('coverage'));
|
|
|
|
// TODO: This should all be moved out into ember-cli-api-double
|
|
// and we should figure out a way to get to the settings here for
|
|
// so we can set this path name centrally in config
|
|
// TODO: undefined here is a possible faker salt that we should be able
|
|
// to pass in from ember serve/config somehow
|
|
const dir = path.resolve('./node_modules/@hashicorp/consul-api-double');
|
|
const controller = apiDouble(undefined, dir, read, $, path.resolve);
|
|
[
|
|
apiDoubleHeaders(),
|
|
cookieParser(),
|
|
bodyParser.text({ type: '*/*' }),
|
|
controller().serve,
|
|
].reduce(function(app, item) {
|
|
return app.use(item);
|
|
}, server.app);
|
|
},
|
|
contentFor: function(type, config) {
|
|
const vars = {
|
|
appName: config.modulePrefix,
|
|
environment: config.environment,
|
|
rootURL: config.environment === 'production' ? '{{.ContentPath}}' : config.rootURL,
|
|
config: config,
|
|
};
|
|
switch (type) {
|
|
case 'head':
|
|
return require('./templates/head.html.js')(vars);
|
|
case 'body':
|
|
return require('./templates/body.html.js')(vars);
|
|
case 'root-class':
|
|
return 'ember-loading';
|
|
}
|
|
},
|
|
};
|