Commit 315135dd authored by Jochen Kressin's avatar Jochen Kressin
Browse files

select tenant by request param #24

parent f57c7d24
#!/bin/bash
PLUGIN_NAME=searchguard-kibana
PLUGIN_VERSION=5.3.1-3-SNAPSHOT
KIBANA_VERSION=5.3.1
PLUGIN_VERSION=5.3.2-3-SNAPSHOT
KIBANA_VERSION=5.3.2
echo "Building $PLUGIN_NAME-$PLUGIN_VERSION.zip"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..
......
......@@ -20,12 +20,28 @@ export default function (pluginRoot, server, APP_ROOT, API_ROOT) {
const config = server.config();
const basePath = config.get('server.basePath');
const backend = server.plugins.searchguard.getSearchGuardBackend();
server.ext('onPostAuth', async function (request, next) {
server.ext('onPostAuth', function (request, next) {
var selectedTenant = request.state.searchguard_tenant;
if (request.query && request.query.sg_tenant) {
// check whether the tenant in the request param is contained in the
// list of valid tenants from the backend
let requestedTenant = request.query.sg_tenant;
let response = await backend.authinfo(request.headers);
if(response.sg_tenants && response.sg_tenants[requestedTenant]) {
selectedTenant = requestedTenant;
next.state('searchguard_tenant', selectedTenant);
}
}
if (selectedTenant != null) {
assign(request.headers, {'sg_tenant' : selectedTenant});
}
return next.continue();
});
}
{
"name": "searchguard",
"version": "5.3.1",
"version": "5.3.2",
"description": "Search Guard features for kibana",
"main": "index.js",
"homepage": "https://floragunn.com",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment