Skip to content

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

@KarthikSubbarao

Description

@KarthikSubbarao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions