根据文档,OpenGrok 的 REST API 在 localhost 上未经身份验证,但需要来自任何其他应用程序的身份验证。
在我的 K8S 设置中,我想将 OpenGrok(标准的opengrok/docker:1.7
)作为容器运行,但要自己进行源更新/签出,并在源更新后重新索引。我有一个opengrok
正在运行的容器和一个src-update
容器。他们共享 3 卷 ( /opengrok/src
, /opengrok/etc
, /opengrok/data
)。
opengrok
容器配置了一个值REST_TOKEN
和一个SYNC_PERIOD_MINUTES
值0
以禁用索引。src-update
容器运行并刷新代码库,然后运行以opengrok-indexer
重新索引数据并通知(通过-U
选项)opengrok
容器索引已更改。运行时,opengrok-indexer
它的索引正常,但在尝试将更新的配置放在 opengrok 服务器上时失败并出现 HTTP 401 错误:
2021-12-08 16:01:03.980+0000 SEVERE t1 Indexer.sendToConfigHost: Failed to send configuration to http://opengrok-service:8080 (is web application server running with opengrok deployed?)
java.io.IOException: InboundJaxrsResponse{context=ClientResponse{method=PUT, uri=http://opengrok-service:8080/api/v1/configuration?reindex=true, status=401, reason=Unauthorized}}
at org.opengrok.indexer.configuration.RuntimeEnvironment.writeConfiguration(RuntimeEnvironment.java:1462)
at org.opengrok.indexer.index.Indexer.sendToConfigHost(Indexer.java:1157)
at org.opengrok.indexer.index.Indexer.main(Indexer.java:383)
这是我在源更新容器上运行的命令。环境值OPENGROK_REST_TOKEN
与传递给 opengrok 容器的值相同REST_TOKEN
。
opengrok-indexer \
-J=-Djava.util.logging.config.file=/opt/opengrok/repo-mgmt/config/opengrok-logging.properties \
-a /opengrok/lib/opengrok.jar -- \
--progress -c /usr/local/bin/ctags \
-s /opengrok/src -d /opengrok/data -H -S -G \
--token $OPENGROK_REST_TOKEN \
-W /opengrok/etc/configuration.xml -U http://opengrok-service:8080
我查看/usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml
了 opengrok 容器上的文件,但没有看到任何安全配置。
我在配置中做错了什么或遗漏了什么?从源更新容器提供 REST API 所需的身份验证的最佳方式是什么?