Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: Add HandshakeHandler to customize handling handshake #138

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

djshow832
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close None

Problem Summary:

The gateway needs to choose a namespace by username and rewrite handshake response.

What is changed and how it works:

  • BackendConnManager calls HandshakeHandler.GetNamespace() and HandshakeHandler.GetCapability()
  • Authenticator calls HandshakeHandler.HandleHandshakeResp() to rewrite handshake response
  • Parse attrs because the gateway will use it

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change (Don't forget to add the declarative for API)
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@@ -82,7 +83,7 @@ func (auth *Authenticator) writeProxyProtocol(clientIO, backendIO *pnet.PacketIO
}

func (auth *Authenticator) verifyBackendCaps(logger *zap.Logger, backendCapability pnet.Capability) error {
requiredBackendCaps := defRequiredBackendCaps
requiredBackendCaps := defRequiredBackendCaps & pnet.Capability(auth.capability)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We don't do the verification for client and server, I think...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyBackendCaps verifies that TiDB also has capability ClientDeprecateEOF. But if TiProxy doesn't enable ClientDeprecateEOF with the client, it shouldn't require ClientDeprecateEOF from the TiDB.

@xhebox xhebox merged commit b94d61b into pingcap:main Dec 1, 2022
@djshow832 djshow832 deleted the auth branch December 1, 2022 11:33
xhebox pushed a commit to xhebox/TiProxy that referenced this pull request Mar 7, 2023
xhebox pushed a commit to xhebox/TiProxy that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants