I suppose the specific implementation of this depends on your implementation / requirements.
Certainly you could go the full DIY route, using an ESP8266 or arduino board and a waterproof number pad (+/- a rfid sensor) in a project box. If you code the arduino correctly, it could be secure-ish, but you’d also be putting out a breadcrumb train for anyone to get in. There are lots devices that have all the magic locked into a proprietary black box, and leave you to program codes locally on the keypad - more secure from that side, and no potential entry point into your network, but no connection into openhab and the maglock/opening leads could be tampered with.
Depending on where you are (what zwave frequency), a product like this https://www.zipato.com/product/mini-keypad-rfid
may be helpful. That one has been used in home assistant, I believe, but you may need to create/configure a zwave device.
If you want reasonably secured, with a polished app, and an openhab binding at least partially in place, and have money to spare, then look into the Doorbird systems and Doorbird video doorbell binding
An out-of-the-box solution could be to use a z-wave deadbolt (Schlage connect, Yale, etc) that is already working with Openhab. Install it without any actual deadbolt used (just ensure the battery ‘inside’ component is in a waterproofed box/location). You can then use habmin to set the user codes, and use 5iver’s rules to interpret which code number was used to unlock the device. I’m thinking of using this route - if user code #9 was used (whatever I set that to), a specific action would be triggered. within openhab. You’d have the lock work to open an imaginary deadbolt, though, and would need to change the battery more often than you’d otherwise need to for a keypad. The bonus is a relatively polished product, waterproof, and Zwave security, with the only significant vulnerability being your openhab system itself.
In the end, for a gate controller I would probably use something like the below keypad, and try to physically protect my controller (likely Wemos D1Mini Pro with external antenna) from tampering.