Metroidvania camera lock?

So I have been searching around the internet and found some examples but none that really do what I need it to. I am trying to design a metroidvania and I need a system where the camera will not move beyond a certain point regardless of the player being up against a wall. They should not be able to see things outside the normal viewing area. \

Does anyone have suggestions on how to do this or has done this before? I tried a ton of things but the issues I ran into were either the camera returns to normal with an offset when the player walks away from walls or the camera leaves the player when they move up/down.

Sounds like you got a working idea but you didnt cover all the possible use cases.
Show your code.