What you describe is the core functionality of the PSTN Line half of the
SPA-3000 ATA. It is typically implemented so that you call in to the FWD number, are prompted to enter a PIN, and then are given a PIN which is coupled with a Dial Plan which controls what numbers you are permitted to dial out to. Calling in the opposite direction is likewise configured.