-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kibana-Keystone plugin with keystone authentication. Change-Id: I1fe1e5b028a753e8e22af4b6a31305d225f0a914
- Loading branch information
Tomasz Trębski
committed
Feb 23, 2016
1 parent
bfd62b9
commit fcd5df1
Showing
17 changed files
with
1,321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
parser: babel-eslint | ||
|
||
plugins: | ||
- mocha | ||
|
||
env: | ||
es6: true | ||
amd: true | ||
node: true | ||
mocha: true | ||
browser: true | ||
|
||
|
||
rules: | ||
block-scoped-var: 2 | ||
camelcase: [ 2, { properties: never } ] | ||
comma-dangle: 0 | ||
comma-style: [ 2, last ] | ||
consistent-return: 0 | ||
curly: [ 2, multi-line ] | ||
dot-location: [ 2, property ] | ||
dot-notation: [ 2, { allowKeywords: true } ] | ||
eqeqeq: [ 2, allow-null ] | ||
guard-for-in: 2 | ||
indent: [ 2, 2, { SwitchCase: 1 } ] | ||
key-spacing: [ 0, { align: value } ] | ||
max-len: [ 2, 140, 2, { ignoreComments: true, ignoreUrls: true } ] | ||
new-cap: [ 2, { capIsNewExceptions: [ Private ] } ] | ||
no-bitwise: 0 | ||
no-caller: 2 | ||
no-cond-assign: 0 | ||
no-debugger: 2 | ||
no-empty: 2 | ||
no-eval: 2 | ||
no-extend-native: 2 | ||
no-extra-parens: 0 | ||
no-irregular-whitespace: 2 | ||
no-iterator: 2 | ||
no-loop-func: 2 | ||
no-multi-spaces: 0 | ||
no-multi-str: 2 | ||
no-nested-ternary: 2 | ||
no-new: 0 | ||
no-path-concat: 0 | ||
no-proto: 2 | ||
no-return-assign: 0 | ||
no-script-url: 2 | ||
no-sequences: 2 | ||
no-shadow: 0 | ||
no-trailing-spaces: 2 | ||
no-undef: 2 | ||
no-underscore-dangle: 0 | ||
no-unused-expressions: 0 | ||
no-unused-vars: 0 | ||
no-use-before-define: [ 2, nofunc ] | ||
no-with: 2 | ||
one-var: [ 2, never ] | ||
quotes: [ 2, single ] | ||
semi-spacing: [ 2, { before: false, after: true } ] | ||
semi: [ 2, always ] | ||
space-after-keywords: [ 2, always ] | ||
space-before-blocks: [ 2, always ] | ||
space-before-function-paren: [ 2, { anonymous: always, named: never } ] | ||
space-in-parens: [ 2, never ] | ||
space-infix-ops: [ 2, { int32Hint: false } ] | ||
space-return-throw-case: [ 2 ] | ||
space-unary-ops: [ 2 ] | ||
strict: [ 2, never ] | ||
valid-typeof: 2 | ||
wrap-iife: [ 2, outside ] | ||
yoda: 0 | ||
|
||
mocha/no-exclusive-tests: 2 | ||
mocha/handle-done-callback: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
build/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2016 FUJITSU LIMITED | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License | ||
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the License for the specific language governing permissions and limitations under | ||
the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright 2016 FUJITSU LIMITED | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
var babel = require('babel-register')({ | ||
presets: ['es2015'] | ||
}); | ||
|
||
var gulp = require('gulp'); | ||
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
var Rsync = require('rsync'); | ||
var Promise = require('bluebird'); | ||
var eslint = require('gulp-eslint'); | ||
var rimraf = require('rimraf'); | ||
var tar = require('gulp-tar'); | ||
var gzip = require('gulp-gzip'); | ||
var fs = require('fs'); | ||
var mocha = require('gulp-mocha'); | ||
|
||
var pkg = require('./package.json'); | ||
var packageName = pkg.name + '-' + pkg.version; | ||
|
||
// relative location of Kibana install | ||
var pathToKibana = '../kibana'; | ||
|
||
var buildDir = path.resolve(__dirname, 'build'); | ||
var targetDir = path.resolve(__dirname, 'target'); | ||
var buildTarget = path.resolve(buildDir, pkg.name); | ||
var kibanaPluginDir = path.resolve(__dirname, pathToKibana, 'installedPlugins', pkg.name); | ||
|
||
var exclude = [ | ||
'.git', | ||
'.idea', | ||
'gulpfile.js', | ||
'.babelrc', | ||
'.gitignore', | ||
'.eslintrc', | ||
'__tests__' | ||
]; | ||
|
||
Object.keys(pkg.devDependencies).forEach(function (name) { | ||
exclude.push(path.join('node_modules', name)); | ||
}); | ||
|
||
function syncPluginTo(dest, done) { | ||
mkdirp(dest, function (err) { | ||
if (err) return done(err); | ||
|
||
var source = path.resolve(__dirname) + '/'; | ||
var rsync = new Rsync(); | ||
|
||
rsync | ||
.source(source) | ||
.destination(dest) | ||
.flags('uav') | ||
.recursive(true) | ||
.set('delete') | ||
.exclude(exclude) | ||
.output(function (data) { | ||
process.stdout.write(data.toString('utf8')); | ||
}); | ||
|
||
rsync.execute(function (err) { | ||
if (err) { | ||
console.log(err); | ||
return done(err); | ||
} | ||
done(); | ||
}); | ||
}); | ||
} | ||
|
||
gulp.task('sync', ['lint'], function (done) { | ||
syncPluginTo(kibanaPluginDir, done); | ||
}); | ||
|
||
gulp.task('lint', function () { | ||
var filePaths = [ | ||
'gulpfile.js', | ||
'server/**/*.js', | ||
'public/**/*.js', | ||
'public/**/*.jsx' | ||
]; | ||
|
||
return gulp.src(filePaths) | ||
// eslint() attaches the lint output to the eslint property | ||
// of the file object so it can be used by other modules. | ||
.pipe(eslint()) | ||
// eslint.format() outputs the lint results to the console. | ||
// Alternatively use eslint.formatEach() (see Docs). | ||
.pipe(eslint.formatEach()) | ||
// To have the process exit with an error code (1) on | ||
// lint error, return the stream and pipe to failOnError last. | ||
.pipe(eslint.failOnError()); | ||
}); | ||
|
||
gulp.task('test', function () { | ||
return gulp.src(['server/**/*.spec.js']) | ||
.pipe(mocha({ | ||
compilers: { | ||
js: babel | ||
} | ||
})); | ||
}); | ||
|
||
gulp.task('clean', function (done) { | ||
Promise.each([buildDir, targetDir], function (dir) { | ||
return new Promise(function (resolve, reject) { | ||
rimraf(dir, function (err) { | ||
if (err) return reject(err); | ||
resolve(); | ||
}); | ||
}); | ||
}).nodeify(done); | ||
}); | ||
|
||
gulp.task('build', ['clean'], function (done) { | ||
syncPluginTo(buildTarget, done); | ||
}); | ||
|
||
gulp.task('package', ['build'], function () { | ||
return gulp.src(path.join(buildDir, '**', '*')) | ||
.pipe(tar(packageName + '.tar')) | ||
.pipe(gzip()) | ||
.pipe(gulp.dest(targetDir)); | ||
}); | ||
|
||
gulp.task('dev', ['sync'], function () { | ||
gulp.watch( | ||
['package.json', 'index.js', 'public/**/*', 'server/**/*'], | ||
['sync']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2016 FUJITSU LIMITED | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
module.exports = (kibana) => { | ||
|
||
const session = require('./server/session'); | ||
const proxy = require('./server/proxy'); | ||
const healthCheck = require('./server/healthcheck'); | ||
|
||
return new kibana.Plugin({ | ||
require: ['elasticsearch'], | ||
config : config, | ||
init : init | ||
}); | ||
|
||
function config(Joi) { | ||
|
||
const cookie = Joi.object({ | ||
password : Joi.string() | ||
.min(16) | ||
.default(require('crypto').randomBytes(16).toString('hex')), | ||
isSecure : Joi.boolean() | ||
.default(false), | ||
ignoreErrors: Joi.boolean() | ||
.default(true), | ||
expiresIn : Joi.number() | ||
.positive() | ||
.integer() | ||
.default(24 * 60 * 60 * 1000) // 1 day | ||
}).default(); | ||
|
||
return Joi.object({ | ||
enabled: Joi.boolean().default(true), | ||
url : Joi.string() | ||
.uri({scheme: ['http', 'https']}) | ||
.required(), | ||
port : Joi.number().required(), | ||
cookie : cookie | ||
}).default(); | ||
} | ||
|
||
function init(server) { | ||
session(server); | ||
proxy(server); | ||
healthCheck(this, server).start(); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "fts-keystone", | ||
"version": "0.0.1", | ||
"description": "Keystone authentication support for Kibana 4.4.x", | ||
"author": "Fujitsu Enabling Software Technology GmbH", | ||
"licenses": "Apache-2.0", | ||
"keywords": [ | ||
"kibana", | ||
"authentication", | ||
"keystone", | ||
"plugin" | ||
], | ||
"scripts": { | ||
"start": "gulp dev", | ||
"build": "gulp build", | ||
"package": "gulp package", | ||
"test": "gulp test" | ||
}, | ||
"engines": { | ||
"node": "0.12.9", | ||
"npm": "2.14.3" | ||
}, | ||
"main": "gulpfile.js", | ||
"dependencies": { | ||
"yar": "^4.2.0", | ||
"keystone-v3-client": "^0.0.7" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/FujitsuEnablingSoftwareTechnologyGmbH/fts-keystone.git" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^4.1.8", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-register": "^6.4.3", | ||
"bluebird": "^3.2.1", | ||
"boom": "^2.8.0", | ||
"chai": "^3.5.0", | ||
"eslint-plugin-mocha": "^1.1.0", | ||
"gulp": "^3.9.0", | ||
"gulp-eslint": "^1.1.1", | ||
"gulp-gzip": "^1.2.0", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-tar": "^1.8.0", | ||
"gulp-util": "^3.0.7", | ||
"lodash": "^4.2.1", | ||
"mkdirp": "^0.5.1", | ||
"proxyquire": "^1.7.4", | ||
"rimraf": "^2.5.1", | ||
"rsync": "^0.4.0", | ||
"sinon": "^1.17.3" | ||
} | ||
} |
Oops, something went wrong.