[
https://issues.apache.org/jira/browse/TINKERPOP3-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14936568#comment-14936568
]
Dylan Millikin commented on TINKERPOP3-855:
-------------------------------------------
Ok I'm done with this and I've got a PR ready. It will however need tweaks
because :
Your test does indeed fail (with or without my changes). The gist of the issue
here with your test is that GraphSON will convert the {{byte[]}} to Base64 and
it fails the test in two ways:
- Without the fix for this issue it will throw the same error ({{can't cast
String to [B}})
- With the fix another error occurs because the Base64 string doesn't follow
the NUL separated specs. (thus failing to populate user and password)
Seeing as this feature doesn't currently work anyways, I think we have full
reign on how to implement it. Converting byte[] to a Base64 string isn't
unpleasant in itself and drivers should be able to implement this.
My suggestion would be to change the documentation and the feature to work in
these two scenarios:
- ARGS_SASL is of type {{byte[]}} and we treat it normally (ensures the feature
is BC)
- ARGS_SASL is of type {{String}} and it must be a Base64 encoded string of a
{byte[]}
This however implies that the data be passed differently depending on the
serializer being used... Which in itself isn't ideal.
The only other option I can think of to homogenize the feature would be to
remove the expectancy on a byte[] typed variable, but that would be a BC
breaking change so alas no.
This is an easy implementation so I'm going ahead with this change, if you have
any counter indications or we decide not to go with it I can easily revert back.
> sasl authentication type error due to Json format
> -------------------------------------------------
>
> Key: TINKERPOP3-855
> URL: https://issues.apache.org/jira/browse/TINKERPOP3-855
> Project: TinkerPop 3
> Issue Type: Bug
> Components: server
> Affects Versions: 3.0.1-incubating
> Reporter: Dylan Millikin
> Assignee: stephen mallette
> Fix For: 3.1.0-incubating, 3.0.2-incubating
>
>
> The documentation states :
> {quote}The password should be an encoded sequence of UTF-8 bytes{quote}
> Thus the {{SaslAuthenticationHandler}} expects to receive a {{byte[]}} type
> var.
>
> However, using gremlin-server with {{GraphSonMessageSerializer}}, if I send
> the payload with the sasl argument (say {{\x00stephen\x00password}}) in
> response to a gremlin-server {{407}} authentication challenge, I will get the
> following error:
> {code}
> java.lang.ClassCastException: java.lang.String cannot be cast to [B
> at
> org.apache.tinkerpop.gremlin.server.handler.SaslAuthenticationHandler.channelRead(SaslAuthenticationHandler.java:74)
> {code}
> This seems "normal" in that Json does not support any binary dataType and the
> sasl argument will automatically be converted to {{String}}.
> I quickly tested a correction locally by changing [this
> line|https://github.com/apache/incubator-tinkerpop/blob/tp30/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/SaslAuthenticationHandler.java#L74]
> to :
> {code}
> final String saslString = (String)
> requestMessage.getArgs().get(Tokens.ARGS_SASL);
> final byte[] saslResponse =
> saslString.getBytes(Charset.forName("UTF-8"));{code}
> This is clearly a breaking change, but it solved the Json issue.
> If you have any ideas on the way you want to go with this (or If I'm totally
> doing something wrong) let me know. I could probably make a PR for this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)