I was wondering how best to shield ships and bases from CMEs (especially bases, since they are harder to orientate to the sun), so did some testing.
The first thing, is that it appears a raycast is done from the center of the habitat to the sun, and anything intersected counts as shielding: this means that a single surface mounted small battery can shield the habitat if it happens to be on that line between the sun and the center of the habitat.
The next thing: is that it seems putting anything in between the sun and the habitat module reduces radiation by a lot: a flag reduced radiation by about 74%, a solar panel reduced radiation by about 91%, a structural panel reduced radiation by 95%, a Cargo Bay reduced radiation by 99.4%.
Shielding layers stack well. Putting TWO flags between the habitat and the sun, reduced radiation by 86%, two solar panels reduced radiation by 99%.
I tested "standoff", whether moving the shielding object further from the ship improves shielding. It does, but by very very little. For example in a particular solar storm, a flag on the surface of the habitat reduced radiation to 0.444 rad/h, the same flag at the maximum extension of a 1P4 telescoping cylinder, reduced radiation to 0.441 rad/h. So there is an effect, but it's absolutely negligible.
The surface attached part can be inside the habitat, that is fine. However if the raycast starts INSIDE a part, that part does not contribute to shielding: embedding a habitat inside a larger part such as a fuel tank does not help. However if the larger part has internal walls such as a structural tube or a service bay then it does work, the principle is probably that the raycast has to hit a wall you can't see through: essentially if you can see the sun, the sun's radiation can see you. Also it doesn't appear to check other vehicles, a Kerbal on EVA can't shelter in the shadow of a ship.
The upshot: higher density objects are more effective for radiation shielding, but they don't need to be very high density, solar panels work well, flags are a bit flimsy but significantly better than nothing. Stacking layers of shielding is probably far more effective than heavier shielding. Enclosing the habitat inside an object with inner walls like a cargo bay is useful. Standoff doesn't literally do nothing but is practically worthless.
A habitat in a base can be shielded simply by blanketing it in surface attached parts or placing it inside a cargo bay or service bay. If you don't want to know exploits don't read this next part:
This is the measured in-game behaviour. It might not be the intended behaviour.
RTGs:
They produce essentially no radiation. Technically they do, but a Kerbal has to snuggle up against one to get an increased dose. They do nothing like 1m away. Don't clip one to the center of a habitat, don't put one on the wall of a very small habitat. Otherwise they do nothing and no shielding strategy is required. I don't have a fission reactor mod installed atm to test them.
LV-N "Nerv":
They produce even less radiation than an RTG which is saying something, and also produce no additional radiation when firing. A Kerbal on EVA has to snuggle up against one to get even half the dose of an RTG. Don't attach one directly to the bottom of an Mk1 lander can or something like that and otherwise they are irrelevant. I don't have any nuclear engine mod installed atm.