A search for "electronic dog door" and/or "selective dog door" turns up several products ranging from $80 to $200 (though they are others that go up to $500), depending on size you need, for example:
There's lots of small selective cat doors, they do seem to get much more expensive as you go bigger.
As far as DIY, there are several ways to do this, and the complexity will really depend on exactly what you do, and how much experience you have doing electronics and embedded programming. An instructable on an RFID cat door may get you started.
Effectively, you just need to buy/build the actual door, which is capable of being locked by some mechanism (I would suggest not using one of the flexible flap ones).
Then you need a lock mechanism that can be controlled electronically, such as a solenoid, linear actuator, or servomotor.
Finally, you need the sensor and control circuitry. An Arduino is probably a good staring place for the controller. For the sensor, RFID has a lot of benefits, but as some of the off-the-shelf products show, you could also use infrared and/or magnetic sensors. I would think those would be more finicky to get working reliably, whereas RFID is pretty simple: just mount the antenna so it can pick up the tag attached to the dog's collar when close to the door.
Here's another instructable on interfacing RFID to the Ardunio. All that needs is an output hooked up to the lock mechanism you build, and the software to hold the lock open for a few seconds after detecting a valid RFID tag.
Note that the hardware to do this DIY isn't necessarily cheap, and in fact, probably approaches the $100-200 price tag on some of the off-the-shelf doors. Great learning experience but don't expect to save much cash DIY here.
I am not a contractor, and this is a real do it yourself type approach. This is provided at your own risk, and I assume no liability for damage.
The only thing I can think of that is going to auto reset in the way you've described is a device powered by gravity. Everything else ( anti-kick devices installed backwards, anti slam devices) either won't allow the door to close or need to be manually reset.
I picture a small piece of plate steel rather than wood, for durability, that has a hole bored in it, along the top edge, perhaps in the center, perhaps 1/4" - 1/2".
Through this hole pass a bolt whose body is less than the hole size, but whose head is too large to pass through (you'll likely end up with 1/16" or 1/8" clearance on the inside of the hole, which should be fine. You'd want to use a bolt that is threaded right to the head as opposed to those that are only partly threaded. You might need to scratch your head a little to get the bolt length right, but I'm thinking that a 5" bolt with 1" into the wall might be enough (remember that at the corner of the door the gap will be much more than 4").
You will also require a self locking nut for this bolt, some washers and some sort of threaded hole you can install into your door frame (there are hammer in threads available, just make sure you plan ahead size wise, some people would just hammer in a nut).
To support this contraption, I picture a wire back to the wall, but a firm brace like a piece of rod or wood could also be used. The brace should look like an upside down triangle when it's installed.
Drill a hole in the top of your door frame, within an easy reach of the door handle (you'll need to reach it to get out of the room), and install the threading. Make sure that you leave enough room for the plate to swing upside down and still clear the door.
Place the loop of wire/support rod on the bolt next to the head.
Place a washer on the bolt and pass it through the plate. Place a washer on the bolt (so that the washers are sandwiching the plate) and put the nut onto the bolt, so that the washers and plate are close, but not firm (if it's too firm, it's too hard to swing it out of your way).
If the door blows closed, the nut will prevent the plate from sliding back to the door frame and thus striking your pet.
When you want to open the door, you swing it open (the plate is between the door and the jam).
When you DON'T want the door to close, do nothing, (the plate's in the way) and gravity will reset the material.
When you DO want to close the door, swing the piece of material out of the way and close the door. When you want to get back out, you'll have to push the plate out of the way again, and leave, gravity resets.
Ok so that's really a lot of text, but it's a diy description ...
I personally think it's easier to use an anti-slam device and put it somewhere remarkably annoying so you can't forget it. Something like this, put over your sink faucet while you use the washroom. They come in really big foam finger style designs, that would probably help give your pet time to get out of the way or prevent some injury.
![The first anti slam I found on google images](https://i.stack.imgur.com/QG9mX.jpg)
Best Answer
It may seem too simple to work, but you just need to cut your own tailor-made cat door.
Basically, a cat can get through any opening it can fit its head through. This usually works against us cat owners, since the beasties have a mind of their own and like to explore. This time, it may work in our favor. So:
Hope this helps (the cat).