Most likely yes, it is legal. The separation of church and state means that the state can't tell the church what to do any more than the church can tell the state what to do. Churches and their affiliate organizations are allowed to require their employees to adhere to the requirements of that particular church.