无法通过HTTP API执行javascript命令

时间:2014-08-26 19:38:17

标签: javascript orientdb

我正在尝试通过HTTP API执行javascript命令,如下所示:

    curl -X POST -H "Content-Type:application/json" -H "Authorization:Basic 
    YWRtaW46aWRlYWw0ODI2" -H "Cache-Control:no-cache" -d '{ "transaction" : true, 
      "operations" : [ 
        {
          "type" : "script",
          "language" : "javascript",
          "script" : "orient.getGraph().createVertex('class:customer')"
        }
      ]
    }' http://localhost:2480/batch/mydb

响应如下:

com.orientechnologies.orient.core.exception.OSecurityException:不允许执行语言'javascript'

版本详细信息(http响应):
服务器→OrientDB服务器v.1.7.8(构建UNKNOWN @ r $ {buildNumber}; 2014-08-13 15:56:07 + 0200)

它出了什么问题!? 谢谢

1 个答案:

答案 0 :(得分:2)

这是出于安全原因。允许JS脚本打开config/orientdb-server-config.xml文件并更改OServerSideScriptInterpreter组件:

    <!-- SERVER SIDE SCRIPT INTERPRETER. WARNING! THIS CAN BE A SECURITY HOLE:
        ENABLE IT ONLY IF CLIENTS ARE TRUCT, TO TURN ON SET THE 'ENABLED' PARAMETER
        TO 'true' -->
    <handler
            class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter">
        <parameters>
            <parameter name="enabled" value="true"/>
            <parameter name="allowedLanguages" value="SQL,Javascript"/>
        </parameters>
    </handler>