hi dragos,

an approach we took, in this regard, was the "router action" pattern.
facebook (similarly for slack) is configured to communicate with the router
action, which will discriminate challenge invocations from normal event
flow invocations.

in the case of facebook (and slack, more recently, can be configured to
operate in this way), you (not facebook) can choose the challenge
parameter. so, this can be bound to the router action in advance.

a nice thing about this is that it allows some flexibility: re-establishing
the challenge parameter can be done without tearing down any openwhisk
assets. also, the router pattern allows for a router that fans out events,
e.g. further discriminating based on some property of the incoming event
(actually more truly as a router)

the pattern also can be generalized to the case where the event source
chooses the challenge. the challenge parameter can then be self-bound
(dynamically) as a package parameter (to the package in which the router
action sits). then, even flows can easily validate the event-flow challenge
parameter (because the pre-established parameter is a package binding, it
is readily accessible by the router action)

nick

On Tue, Jun 20, 2017 at 8:45 PM, Dragos Dascalita Haut <
[email protected]> wrote:

> Is there a pattern for registering feeds with providers that require a
> verification action to be invoked, in order to validate the webhook ?
>
>
> I'm trying to add a new feed provider for FB to the OW catalog [1]. Some
> providers may enforce a verification step before accepting the webhook; it
> could be as simple as the provider sending a verification token that it
> expects to be sent back by that webhook. See an example at [2].
>
>
> In OW triggers and rules are separate concerns, a design I personally
> like. The issue is that when the providers want to verify something,
> there's no "default verification rule" associated with a trigger.
>
>
> The pattern I'm currently trying to implement is:
>
>   1.  When the CREATE event for the feed is called, register the new
> trigger
>   2.  Create a "verification" rule for this trigger to invoke an action
> that satisfies the provider requirements
>   3.  Invoke the provider API for registering a new webhook
>   4.  Wait for the provider to verify the webhook, and then delete the
> rule created at step 2.
>
>
> Do you have any thoughts regarding this approach ?
>
>
> Thanks,
>
> dragos
>
> [1] - https://github.com/apache/incubator-openwhisk-catalog
> [2] - https://developers.facebook.com/docs/graph-api/webhooks#callback-url
>

Reply via email to