'Ubadah bin As-Samit (May Allah be pleased with him) reported:
We swore allegiance to Messenger of Allah (ﷺ) to hear and obey; in time of difficulty and in prosperity, in hardship and in ease, to endure being discriminated against and not to dispute about rule with those in power, except in case of evident infidelity regarding which there is a proof from Allah. We swore allegiance to Messenger of Allah (ﷺ) to say what was right wherever we were, and not to fear from anyone's reproach.[Al-Bukhari and Muslim].
Arabic/English book reference: Book 1, Hadith 186