At the moment, the best answer is that we don't know. What we *do* know is -- I hope correctly** -- summarised below:
1. Part of the Withdrawal Agreement (WA) that has currently been rejected relates to mutual rights of EU and UK citizens, and would ensure the continuity of such rights through a transition period. So if the WA is agreed on after all, in perhaps a modified form, then in the short term everything will be as it was before until full separation.
2. Absent the WA, the EU has argued that they can't form a deal exclusively on Citizens' rights, as it would be too coupled to other issues. So they have left it to individual member states whilst encouraging/urging all members to be generous and pragmatic.
3. Therefore it seems to depend on *where* in the EU you are claiming benefits:
4. If you are in Spain, France, Sweden, or Ireland, then it seems that plans are already in place to ensure that nothing changes for a period of around a year after Brexit. Many other countries are following suit.
5. Most of the time this appears to be conditional on having worked in the relevant country, but I suppose the point is that this would be as it was before, ie if you weren't entitled to a given Social Security benefit before Brexit, then you wouldn't be entitled to it afterwards.
6. In a few countries, eg Poland and the Czech Republic, the guarantee of continued rights may also be conditional on the UK returning the favour. Since the UK is also making moves to guarantee the right of EU citizens currently resident in the UK, it seems likely that in those countries too rights will be preserved for a year beyond Brexit.
7. In conclusion, it's important to look on official pages of the representative government of the country you live in, and keep checking for updates over the next few months.
**NB: Some of this information may be out-of-date, but hopefully that would only mean that events have moved in the right direction.