Swap order of trust and challenge in AuthProtocolResponseHandler
This will ensure that if challenge-authorization is enabled and
configured it will be used instead of trust.
@@ -383,63 +383,64 @@ impl Handler for AuthProtocolResponseHandler {
}
}
_ => {
- #[cfg(feature = "challenge-authorization")]
+ #[cfg(feature = "trust-authorization")]
if protocol_request
.accepted_authorization_type
.iter()
- .any(|t| matches!(t, PeerAuthorizationType::Challenge))
+ .any(|t| matches!(t, PeerAuthorizationType::Trust))
{
- let nonce_request = AuthorizationMessage::AuthChallengeNonceRequest(
- AuthChallengeNonceRequest,
- );
+ let trust_request =
+ AuthorizationMessage::AuthTrustRequest(AuthTrustRequest {
+ identity: self.identity.clone(),
+ });
- let action = AuthorizationLocalAction::Challenge(
- ChallengeAuthorizationLocalAction::SendAuthChallengeNonceRequest,
- );
if self
.auth_manager
- .next_local_state(context.source_connection_id(), action)
+ .next_local_state(
+ context.source_connection_id(),
+ AuthorizationLocalAction::Trust(
+ TrustAuthorizationLocalAction::SendAuthTrustRequest,
+ ),
+ )
.is_err()
{
error!(
"Unable to transition from ReceivedAuthProtocolResponse to \
- WaitingForAuthChallengeNonceResponse"
+ WaitingForAuthTrustResponse"
)
};
msg_bytes = IntoBytes::<network::NetworkMessage>::into_bytes(
- NetworkMessage::from(nonce_request),
+ NetworkMessage::from(trust_request),
)?;
}
- #[cfg(feature = "trust-authorization")]
+
+ #[cfg(feature = "challenge-authorization")]
if protocol_request
.accepted_authorization_type
.iter()
- .any(|t| matches!(t, PeerAuthorizationType::Trust))
+ .any(|t| matches!(t, PeerAuthorizationType::Challenge))
{
- let trust_request =
- AuthorizationMessage::AuthTrustRequest(AuthTrustRequest {
- identity: self.identity.clone(),
- });
+ let nonce_request = AuthorizationMessage::AuthChallengeNonceRequest(
+ AuthChallengeNonceRequest,
+ );
+ let action = AuthorizationLocalAction::Challenge(
+ ChallengeAuthorizationLocalAction::SendAuthChallengeNonceRequest,
+ );
if self
.auth_manager
- .next_local_state(
- context.source_connection_id(),
- AuthorizationLocalAction::Trust(
- TrustAuthorizationLocalAction::SendAuthTrustRequest,
- ),
- )
+ .next_local_state(context.source_connection_id(), action)
.is_err()
{
error!(
"Unable to transition from ReceivedAuthProtocolResponse to \
- WaitingForAuthTrustResponse"
+ WaitingForAuthChallengeNonceResponse"
)
};
msg_bytes = IntoBytes::<network::NetworkMessage>::into_bytes(
- NetworkMessage::from(trust_request),
+ NetworkMessage::from(nonce_request),
)?;
}
