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

Add username to on_init #31

Conversation

burgalon
Copy link

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

See #30
Currently the shim.authenticate does not pass a &mut self and so it is not possible to save the username for later use - i.e: initialization of upstream

Also the on_init does not pass username or the entire handshake but rather just the db.
Can we add the username to the on_init ?

@PsiACE PsiACE requested review from TCeason and sundy-li August 29, 2022 02:31
@TCeason
Copy link
Contributor

TCeason commented Aug 29, 2022

Yes, we can add a username on init.

But now we need database_name because of we will init_db in there.

The user name in shim.authenticate acctually will store in there.

So I think If use it as a base library, that's might be better off doing these things in own program.

BTW: what initialization of upstream this means? Is it convenient to explain a little bit?

@burgalon
Copy link
Author

let's suppose we're doing a pass-through proxy for mysql, and we need to initialize an upstream mysql client with the same user that we were called with - in this case we need to initialize the self.upstream_client = Mysql(...) with the same username that we were connected to with.

@burgalon burgalon force-pushed the authentication-pass-username branch from 14310a7 to e3783db Compare August 29, 2022 06:44
@burgalon
Copy link
Author

indeed it seems like the missing db is an issue

@sundy-li
Copy link
Member

Currently the shim.authenticate does not pass a &mut self and so it is not possible to save the username for later use - i.e: initialization of upstream

I don't think so. You can use interior-mutability to modify self.

@sundy-li
Copy link
Member

Also the on_init does not pass username or the entire handshake but rather just the db

on_init will be called only if the auth handshake is finished as ok. I think the user can be saved in your own struct rather than exporting this as an extra arg.

@sundy-li sundy-li closed this Mar 3, 2023
@sundy-li
Copy link
Member

sundy-li commented Mar 3, 2023

Closing seems it's not needed. Feel free to open it if it's not solved, thanks!

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.

3 participants