something like this
Suppose you put a bolt through it, with a couple of washers under the head to reduce wear and friction, then a couple more on the other side, then pushed the bolt through a hole drilled in the side of the leg, then a couple more washers, then a nut.
that's the basic idea.
It can be improved with a bit of tube as a bearing, and additional nuts and washers to clamp it firmly to the leg to prevent the wood wearing.
DIY sheds sell that sort of thing
edit
yes, studding is cheaper than long bolts, and you cut it to whatever length you want. Put a nut on each side of the mark before you cut it, so that winding the nut off will clean away burrs or damage to the thread from your saw.
Suppose you put a bolt through it, with a couple of washers under the head to reduce wear and friction, then a couple more on the other side, then pushed the bolt through a hole drilled in the side of the leg, then a couple more washers, then a nut.
that's the basic idea.
It can be improved with a bit of tube as a bearing, and additional nuts and washers to clamp it firmly to the leg to prevent the wood wearing.
DIY sheds sell that sort of thing
edit
yes, studding is cheaper than long bolts, and you cut it to whatever length you want. Put a nut on each side of the mark before you cut it, so that winding the nut off will clean away burrs or damage to the thread from your saw.