@@ -17,10 +17,12 @@ package proxycore
17
17
import (
18
18
"bytes"
19
19
"fmt"
20
+
21
+ "go.uber.org/zap"
20
22
)
21
23
22
24
type Authenticator interface {
23
- InitialResponse (authenticator string ) ([]byte , error )
25
+ InitialResponse (authenticator string , c * ClientConn ) ([]byte , error )
24
26
EvaluateChallenge (token []byte ) ([]byte , error )
25
27
Success (token []byte ) error
26
28
}
@@ -31,14 +33,21 @@ type passwordAuth struct {
31
33
password string
32
34
}
33
35
34
- func (d * passwordAuth ) InitialResponse (authenticator string ) ([]byte , error ) {
35
- switch authenticator {
36
- case "com.datastax.bdp.cassandra.auth.DseAuthenticator" :
36
+ const dseAuthenticator = "com.datastax.bdp.cassandra.auth.DseAuthenticator"
37
+ const passwordAuthenticator = "org.apache.cassandra.auth.PasswordAuthenticator"
38
+ const astraAuthenticator = "org.apache.cassandra.auth.AstraAuthenticator"
39
+
40
+ func (d * passwordAuth ) InitialResponse (authenticator string , c * ClientConn ) ([]byte , error ) {
41
+ if authenticator == dseAuthenticator {
37
42
return []byte ("PLAIN" ), nil
38
- case "org.apache.cassandra.auth.PasswordAuthenticator" :
39
- return d .makeToken (), nil
40
43
}
41
- return nil , fmt .Errorf ("unknown authenticator: %v" , authenticator )
44
+ // We'll return a SASL response but if we're seeing an authenticator we're unfamiliar with at least log
45
+ // that information here
46
+ if (authenticator != passwordAuthenticator ) && (authenticator != astraAuthenticator ) {
47
+ c .logger .Info ("observed unknown authenticator, treating as SASL" ,
48
+ zap .String ("authenticator" , authenticator ))
49
+ }
50
+ return d .makeToken (), nil
42
51
}
43
52
44
53
func (d * passwordAuth ) EvaluateChallenge (token []byte ) ([]byte , error ) {
0 commit comments