Commit 870b799e authored by Matthieu Tanon's avatar Matthieu Tanon
Browse files

Improve sender authentication

parent 2cd6c2f7
......@@ -212,6 +212,7 @@ private:
ConferenceId conferenceId;
IdentityAddress fromAddress;
IdentityAddress authenticatedFromAddress;
bool senderAuthenticationEnabled = true;
IdentityAddress toAddress;
ChatMessage::State state = ChatMessage::State::Idle;
......
......@@ -510,12 +510,16 @@ LinphoneReason ChatMessagePrivate::receive () {
currentRecvStep |= ChatMessagePrivate::Step::Encryption;
}
// If LIMEv2 is enabled, it sets the authenticatedFromAddress as the decypted CPIM From Address
// If not it must be set here as the SIP From address
// If LIMEv2 is enabled, it sets the authenticatedFromAddress as the decrypted CPIM From Address
// If LIMEv2 is disabled, the authenticatedFromAddress must be set here as the SIP From Address
// In case of clear message in group chat room the sender authentication is disabled
if (!core->limeV2Enabled()) {
if (q->getSharedFromThis()->getChatRoom()->getCapabilities() & ChatRoom::Capabilities::Basic) {
IdentityAddress sipFromAddress = q->getSharedFromThis()->getFromAddress();
q->getSharedFromThis()->getPrivate()->setAuthenticatedFromAddress(sipFromAddress);
} else {
lInfo() << "Sender authentication disabled";
senderAuthenticationEnabled = false;
}
}
......
......@@ -169,14 +169,18 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptr<Ch
if (dateTimeHeader)
message->getPrivate()->setTime(dateTimeHeader->getTime());
if (cpimFromAddress.isValid() && (cpimFromAddress == message->getAuthenticatedFromAddress())) {
message->getPrivate()->forceFromAddress(cpimFromAddress);
lInfo() << "[CPIM] Sender authentication sucessful";
}
else {
lWarning() << "[CPIM] Sender authentication failed";
errorCode = 488;
return ChatMessageModifier::Result::Error;
if (message->getPrivate()->senderAuthenticationEnabled) {
if (cpimFromAddress.isValid() && (cpimFromAddress == message->getAuthenticatedFromAddress())) {
message->getPrivate()->forceFromAddress(cpimFromAddress);
lInfo() << "[CPIM] Sender authentication successful";
cout << "[CPIM] Sender authentication successful" << endl;
}
else {
lWarning() << "[CPIM] Sender authentication failed";
cout << "[CPIM] Sender authentication failed" << endl;
errorCode = 488;
return ChatMessageModifier::Result::Error;
}
}
auto messageIdHeader = cpimMessage->getMessageHeader("Message-ID"); // TODO: For compatibility, to remove
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment