mirror of https://gitee.com/bigwinds/arangodb
Export cluster auth on dispatchers (non-cluster) to JS.
This commit is contained in:
parent
2390008f00
commit
02b68533e1
|
@ -1251,6 +1251,26 @@ static v8::Handle<v8::Value> JS_StatusServerState (v8::Arguments const& argv) {
|
|||
return scope.Close(v8::String::New(state.c_str(), (int) state.size()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the server state
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_GetClusterAuthentication (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (argv.Length() != 0) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "getClusterAuthentication()");
|
||||
}
|
||||
|
||||
std::string auth;
|
||||
if (ServerState::instance()->getRole() == ServerState::ROLE_UNDEFINED) {
|
||||
// Only on dispatchers, otherwise this would be a security risk!
|
||||
auth = ServerState::instance()->getAuthentication();
|
||||
}
|
||||
|
||||
return scope.Close(v8::String::New(auth.c_str(), (int) auth.size()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief prepare to send a request
|
||||
///
|
||||
|
@ -1832,6 +1852,7 @@ void TRI_InitV8Cluster (v8::Handle<v8::Context> context) {
|
|||
TRI_AddMethodVocbase(rt, "setId", JS_SetIdServerState, true);
|
||||
TRI_AddMethodVocbase(rt, "setRole", JS_SetRoleServerState, true);
|
||||
TRI_AddMethodVocbase(rt, "status", JS_StatusServerState);
|
||||
TRI_AddMethodVocbase(rt, "getClusterAuthentication", JS_GetClusterAuthentication);
|
||||
|
||||
v8g->ServerStateTempl = v8::Persistent<v8::ObjectTemplate>::New(isolate, rt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "ArangoServerStateCtor", ft->GetFunction(), true);
|
||||
|
|
Loading…
Reference in New Issue