mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
cb18e9e8b3
|
@ -7,3 +7,6 @@ You can find packages for various operation systems at our [download](http://www
|
|||
|
||||
If you don't want to install ArangoDB at the beginning and just want to experiment with the features, you can use our [online demo](https://www.arangodb.org/tryitout).
|
||||
|
||||
In this Chapter you will also learn how to Compile ArangoDB from scratch.
|
||||
|
||||
You also get help if you want to update your ArangoDB Version to the newest one!
|
|
@ -5,6 +5,8 @@
|
|||
* [Mac OS X](Installing/MacOSX.md)
|
||||
* [Windows](Installing/Windows.md)
|
||||
* [Compiling](Installing/Compiling.md)
|
||||
* [Upgrading in general](Installing/Upgrading.md)
|
||||
* [Set up Cluster](Installing/Cluster.md)
|
||||
<!-- 2 -->
|
||||
* [First Steps](FirstSteps/README.md)
|
||||
* [Getting Familiar](FirstSteps/GettingFamiliar.md)
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
<li>
|
||||
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank"class="issues-link">Have any questions?</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.arangodb.org/manuals/2/NewFeatures21.html" target="_blank">Whats New in this Version?</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if _divider %}
|
||||
<li class="divider"></li>
|
||||
|
|
|
@ -60,8 +60,7 @@ def fetch_comments(dirpath):
|
|||
if ("@startDocuBlock" in _text) or \
|
||||
("@endDocuBlock" in _text):
|
||||
fh.write("<!-- %s -->\n\n" % _text)
|
||||
elif ("@EXAMPLE_ARANGOSH_OUTPUT" in _text or \
|
||||
"@EXAMPLE_ARANGOSH_RUN" in _text):
|
||||
elif ("@EXAMPLE_ARANGOSH_OUTPUT" in _text):
|
||||
shouldIgnoreLine = True
|
||||
_filename = re.search("{(.*)}", _text).group(1)
|
||||
dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir, "Examples", _filename + ".generated"))
|
||||
|
@ -71,8 +70,7 @@ def fetch_comments(dirpath):
|
|||
print "Could not find code for " + _filename
|
||||
else:
|
||||
fh.write("%s\n" % _text)
|
||||
elif ("@END_EXAMPLE_ARANGOSH_OUTPUT" in _text or \
|
||||
"@END_EXAMPLE_ARANGOSH_RUN" in _text):
|
||||
elif ("@END_EXAMPLE_ARANGOSH_OUTPUT" in _text):
|
||||
shouldIgnoreLine = False
|
||||
|
||||
fh.close()
|
||||
|
@ -81,7 +79,7 @@ if __name__ == "__main__":
|
|||
open("allComments.txt", "w").close()
|
||||
path = ["arangod/cluster","arangod/RestHandler","arangod/V8Server",
|
||||
"lib/Admin","lib/HttpServer",
|
||||
"js/actions","js/client","js/apps","js/common","js/server"]
|
||||
"js/actions","js/client","js/apps/databases","js/apps/system/cerberus","js/apps/system/gharial","js/common","js/server"]
|
||||
for i in path:
|
||||
dirpath = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir,"ArangoDB/../../"+i))
|
||||
fetch_comments(dirpath)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
SYS_DOWNLOAD, SYS_EXECUTE, SYS_GET_CURRENT_REQUEST, SYS_GET_CURRENT_RESPONSE,
|
||||
SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
|
||||
SYS_RAND, SYS_SERVER_STATISTICS, SYS_SPRINTF, SYS_TIME, SYS_START_PAGER, SYS_STOP_PAGER,
|
||||
SYS_SHA256, SYS_SLEEP, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
SYS_HMAC, SYS_SHA256, SYS_SLEEP, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
SYS_GEN_RANDOM_NUMBERS, SYS_GEN_RANDOM_ALPHA_NUMBERS, SYS_GEN_RANDOM_SALT, SYS_CREATE_NONCE,
|
||||
SYS_CHECK_AND_MARK_NONCE, SYS_CLIENT_STATISTICS, SYS_HTTP_STATISTICS, SYS_UNIT_TESTS, SYS_UNIT_TESTS_RESULT:true,
|
||||
SYS_PROCESS_CSV_FILE, SYS_PROCESS_JSON_FILE, ARANGO_QUIET, COLORS, COLOR_OUTPUT,
|
||||
|
@ -559,6 +559,15 @@
|
|||
delete SYS_GEN_RANDOM_SALT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sha256
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_HMAC !== "undefined") {
|
||||
exports.hmac = SYS_HMAC;
|
||||
delete SYS_HMAC;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief createNonce
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
SYS_DOWNLOAD, SYS_EXECUTE, SYS_GET_CURRENT_REQUEST, SYS_GET_CURRENT_RESPONSE,
|
||||
SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
|
||||
SYS_RAND, SYS_SERVER_STATISTICS, SYS_SPRINTF, SYS_TIME, SYS_START_PAGER, SYS_STOP_PAGER,
|
||||
SYS_SHA256, SYS_SLEEP, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
SYS_HMAC, SYS_SHA256, SYS_SLEEP, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
SYS_GEN_RANDOM_NUMBERS, SYS_GEN_RANDOM_ALPHA_NUMBERS, SYS_GEN_RANDOM_SALT, SYS_CREATE_NONCE,
|
||||
SYS_CHECK_AND_MARK_NONCE, SYS_CLIENT_STATISTICS, SYS_HTTP_STATISTICS, SYS_UNIT_TESTS, SYS_UNIT_TESTS_RESULT:true,
|
||||
SYS_PROCESS_CSV_FILE, SYS_PROCESS_JSON_FILE, ARANGO_QUIET, COLORS, COLOR_OUTPUT,
|
||||
|
@ -559,6 +559,15 @@
|
|||
delete SYS_GEN_RANDOM_SALT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sha256
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_HMAC !== "undefined") {
|
||||
exports.hmac = SYS_HMAC;
|
||||
delete SYS_HMAC;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief createNonce
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -38,11 +38,6 @@ var internal = require("internal");
|
|||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Random
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generate a random number
|
||||
///
|
||||
|
@ -54,10 +49,6 @@ exports.rand = function (value) {
|
|||
return internal.rand();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- HASHES
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -67,10 +58,13 @@ exports.rand = function (value) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Hashes
|
||||
/// @{
|
||||
/// @brief apply an SHA 256 hash
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.hmac = function (key, message, algorithm) {
|
||||
return internal.hmac(key, message, algorithm);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief apply an MD5 hash
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -127,10 +121,6 @@ exports.checkAndMarkNonce = function (value) {
|
|||
return internal.checkAndMarkNonce(value);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -182,12 +182,21 @@ namespace triagens {
|
|||
}
|
||||
|
||||
|
||||
string sslHMAC (char const* key, char const* message, size_t messageLen) {
|
||||
const EVP_MD * evp_md = EVP_sha256();
|
||||
string sslHMAC (char const* key, size_t keyLength, char const* message, size_t messageLen, Algorithm algorithm) {
|
||||
EVP_MD* evp_md = nullptr;
|
||||
|
||||
if (algorithm == Algorithm::ALGORITHM_SHA1) {
|
||||
evp_md = const_cast<EVP_MD*>(EVP_sha1());
|
||||
}
|
||||
else {
|
||||
// default
|
||||
evp_md = const_cast<EVP_MD*>(EVP_sha256());
|
||||
}
|
||||
|
||||
unsigned char* md = (unsigned char*) TRI_SystemAllocate(EVP_MAX_MD_SIZE + 1, false);
|
||||
unsigned int md_len;
|
||||
|
||||
HMAC(evp_md, key, (int) strlen(key), (const unsigned char*) message, messageLen, md, &md_len);
|
||||
HMAC(evp_md, key, (int) keyLength, (const unsigned char*) message, messageLen, md, &md_len);
|
||||
|
||||
string result = StringUtils::encodeBase64(string((char*)md, md_len));
|
||||
TRI_SystemFree(md);
|
||||
|
@ -197,15 +206,15 @@ namespace triagens {
|
|||
|
||||
|
||||
|
||||
bool verifyHMAC (char const* challenge, char const* secret, size_t secretLen, char const* response, size_t responseLen) {
|
||||
bool verifyHMAC (char const* challenge, size_t challengeLength, char const* secret, size_t secretLen, char const* response, size_t responseLen, Algorithm algorithm) {
|
||||
// challenge = key
|
||||
// secret, secretLen = message
|
||||
// result must == BASE64(response, responseLen)
|
||||
|
||||
string s = sslHMAC(challenge, secret, secretLen);
|
||||
string s = sslHMAC(challenge, challengeLength, secret, secretLen, algorithm);
|
||||
|
||||
if (s.length() == responseLen && s.compare( string(response, responseLen) ) == 0) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -34,6 +34,11 @@ namespace triagens {
|
|||
namespace rest {
|
||||
namespace SslInterface {
|
||||
|
||||
enum Algorithm {
|
||||
ALGORITHM_SHA256 = 0,
|
||||
ALGORITHM_SHA1 = 1
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief md5 hash
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -116,13 +121,13 @@ namespace triagens {
|
|||
/// @brief HMAC with sha265 hashing and base64 encoding
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string sslHMAC (char const* key, char const* message, size_t messageLen);
|
||||
string sslHMAC (char const* key, size_t keyLength, char const* message, size_t messageLen, Algorithm algorithm);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief HMAC
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool verifyHMAC (char const* challenge, char const* secret, size_t secretLen, char const* response, size_t responseLen);
|
||||
bool verifyHMAC (char const* challenge, size_t challengeLength, char const* secret, size_t secretLen, char const* response, size_t responseLen, Algorithm algorithm);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generate a random number using OpenSsl
|
||||
|
|
|
@ -2515,6 +2515,45 @@ static v8::Handle<v8::Value> JS_ClientStatistics (v8::Arguments const& argv) {
|
|||
return scope.Close(result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief computes the HMAC signature
|
||||
///
|
||||
/// @FUN{internal.HMAC(@FA{key}, @FA{message}, @FA{algorithm})}
|
||||
///
|
||||
/// Computes the HMAC for the @FA{message}.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_HMAC (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
// extract arguments
|
||||
if (argv.Length() < 2 || ! argv[0]->IsString() || ! argv[1]->IsString()) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "HMAC(<key>, <text>, <algorithm>)");
|
||||
}
|
||||
|
||||
string key = TRI_ObjectToString(argv[0]);
|
||||
string message = TRI_ObjectToString(argv[1]);
|
||||
|
||||
SslInterface::Algorithm al = SslInterface::Algorithm::ALGORITHM_SHA256;
|
||||
if (argv.Length() > 2 && ! argv[2]->IsUndefined()) {
|
||||
string algorithm = TRI_ObjectToString(argv[2]);
|
||||
StringUtils::tolowerInPlace(&algorithm);
|
||||
|
||||
if (algorithm == "sha1") {
|
||||
al = SslInterface::Algorithm::ALGORITHM_SHA1;
|
||||
}
|
||||
else if (algorithm == "sha256") {
|
||||
al = SslInterface::Algorithm::ALGORITHM_SHA256;
|
||||
}
|
||||
else {
|
||||
TRI_V8_EXCEPTION_PARAMETER(scope, "invalid value for <algorithm>");
|
||||
}
|
||||
}
|
||||
|
||||
string result = SslInterface::sslHMAC(key.c_str(), key.size(), message.c_str(), message.size(), al);
|
||||
return scope.Close(v8::String::New(result.c_str(), (int) result.size()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the current http statistics
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3313,6 +3352,7 @@ void TRI_InitV8Utils (v8::Handle<v8::Context> context,
|
|||
TRI_AddGlobalFunctionVocbase(context, "SYS_GEN_RANDOM_NUMBERS", JS_RandomNumbers);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_GEN_RANDOM_SALT", JS_RandomSalt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_GETLINE", JS_Getline);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_HMAC", JS_HMAC);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_HTTP_STATISTICS", JS_HttpStatistics);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_KILL_EXTERNAL", JS_KillExternal);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_LOAD", JS_Load);
|
||||
|
|
Loading…
Reference in New Issue