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

Create Interface for Modules to Register a Custom Auth Module Callback #179

Open
KarthikSubbarao opened this issue Feb 21, 2025 · 0 comments

Comments

@KarthikSubbarao
Copy link
Member

KarthikSubbarao commented Feb 21, 2025

Create Interface for Modules to Register a Custom Auth Module Callback.

In Valkey (even on 7.2), we have the ability to register custom authentication callbacks from Modules using the ValkeyModule_RegisterAuthCallback Module API.

https://valkey.io/topics/modules-api-ref/#ValkeyModule_RegisterAuthCallback

For Rust Modules, we can abstract away a lot of interactions by implementing a macro that allows both blocking and non blocking authentication implementations in the module.

High level valkeymodule-rs Interface updates:

  • Have a single new macro (valkey_module_auth!) to allow registering authentication callbacks. This macro should also be embedded inside the valkey_module! macro such that it can be optionally used by Valkey Rust Modules.
  • valkey_module_auth! should accept both a callback argument (the function signature should be safe for Rust Modules to implement, ie - no unsafe operations) and should allow modules to implement both blocking and non blocking callbacks.
  • Extend the BlockedClient interface in blocked.rs to allow a new mode of blocking clients - block on authentication by using the ValkeyModule_BlockClientOnAuth
  • Extend the BlockedClient interface in blocked.rs to allow setting and getting private info. This would be used in blocking authentication to store the result of the authentication and use it when the client is unblocked.

See the C Module example of this here: https://github.com/valkey-io/valkey/blob/unstable/tests/modules/auth.c#L83-#L221

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

No branches or pull requests

1 participant