Hi Jonathan,
When thinking of macaroons, think of each macaroon as granting absolute
access to a specific resource. For example, there could be one secret
per profile in a social network.
Once you figure out the resource/secret coupling, the use of caveats
falls out naturally. For example, in the social network example, the
application can take the macaroon for my profile, add the caveats "post
to wall" as a 1st party caveat and "is friends with Robert" as a third
party caveat, and publish this macaroon in a place where every user can
see it. This macaroon is only useful for principals posting to my wall,
and only after they can obtain the third party discharge that they are
friends with me. That discharge can, of course, include further
caveats.
The caveats themselves form the policy to be verified. In your system,
I would assign one macaroon secret per widget. A macaroon minted with
this secret provides complete, unfettered access to the widget. You can
then do things like I described above, and publish a widget that says,
"You can play with this widget" as a first party caveat and "The
authorization system says you are in the 'playful people' group" as a
third party caveat. You could make these available like
/macaroons/widgets/:id/play. Again, there's no need to provide
authorization on these with the third party caveats because the
macaroons are unusable without the discharge.
Done right, you could even prevent the client from contacting the
discharge server to prove it's a member of the 'playful people' group
more than once.
If you want to really change your view on macaroons, you could even
consider a scenario in which macaroons are obtainable only after
presenting other macaroons. For example, in a social network, you could
have one macaroon per image uploaded by users. The owner of an image
has a macaroon with absolute authority over the image. The service
could have a single copy of this macaroon with a read caveat on it
hidden behind a service that requires that you prove yourself to be
logged in and friends with the image owner before retrieving the
image-access macaroon.
-Robert