有没有办法将用户映射到Gremlin服务器中的各个图形?
我正在Gremlin服务器中设置到OrientDB数据库的多个图形映射。但是,我找不到在Groovy中编写什么脚本以及在配置yaml文件中配置什么,以便能够将每个经过身份验证的用户映射到单个图形,而不是让所有经过身份验证的用户都能够访问所有内容。有什么方法可以实现这一点吗?Gremlin服务器不提供任何仅用于授权的身份验证功能。您必须自己构建一些东西来处理将用户限制到不同图形(或其他约束)的问题。这意味着要建立两个东西:有没有办法将用户映射到Gremlin服务器中的各个图形?,gremlin,tinkerpop,Gremlin,Tinkerpop,我正在Gremlin服务器中设置到OrientDB数据库的多个图形映射。但是,我找不到在Groovy中编写什么脚本以及在配置yaml文件中配置什么,以便能够将每个经过身份验证的用户映射到单个图形,而不是让所有经过身份验证的用户都能够访问所有内容。有什么方法可以实现这一点吗?Gremlin服务器不提供任何仅用于授权的身份验证功能。您必须自己构建一些东西来处理将用户限制到不同图形(或其他约束)的问题。这意味着要建立两个东西: 处理授权的自定义ChannelInboundHandlerAdapter,
ChannelInboundHandlerAdapter
,可能称为AuthorizationHandler
Channelizer
实现将自定义授权器连接到管道-可能称为authorizationchannelizer
AuthorizationHandler
基本上只会覆盖Netty的channelRead()
方法
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof RequestMessage){
RequestMessage requestMessage = (RequestMessage) msg;
// examine contents of RequestMessage to see what is being requested
// e.g. the graph - the user information will be there too but
// depending on the authentication method you're using you might need
// to re-decode it at this time as it doesn't appear that the authenticated
// user is placed on the ChannelHandlerContext for some reason. i made
// a note to change that as it seems helpful and is a simple enough thing
// to do
}
}
对于authorizationchannelizer
您基本上可以扩展WebSocketChannelizer
并覆盖configure()
方法:
@Override
public void configure(ChannelPipeline pipeline) {
super.configure(pipeline);
// add an instance of your `AuthorizingChannelizer` to the end of the
// netty pipeline which will put it after the `AuthenticationHandler`
// but before all the Gremlin processing/execution
pipeline.addLast("authorizier", authorizingChannelizer);
}
然后,在您的Gremlin服务器配置中,用您的AuthorizationChannelizer
的完全限定名称替换channelizer
设置。假设您已经将包含该类的jar放置在Gremlin服务器的路径中,它应该在启动时创建该类的实例
我将查看现有的“”和“”代码,以获得更多关于如何实现这一点的灵感