Suwayd b. Ghaflah reports that ‘Umar b. Al-Khattāb – Allāh be pleased with him – once took him by the hand and said:

O Abū Umayah, by Allāh, I know not if we will meet again after today. Fear and obey Allāh your Lord until the Day of Resurrection, as if you see Him, and obey the ruler (imām) even if he is a cut-nosed Abyssinian slave: if he beats you, be patient; if he robs you, be patient and if he belittles you, be patient. And if he tells you [to do something] to the detriment of your religion (to sin), say: “I hear and obey, [but] my blood goes before my religion.” Never leave the Main Muslim Body (Al-Jamā’ah).

Ibn Zanjawayh, Kitāb Al-Amwāl article 30; Ibn Abī Zamanīn, Uṣūl Al-Sunnah article 205 with a slight variation in wording. Also recorded in other collections.