You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2018-10-23 20:43:00 73074 [main] [ERROR] com.baidu.hugegraph.dist.HugeGraphServer [] - HugeGraphServer error:
java.lang.ClassCastException: com.baidu.hugegraph.auth.HugeGraphAuthProxy cannot be cast to com.baidu.hugegraph.HugeGraph
at com.baidu.hugegraph.core.GraphManager.checkBackendVersionOrExit(GraphManager.java:172) ~[classes/:?]
at com.baidu.hugegraph.core.GraphManager.<init>(GraphManager.java:67) ~[classes/:?]
at com.baidu.hugegraph.server.ApplicationConfig$GraphManagerFactory$1.onEvent(ApplicationConfig.java:102) ~[classes/:?]
at org.glassfish.jersey.server.internal.monitoring.CompositeApplicationEventListener.onEvent(CompositeApplicationEventListener.java:74) ~[jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.internal.monitoring.MonitoringContainerListener.onStartup(MonitoringContainerListener.java:81) ~[jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.onStartup(ApplicationHandler.java:1180) ~[jersey-server-2.25.1.jar:?]
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.start(GrizzlyHttpContainer.java:357) ~[jersey-container-grizzly2-http-2.25.1.jar:?]
at org.glassfish.grizzly.http.server.HttpHandlerChain.start(HttpHandlerChain.java:422) ~[grizzly-http-server-2.3.28.jar:2.3.28]
at org.glassfish.grizzly.http.server.HttpServer.setupHttpHandler(HttpServer.java:314) ~[grizzly-http-server-2.3.28.jar:2.3.28]
at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:290) ~[grizzly-http-server-2.3.28.jar:2.3.28]
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:296) ~[jersey-container-grizzly2-http-2.25.1.jar:?]
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:119) ~[jersey-container-grizzly2-http-2.25.1.jar:?]
at com.baidu.hugegraph.server.RestServer.start(RestServer.java:59) ~[classes/:?]
at com.baidu.hugegraph.server.RestServer.start(RestServer.java:76) ~[classes/:?]
at com.baidu.hugegraph.dist.HugeRestServer.start(HugeRestServer.java:54) ~[classes/:?]
at com.baidu.hugegraph.dist.HugeGraphServer.main(HugeGraphServer.java:58) [classes/:?]
INFO: [HttpServer] Started.
Oct 24, 2018 4:21:48 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [127.0.0.1:8080]
Oct 24, 2018 4:21:48 PM org.glassfish.jersey.internal.Errors logErrors
WARNING: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 1
java.lang.IllegalStateException: Please wait for the server to initialize
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at com.baidu.hugegraph.util.E.checkState(E.java:68)
at com.baidu.hugegraph.server.ApplicationConfig$GraphManagerFactory.provide(ApplicationConfig.java:120)
at com.baidu.hugegraph.server.ApplicationConfig$GraphManagerFactory.provide(ApplicationConfig.java:90)
at org.jvnet.hk2.internal.FactoryCreator.create(FactoryCreator.java:153)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:162)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2022)
at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:774)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getUnqualifiedService(ServiceLocatorImpl.java:786)
at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:111)
at com.baidu.hugegraph.api.filter.AuthenticationFilter.authenticate(AuthenticationFilter.java:62)
at com.baidu.hugegraph.api.filter.AuthenticationFilter.filter(AuthenticationFilter.java:56)
at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:132)
at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:68)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:318)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:224)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
at java.lang.Thread.run(Thread.java:748)
Oct 24, 2018 4:21:49 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
* About to connect() to 192.168.0.140 port 8181 (#0)
* Trying 192.168.0.140...
* Connected to 192.168.0.140 (192.168.0.140) port 8181 (#0)
* Server auth using Basic with user 'admin'
> GET /graphs/hugegraph HTTP/1.1
> Authorization: Basic YWRtaW46MTYyZjc4NDgtMGI2ZC00ZmFmLWI1NTctM2EwNzk3ODY5YzU1
> User-Agent: curl/7.29.0
> Host: 192.168.0.140:8181
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Incorrect username or password
< Content-Type: application/json
< Date: Wed, 28 Oct 2020 03:19:39 GMT
< Content-Length: 118
<
* Connection #0 to host 192.168.0.140 left intact
{"exception":"class javax.ws.rs.NotAuthorizedException","message":"Authentication failed for user 'admin'","cause":""}
Activity
javeme commentedon Oct 23, 2018
日志中是否有打印如下信息:
fisherinbox commentedon Oct 23, 2018
@javeme 日志中没有出现error,上述图片就是全部的 logs/hugegraph-server.log的内容,请问authentication部分配置有没有详细一点的说明,如何使用,有什么用处
javeme commentedon Oct 23, 2018
@fisherinbox 启动超时实际是否可以访问呢?从截图中来看server似乎起来了。能否清空一下日志复现一下?
authentication是用于权限认证:config-authentication,另附更多配置项文档。
fisherinbox commentedon Oct 24, 2018
@javeme 这个贴的日志截图就是清空了之后再启动的日志,服务进程是起来了,用restful api查询的时候返回
{"exception":"class javax.ws.rs.NotAuthorizedException","message":"HTTP 401 Unauthorized","cause":""}fisherinbox commentedon Oct 24, 2018
@javeme 我再补一个今天的完整的日志
fisherinbox commentedon Oct 24, 2018
@javeme 我有几点疑问
这个配置项是不是要在第一次init图之前就要配置才行,像我这种后期再打开的是不是不行
这个权限配置项是针对restful查询吗,而且只针对restful查询吗,我看到https://hugegraph.github.io/hugegraph-doc/clients/restful-api/graph.html 这里面说查看图的配置需要管理员权限,是类似这种使用方式吗,这里只用了管理员权限,那user_tokens那一项,针对某一个用户,是怎么使用呢?
auth.admin_token和auth.user_tokens是否可以自己随意改写,auth.user_tokens是否可以配置多个用户
alegjk commentedon Oct 24, 2018
@javeme @fisherinbox 我这里也是配置了authentication相关参数后,在服务器上启动超时, 查看日志有异常, 异常了服务器还给拉起来了(另外, 代码调试环境配置了authentication相关参数启动是正常的), 日志如下:
javeme commentedon Oct 25, 2018
@fisherinbox 看完整日志确实是启动成功了,返回401是因为没有认证通过。
如果启用了authentication,那么需要通过用户信息来登录,java client代码如下:
new HugeClient(url, graph, username, password)针对上述疑问解答:
没有这个限制的,可以后期再开启authentication
既可以对rest查询,也可以对gremlin查询
是的,管理员权限就是基于authentication机制的。auth.admin_token和auth.user_tokens可以随意改写(事实上应该修改),登录时请使用修改后的用户信息。
默认的权限管理实现(StandardAuthenticator):auth.user_tokens允许每个图配置一个用户(用户名称与图名称必须相同),如果需要更佳丰富的用户管理功能、或者需要集成第三方或自定义的用户管理系统,可自己实现接口并修改相关配置指向该实现。
javeme commentedon Oct 25, 2018
@hklmuaqmn 日志中的异常只是WARNING(服务没有启动完成时收到了请求),这个异常不影响服务的正常使用。服务启动超时事实上可能成功了,当然对于这个启动脚本的超时检测可能还需要改进。
fisherinbox commentedon Oct 25, 2018
@javeme 感谢解答,还有一个问题是用restful和gremlin来查询时如何加上username和password
javeme commentedon Oct 25, 2018
@fisherinbox hugegraph使用的是Http Basic Authorization,可参考:https://zh.wikipedia.org/wiki/HTTP%E5%9F%BA%E6%9C%AC%E8%AE%A4%E8%AF%81
alegjk commentedon Oct 30, 2018
@javeme 没有疑问了, 确实超时了也可以访问, 这个机制看下能否再审视下,超时体验不太友好,我本地搭了源码环境, 也准备拜读下hugegraph的源码, 多交流
dyhyao6 commentedon Oct 28, 2020
看我的配置,为啥admin 用户认证失败了呢? @fisherinbox @javeme

* About to connect() to 192.168.0.140 port 8181 (#0) * Trying 192.168.0.140... * Connected to 192.168.0.140 (192.168.0.140) port 8181 (#0) * Server auth using Basic with user 'admin' > GET /graphs/hugegraph HTTP/1.1 > Authorization: Basic YWRtaW46MTYyZjc4NDgtMGI2ZC00ZmFmLWI1NTctM2EwNzk3ODY5YzU1 > User-Agent: curl/7.29.0 > Host: 192.168.0.140:8181 > Accept: */* > < HTTP/1.1 401 Unauthorized < WWW-Authenticate: Incorrect username or password < Content-Type: application/json < Date: Wed, 28 Oct 2020 03:19:39 GMT < Content-Length: 118 < * Connection #0 to host 192.168.0.140 left intact {"exception":"class javax.ws.rs.NotAuthorizedException","message":"Authentication failed for user 'admin'","cause":""}javeme commentedon Oct 28, 2020
从0.11开始,使用数据库后端来存储用户名密码的方式,来替代原来通过配置文件指定用户名Token的方式,原来
StandardAuthenticator被重命名为ConfigAuthenticator了,新的StandardAuthenticator是指数据库的方式。那么,原来的配置项
auth.admin_token和auth.user_tokens仅在auth.authenticator=com.baidu.hugegraph.auth.ConfigAuthenticator时才有效果。@dyhyao6 如果你在0.11版以上,配置了
auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator,那么用户名密码是存储在数据库中的,admin密码是在数据库初始化时输入的,其他用户由admin动态创建。所以传递admintoken作为密码是错误的。dyhyao6 commentedon Oct 28, 2020
是的,改为auth.authenticator=com.baidu.hugegraph.auth.ConfigAuthenticator就能正确的认证

dyhyao6 commentedon Oct 28, 2020
如果这样配置,auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator。是不是得重新初始化数据库,以及清空数据库里的数据呢 @javeme
github-actions commentedon Jan 23, 2022
Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label
fix: add style files back (#125)