Skip to content

Commit

Permalink
Kerberos auth requires token in credentials field
Browse files Browse the repository at this point in the history
Deprecate `auth_tokens.keyTicket`, should be "credentials".
  • Loading branch information
robsdedude committed Sep 28, 2021
1 parent d670b9c commit 0e482e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions neo4j/auth_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const schemeKerberos = "kerberos"
const keyPrincipal = "principal"
const keyCredentials = "credentials"
const keyRealm = "realm"
const keyTicket = "ticket"
// Deprecated: will be removed in 5.0. Use keyCredentials instead.
const keyTicket = keyCredentials

// NoAuth generates an empty authentication token
func NoAuth() AuthToken {
Expand Down Expand Up @@ -62,7 +63,7 @@ func KerberosAuth(ticket string) AuthToken {
keyScheme: schemeKerberos,
// Backwards compatibility: Neo4j servers pre 4.4 require the presence of the principal.
keyPrincipal: "",
keyTicket: ticket,
keyCredentials: ticket,
},
}

Expand Down
10 changes: 7 additions & 3 deletions neo4j/auth_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,20 @@ func TestKerberosAuth(t *testing.T) {

token := KerberosAuth(ticket)

if len(token.tokens) != 2 {
if len(token.tokens) != 3 {
t.Errorf("should contain 2 keys")
}

if token.tokens[keyScheme] != schemeKerberos {
t.Errorf("the key scheme should be 'kerberos' %v", token.tokens[keyScheme])
}

if token.tokens[keyTicket] != ticket {
t.Errorf("the key ticket was not properly set %v", token.tokens[keyTicket])
if token.tokens[keyPrincipal] != "" {
t.Errorf("the key principal was not properly set %v", token.tokens[keyPrincipal])
}

if token.tokens[keyCredentials] != ticket {
t.Errorf("the key ticket was not properly set %v", token.tokens[keyCredentials])
}
}

Expand Down
2 changes: 1 addition & 1 deletion testkit-backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (b *backend) handleRequest(req map[string]interface{}) {
authTokenMap["credentials"].(string),
realmString)
case "kerberos":
authToken = neo4j.KerberosAuth(authTokenMap["ticket"].(string))
authToken = neo4j.KerberosAuth(authTokenMap["credentials"].(string))
default:
authToken = neo4j.CustomAuth(
authTokenMap["scheme"].(string),
Expand Down

0 comments on commit 0e482e5

Please sign in to comment.