What is required for the validity of voluntary prayer inside or on the Kaaba regarding facing a structure?

Chapter on Praying with Impurity and Other Matters

Al-Mughni

Book of Prayer

Book 3 · Issue 3 · Bab 8

Open in Qurani

Primary text

The established opinion is that requiring a structure to be in front of the worshipper is not stipulated, because the obligation is to face its location and its space, not necessarily its walls. The evidence for this is that if the Kaaba were destroyed, the prayer would still be valid facing its former location. Similarly, if one prays on a high mountain far from its perpendicular alignment, the prayer is valid facing its space, and the same applies here regarding the Kaaba's interior space.