In line with the Qur'anQur'an 33:53 ↗يَٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُواْ لَا تَدۡخُلُواْ بُيُوتَ ٱلنَّبِيِّ إِلَّآ أَن يُؤۡذَنَ لَكُمۡ إِلَىٰ طَعَامٍ غَيۡرَ نَٰظِرِينَ إِنَىٰهُ وَلَٰكِنۡ إِذَا دُعِيتُمۡ فَٱدۡخُلُواْ فَإِذَا طَعِمۡتُمۡ فَٱنتَشِرُواْ وَلَا مُسۡتَـٔۡنِسِينَ لِحَدِيثٍۚ إِنَّ ذَٰلِكُمۡ كَانَ يُؤۡذِي ٱلنَّبِيَّ فَيَسۡتَحۡيِۦ مِنكُمۡۖ وَٱللَّهُ لَا يَسۡتَحۡيِۦ مِنَ ٱلۡحَقِّۚ وَإِذَا سَأَلۡتُمُوهُنَّ مَتَٰعٗا فَسۡـَٔلُوهُنَّ مِن وَرَآءِ حِجَابٖۚ ذَٰلِكُمۡ أَطۡهَرُ لِقُلُوبِكُمۡ وَقُلُوبِهِنَّۚ وَمَا كَانَ لَكُمۡ أَن تُؤۡذُواْ رَسُولَ ٱللَّهِ وَلَآ أَن تَنكِحُوٓاْ أَزۡوَٰجَهُۥ مِنۢ بَعۡدِهِۦٓ أَبَدًاۚ إِنَّ ذَٰلِكُمۡ كَانَ عِندَ ٱللَّهِ عَظِيمًا
O you who believe! Do not enter the homes of the Prophet, unless you are given permission to come for a meal; and do not wait for its preparation. And when you are invited, go in. And when you have eaten, disperse, without lingering for conversation. This irritates the Prophet, and he shies away from you, but God does not shy away from the truth. And when you ask his wives for something, ask them from behind a screen; that is purer for your hearts and their hearts. You must never offend the Messenger of God, nor must you ever marry his wives after him, for that would be an enormity with God.
The verse tells believers to enter the messenger's houses only when permitted for a meal and to come in when invited, matching that the invitation itself is permission.
In line with the Qur'anQur'an 24:27 ↗يَٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُواْ لَا تَدۡخُلُواْ بُيُوتًا غَيۡرَ بُيُوتِكُمۡ حَتَّىٰ تَسۡتَأۡنِسُواْ وَتُسَلِّمُواْ عَلَىٰٓ أَهۡلِهَاۚ ذَٰلِكُمۡ خَيۡرٞ لَّكُمۡ لَعَلَّكُمۡ تَذَكَّرُونَ
O you who believe! Do not enter homes other than your own, until you have asked permission and greeted their occupants. That is better for you, that you may be aware.
The verse requires permission before entering houses, the rule the report says an invitation fulfils.