The Supreme Court in Cooper v. Pate, 378 U.S. 546 (1964), decided that the Bill of Rights applied inside prisons, and that, in this particular case, authorities had erred in denying religious publications and texts to an inmate.
https://www.mtsu.edu/first-amendment/article/532/cooper-v-pate