FIFA Laws of the Game, excerpt:
The goalkeeper is considered to be in control of the ball by touching it with any part of his hands or arms. Possession of the ball... does not include the circumstances where, in the opinion of the referee, the ball rebounds accidentally from the goalkeeper...
The following observations and recommendations are the opinions of Incline AYSO Soccer (Region 995) and are not necessarily totally compliant with FIFA, but are intended to "protect the goalkeeper against dangerous play".
Goalkeeper has control of the ball:
The goalkeeper is generally, particularly in the scope of AYSO, considered to "control and have possession" of the ball in the following situations while in his/her own penalty area:
The ball is clearly being held in one or both hands
The ball is being pinned against the ground with any part of the hand or arm, in the limiting case with as little as one finger
In AYSO, and particularly in the younger U6, U8 and U10 divisions, it would be in the spirit of AYSO rules and regulations to say that... if the ball is being juggled to the ground by the goalkeeper, the goalkeeper should be given the benefit of the doubt that he/she will imminently and ultimately control the ball. During this delicate transition, referees should be quick to "protect the goalkeeper from dangerous play".
When in control/possession of the ball, the goalkeeper has very special protection:
no other player may kick at the ball or in any way charge (i.e. have more than casual contact with) the goalkeeper
no opposing player may interfere with or harass the goalkeeper from releasing the ball from his/her hands
The above infractions are generally non-penal fouls ("dangerous play" or "prevents the goalkeeper from releasing the ball from his hands") and result in an Indirect Free Kick.
Note that it is possible that the player committing the foul might be a teammate of the goalkeeper (keeps kicking at the ball after the keeper has possession), in which case the Indirect Free Kick is awarded to the opposing (previously attacking) team.
Goalkeeper does not (yet, or any more) have control of the ball
In this case, the ball is still bouncing/rolling around or the goalkeeper has lost possession of the ball (either intentionally or unintentionally). The goalkeeper at this point does not enjoy the special protections noted above and is like any other field player. But just as with play amongst field players, the referee needs to be on the lookout for "fouls" and specifically for "dangerous play", even more vigilantly as the ball approaches the goalkeeper... as we have the obvious situation of the keeper likely putting his/her hands and head near the ground and quite possibly into harms way.
In general, four cases can arise:
An attacking player commits a foul against the goalkeeper (push, trip, hold, impede), again viewed just as you would interplay between any two field players:
==> call the appropriate penal or non-penal foul, resulting respectively in a Direct or Indirect Free Kick for the defending team
the goalkeeper commits a foul against an attacker, again viewed just as you would interplay between any two field players:
==> call the appropriate penal or non-penal foul, resulting respectively in a Direct (PK if in penalty area) or Indirect Free Kick for the attacking team
the attacker "plays in a dangerous manner", e.g. by kicking at the ball when the keeper's head is already near that same spot
==> call dangerous play and award an IFK to the defending team
the keeper "plays in a dangerous manner", e.g. by wildly punching at the ball with elbow flailing toward the attacker, or e.g. by thrusting his/her head into an already swing foot of an attacker
==> call dangerous play and award an IFK to the attacking team
The last of these four (keeper plays in a dangerous manner) is probably the least seen case.
SAFE -- it is the referee's duty to consider the safety of all players, and particularly to protect the goalkeeper against dangerous play
FAIR -- the goalkeeper has special protections when in control/possession of the ball, but without control/possession is just like any field player (with the ref keenly on the lookout for potential dangerous play situations)
FUN