pub trait AuthenticationContextBuilder<Context> {
// Required method
fn build_from_remoting(
&self,
request: &RemotingCommand,
channel_id: Option<&str>,
) -> AuthServiceResult<Context>;
}Expand description
Authentication context builder trait.
This trait defines the interface for building authentication contexts from different request sources. Implementations should extract authentication credentials (AccessKey, Signature, etc.) from the request and construct an appropriate authentication context.
§Type Parameters
Context- The type of authentication context to build
§Examples
ⓘ
use rocketmq_auth::AuthenticationContextBuilder;
let builder = DefaultAuthenticationContextBuilder::new();
let context = builder.build_from_remoting(channel_context, &request)?;Required Methods§
Sourcefn build_from_remoting(
&self,
request: &RemotingCommand,
channel_id: Option<&str>,
) -> AuthServiceResult<Context>
fn build_from_remoting( &self, request: &RemotingCommand, channel_id: Option<&str>, ) -> AuthServiceResult<Context>
Build an authentication context from a Remoting command.
Extracts authentication information from RemotingCommand extFields including:
- AccessKey field
- Signature field
- All other fields (combined as signed content)
§Arguments
channel_context- The channel handler context (provides channel ID)request- The remoting command request
§Returns
Ok(Context)- Successfully built authentication contextErr(AuthServiceError)- Failed to extract authentication data
§Security Notes
- Filters out UNIQUE_MSG_QUERY_FLAG for versions <= 4.9.3
- Excludes Signature field from signed content
- Sorts fields for consistent signature verification
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".