-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpubsubhubbub-core-0.4.xml
1140 lines (949 loc) · 52 KB
/
pubsubhubbub-core-0.4.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<!--
For editting this, see:
http://xml.resource.org/public/rfc/html/rfc2629.html
In a nutshell,
$ sudo apt-get install xml2rfc
$ xml2rfc pubsubhubbub-core-0.1.xml pubsubhubbub-core-0.1.html
-->
<rfc category="info" docName="pubsubhubbub-core-0-4" ipr="full3978">
<?rfc toc="yes" ?>
<?rfc tocdepth="2" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc strict="no" ?>
<?rfc iprnotified="no" ?>
<?rfc private="Draft" ?>
<front>
<title>PubSubHubbub Core 0.4 -- Working Draft</title>
<author fullname="Brad Fitzpatrick" initials="B." surname="Fitzpatrick">
<organization>Google, Inc</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<author fullname="Brett Slatkin" initials="B." surname="Slatkin">
<organization>Google, Inc</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<author fullname="Martin Atkins" initials="M." surname="Atkins">
<organization>Six Apart Ltd.</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<author fullname="Monica Keller" initials="M." surname="Keller">
<organization>Facebook Inc.</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<date day="24" month="June" year="2010" />
<abstract>
<t>An open, simple, web-scale pubsub protocol, along with an open source
reference implementation targeting Google App Engine. Notably, however,
nothing in the protocol is centralized, or Google- or App
Engine-specific. Anybody can play.</t>
<t>As opposed to more developed (and more complex) pubsub specs like
<xref target="XEP-0060">Jabber Publish-Subscribe</xref> this spec's base
profile (the barrier-to-entry to speak it) is dead simple. The fancy
bits required for high-volume publishers and subscribers are optional.
The base profile is HTTP-based, as opposed to XMPP (see more on this
below).</t>
<t>In version 0.4 we have generalized the specification to support
subscription to any resource with a URL.
This was done to provide real-time notifications of changes to resources.
In addition, notifications now support specifying the type of operation
needed to reflect the synchronization change such as append, replace
or delete. This is done by having the hub more granularly convey the response from
the publisher for the resource.
Also in version 0.4 we are adding support for authenticated subscriptions
and an arbitrarily formatted payload so that for example, simple JSON
endpoints can continue using the same format.</t>
<t>We offer this spec in hopes that it allows secure synchronization
of independent repositories of data in realtime to make the web more
open, relevant and connected.
</t>
</abstract>
</front>
<middle>
<section title="Notation and Conventions">
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref
target="RFC2119"></xref>. Domain name examples use <xref
target="RFC2606"></xref>.</t>
</section>
<section title="Definitions">
<t><list style="hanging">
<t hangText="Topic:">A public or protected resource URL. The unit
to which one can subscribe to changes. Topics can point to resources with any Content Type.</t>
<t hangText="Feed:">A resource which is a list of items with unique
identifiers, and last modified timestamp for each item. Feeds MAY
contain the location of the hub.
Whether a resource is a Feed and where the hub is located will be determined
based on the Content-Type header.
RSS(application/rss+xml), Atom(application/atom+xml) and
JSON Activity Streams(application/stream+json) are examples of Feeds.
</t>
<t hangText="Hub ("the hub"):">The server (<xref
target="RFC3986">URL</xref>) which implements both sides of this
protocol. We have implemented this and are running a server at <eref
target="http://pubsubhubbub.appspot.com/">
http://pubsubhubbub.appspot.com</eref> that is, at least for now,
open to anybody for use, as either a publisher or subscriber. Any
hub MAY implement its own policies on who can use it.</t>
<t hangText="Publisher:">An owner of a resource. Notifies the hub
when the resource has been updated. It just notifies that it <spanx
style="emph">has</spanx> been updated, but not how. As in almost all
pubsub systems, the publisher is unaware of the subscribers, if any.
Other pubsub systems might call the publisher the "source".</t>
<t hangText="Subscriber:">An entity (person or program) that wants
to be notified of changes on a resource. The subscriber must be
directly network-accessible and is identified by its Subscriber
Callback URL.</t>
<t hangText="Subscription:">A unique relation to a resource by a
subscriber that indicates it should receive updates for that topic.
A subscription's unique key is the tuple (Topic URL, Subscriber
Callback URL). Subscriptions may (at the hub's decision) have
expiration times akin to DHCP leases which must be periodically
renewed.</t>
<t hangText="Subscriber Callback URL:">The <xref
target="RFC3986">URL</xref> at which a subscriber wishes to receive
notifications.</t>
<t hangText="Event:">An event that causes updates to potentially multiple
topics. For each event that happens (e.g. "Brad posted to the Linux
Community."), multiple topics could be affected (e.g. "Brad posted."
and "Linux community has new post"). Publisher events cause topics
to be updated and the hub looks up all subscriptions for affected
topics, sending out notifications to subscribers.</t>
<t hangText="Notification:">A payload describing how a topic's
contents have changed. This difference (or "delta") is computed by
the hub and sent to all subscribers if and only if the topic is a Feed.
The hub will only send the entries which are new or have changed.
If the topic is not a Feed then it cannot be used to compute deltas and
the notification will contain the entire resource as if it was fetched directly
using the topic url.
The notification can be the result of a publisher telling
the hub of an update, or the hub proactively polling a topic feed,
perhaps for a subscriber subscribing to a topic that's not
pubsub-aware. Note also that a notification to a subscriber can be a
payload consisting of updates for multiple resources. Hubs MAY
choose to send multi-resource notifications as an optimization for
heavy subscribers, but subscribers MUST understand them. See <xref
target="contentdistribution"></xref> for format details.</t>
</list></t>
</section>
<section title="High-level protocol flow">
<t>(This section is non-normative.)</t>
<t><list style="symbols">
<t>Publishers POST a ping to their hub(s) URLs when their resource(s)
change.</t>
<t>Subscribers POST to one or more of the advertised hubs for a
resource they're interested in. Alternatively, some hubs may offer
auto-polling capability, to let {their,any} subscribers subscribe to
topics which don't advertise a hub.</t>
<t>The hub caches minimal metadata (id, data, entry digest) about
each resource's previous state. When the hub re-fetches a resource
(on its own initiative or as a result of a publisher's ping) and
finds a delta, it enqueues a notification to all registered
subscribers.</t>
</list></t>
</section>
<section title="Notification Details">
<t>If the publisher's resources are feeds, then they should select a hub which
supports their Feed Content Type. The well known Feed Content Types are: <xref
target="RFC4287">Atom</xref> or <xref target="RSS20">RSS</xref> or
<xref target="JSON_Activity_Stream">JSON Activity Stream</xref>.
The Publisher makes the decision as to include full body, truncated body, or
meta data of most recent event(s). One of:</t>
<t><list style="symbols">
<t>URL + metadata</t>
<t>URL + metadata + truncated</t>
<t>URL + metadata + full</t>
</list></t>
<t>The trade-off between including all content in outgoing notifications
or having the thundering herd (by clients who fetch the <spanx
style="verb">//atom:feed/entry/link</spanx> in response to a
notification) is up to the publisher. Entries of the most recent events
(for recipient to know whether or not they'd missed any recent items--
like TCP SACK) MAY be provided as context. Some examples of Atom feed
entries follow.</t>
<t>Publishers with content that cannot be syndicated publicly SHOULD
utilize a hub which understands their authorization scheme. Typically these hubs are
Service Providers which support manual publishing by users specifying the privacy of their content.
These specialized hubs will require an authenticated and full
notification of changes. The mechanics of how this is done are outside
the scope of this spec.
They may be done via an <xref target="OAuth_2_0">OAuth 2.0</xref> POST
request to the appropriate resource end point or via the user interface
if the publisher does not wish to have their own copy of the data.
</t>
</section>
<section anchor="discovery" title="Discovery">
<t>A potential subscriber initiates discovery by retrieving the resource to
which it wants to subscribe. The <xref target="RFC2616">HTTP</xref> response
from the publisher MUST include the location of the hub if one is available.
The location of the hub MAY be transmitted using <xref target="draft-nottingham-http-link-header-10">Web Linking</xref>
<t>Example using HTTP headers to syndicate the hub for resource "http://www.asite.net/ciberch"</t>
<figure>
<artwork>
GET /ciberch HTTP/1.1
Host: www.asite.net
-------------------------------------------------------------
HTTP/1.1 200 OK
Content-Type: application/json
Link:<http://hub.company.com/>;rel="hub"
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 268
{
"id" : 1212121,
"type" : "user",
"about" : "sample about this can be any payload",
"name" : "Sample User",
"interests" : ["tennis", "ping-pong"]
}
</artwork>
</figure>
or inside the document if the mime type supports including a hub. Examples of this
are Atom or RSS where the hub is transmitted as a child of <spanx style="verb">//atom:feed</spanx>
or <spanx style="verb">//rss:rss/channel</spanx> an <spanx
style="verb">atom:link</spanx> element whose <spanx style="verb">rel</spanx>
attribute has the value <spanx style="verb">hub</spanx> and whose <spanx
style="verb">href</spanx> attribute contains the hub's endpoint URL.</t>
<t>Feeds MAY contain multiple <spanx style="verb">atom:link[@rel="hub"]</spanx>
elements if the publisher wishes to notify multiple hubs. When a
potential subscriber encounters one or more such links, that subscriber
MAY subscribe to the feed using one or more hubs URLs as described in
<xref target="subscribing"></xref>.</t>
<t>Example using the response body:</t>
<figure>
<artwork>
GET /topic.xml HTTP/1.1
Host: publisher.example.com
-------------------------------------------------------------
HTTP/1.1 200 OK
Content-Type: application/atom+xml; charset=utf-8
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 768
<![CDATA[<?xml version="1.0"?>
<atom:feed>
<!-- Normally here would be source, title, author, id, etc ... -->
<link rel="hub" href="https://www.nicehub.com/pshb_endpoint" />
<link rel="self" href="http://publisher.example.com/topic.xml" />
....
<entry>
....
</entry>
<entry>
....
</entry>
</atom:feed>
]]></artwork>
</figure>
<t>Hubs MUST use the same URL for both the publishing and subscribing
interfaces, which is why only a single <spanx style="verb">atom:link</spanx>
element is required to declare a hub. Publishers SHOULD use <xref
target="RFC2616">HTTPS</xref> in their hubs' discovery URLs. However,
subscribers that do not support <xref target="RFC2818">HTTPS</xref> MAY
try to fallback to <xref target="RFC2616">HTTP</xref>, which MAY work
depending on the hub's policy.</t>
</section>
<section anchor="subscribing" title="Subscribing and Unsubscribing">
<t>Subscribing to a resource consists of three parts that may occur
immediately in sequence or have a delay.</t>
<t><list style="symbols">
<t>Requesting a subscription using the hub</t>
<t>Confirming the subscription was actually desired</t>
<t>Periodically reconfirming the subscription is still active</t>
</list></t>
<figure title="Requesting a subscription using the hub">
<artwork>
POST /pshb_endpoint HTTP/1.1
Host: www.nicehub.com
...
Content-Type: application/x-www-form-urlencoded
Content-Length: 200
hub.callback=http://www.reader.com/pshb&hub.mode=subscribe&
hub.verify=sync&oauth_token=XXXXXXIOEIWOEWOKEM922IOJK222NK2
-------------------------------------------------------------
HTTP/1.1 204 No Content
Date: Fri, 14 May 2010 20:54:17 GMT
Content-Length: 0
</artwork>
</figure>
<t>Unsubscribing works in the same way, except with a single parameter
changed to indicate the desire to unsubscribe.</t>
<section title="Subscriber Sends Subscription Request">
<t>Subscription is initiated by the subscriber making an
<xref target="RFC2616">HTTP</xref> POST request to the hub URL.
Optionally this request can be signed using <xref target="OAuth_2_0">OAuth 2.0</xref>
and transmitted as an <xref target="RFC2818">HTTPS</xref> POST request.
This request has a Content-Type of <spanx style="verb">application/x-www-form-urlencoded</spanx>
(described in Section 17.13.4 of <xref
target="W3C.REC-html401-19991224"></xref>) and the following
parameters in its body:</t>
<t><list style="hanging">
<t hangText="hub.callback">REQUIRED. The subscriber's callback URL
where notifications should be delivered.</t>
<t hangText="hub.update_callback">OPTIONAL. The subscriber's callback URL
where content update notifications should be delivered. Will be invoked using the HTTP PUT method.
If not specified default to hub.callback</t>
<t hangText="hub.delete_callback">OPTIONAL. The subscriber's callback URL
where delete notifications should be delivered. Will be invoked using the HTTP DELETE method.
If not specified default to hub.callback</t>
<t hangText="hub.mode">REQUIRED. The literal string "subscribe" or
"unsubscribe", depending on the goal of the request.</t>
<t hangText="hub.topic">REQUIRED. The resource URL that the
subscriber wishes to subscribe to.</t>
<t hangText="hub.verify">REQUIRED. Keyword describing verification
modes supported by this subscriber, as described below. This
parameter may be repeated to indicate multiple supported
modes.</t>
<t hangText="hub.lease_seconds">OPTIONAL. Number of seconds for
which the subscriber would like to have the subscription active.
If not present or an empty value, the subscription will be
permanent (or active until <xref target="autorefresh">automatic
refreshing</xref> removes the subscription). Hubs MAY choose to
respect this value or not, depending on their own policies. This
parameter MAY be present for unsubscription requests and MUST be
ignored by the hub in that case.</t>
<t hangText="hub.secret">OPTIONAL. A subscriber-provided secret
string that will be used to compute an HMAC digest for <xref
target="authednotify">authorized content distribution</xref>. If
not supplied, the HMAC digest will not be present for content
distribution requests. This parameter SHOULD only be specified
when the request was made over <xref
target="RFC2818">HTTPS</xref>. This parameter MUST be less than
200 bytes in length.</t>
<t hangText="hub.verify_token">OPTIONAL. A subscriber-provided
opaque token that will be echoed back in the verification request
to assist the subscriber in identifying which subscription request
is being verified. If this is not included, no token will be
included in the verification request.</t>
<t hangText="oauth_token">OPTIONAL. Use this field with
<xref target="OAuth_2_0">OAuth 2.0</xref> to transmit a hub-provided
opaque token that will grant or deny access to the resource.</t>
</list>
</t>
<t>The following keywords are supported for hub.verify:</t>
<t><list style="hanging">
<t hangText="sync">The subscriber supports synchronous
verification, where the verification request must occur before the
subscription request's HTTP response is returned.</t>
<t hangText="async">The subscriber supports asynchronous
verification, where the verification request may occur at a later
point after the subscription request has returned.</t>
</list></t>
<t>Where repeated keywords are used, their order indicates the
subscriber's order of preference. Subscribers MUST use at least one of
the modes indicated in the list above, but MAY include additional
keywords defined by extension specifications. Hubs MUST ignore verify
mode keywords that they do not understand.</t>
<t>Hubs MUST ignore additional request parameters they do not
understand.</t>
<t>Hubs MUST allow subscribers to re-request subscriptions that are
already activate. Each subsequent request to a hub to subscribe or
unsubscribe MUST override the previous subscription state for a
specific topic URL and callback URL combination once the action is
verified. Any failures to confirm the subscription action MUST leave
the subscription state unchanged. This is required so subscribers can
renew their subscriptions before the lease seconds period is over
without any interruption.</t>
<section title="Subscription Parameter Details">
<t>The resource and callback URLs MUST NOT contain an anchor fragment.
These URLs MAY use <xref target="RFC2616">HTTP</xref> or <xref
target="RFC2818">HTTPS</xref> schemes. These URLs MAY have port
numbers specified; however, hubs MAY choose to disallow certain
ports based on their own policies (e.g., security) and return errors
for these requests. The topic URL can otherwise be free-form
following <xref target="RFC3986">the URI spec</xref>. Hubs MUST
always decode non-reserved characters for these URL parameters; see
section 2.4 on <spanx style="emph">"When to Encode or Decode"</spanx>
in <xref target="RFC3986">the URI spec</xref>.</t>
<t>The callback URL MAY contain arbitrary query string parameters
(e.g., <spanx style="verb">?foo=bar&red=fish</spanx>). Hubs MUST
preserve the query string during subscription verification by
appending new parameters to the end of the list using the <spanx
style="verb">&</spanx> (ampersand) character to join. Existing
parameters with names that overlap with those used by verification
requests will not be overwritten; Hubs MUST only append verification
parameters to the existing list, if any. For event notification, the
callback URL will be POSTed to including any query-string parameters
in the URL portion of the request, not as POST body parameters.</t>
<t>Subscribers MAY choose to use <xref target="RFC2818">HTTPS</xref>
for their callback URLs if they care about the privacy of
notifications as they come over the wire from the Hub. The use of
mechanisms (such as XML signatures) to verify the integrity of
notifications coming from the original publisher is out of the scope
of this specification.</t>
</section>
<section title="Subscription Response Details">
<t>The hub MUST respond to a subscription request with an HTTP 204
"No Content" response to indicate that the request was verified and
that the subscription is active. If the subscription has yet to be
verified (i.e., the hub is using asynchronous verification), the hub
MUST respond with a 202 "Accepted" code.</t>
<t>If a hub finds any errors in the subscription request, an
appropriate HTTP error response code (4xx or 5xx) MUST be returned.
For example, for <xref target="OAuth_2_0">OAuth 2.0</xref> requests
with expired tokens you would get a
<figure><artwork>
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Token realm='Service', error='token_expired'
</artwork></figure>
In the event of an error, hubs SHOULD return a description of the
error in the response body as plain text. Hubs MAY decide to reject
some callback URLs or topic URLs based on their own policies (e.g.,
domain authorization, topic URL port numbers).</t>
<t>In synchronous mode, the verification (<xref
target="verifysub"></xref>) MUST be completed before the hub returns
a response. In asynchronous mode, the verification MAY be deferred
until a later time. This is useful to enable hubs to defer work;
this could allow them to alleviate servers under heavy load or do
verification work in batches.</t>
</section>
</section>
<section anchor="verifysub"
title="Hub Verifies Intent of the Subscriber">
<t>In order to prevent an attacker from creating unwanted
subscriptions on behalf of a subscriber (or unsubscribing desired
ones), a hub must ensure that the subscriber did indeed send the
subscription request.</t>
<t>The hub verifies a subscription request by sending an <xref
target="RFC2616">HTTP</xref> GET request to the subscriber's callback
URL as given in the subscription request. This request has the
following query string arguments appended (format described in Section
17.13.4 of <xref target="W3C.REC-html401-19991224"></xref>):</t>
<t><list style="hanging">
<t hangText="hub.mode">REQUIRED. The literal string "subscribe" or
"unsubscribe", which matches the original request to the hub from
the subscriber.</t>
<t hangText="hub.topic">REQUIRED. The topic URL given in the
corresponding subscription request.</t>
<t hangText="hub.challenge">REQUIRED. A hub-generated, random
string that MUST be echoed by the subscriber to verify the
subscription.</t>
<t hangText="hub.lease_seconds">REQUIRED/OPTIONAL. The
hub-determined number of seconds that the subscription will stay
active before expiring, measured from the time the verification
request was made from the hub to the subscriber. Hubs MUST supply
this parameter for subscription requests. This parameter MAY be
present for unsubscribe requests and MUST be ignored by
subscribers during unsubscription.</t>
<t hangText="hub.verify_token">OPTIONAL. The subscriber-provided
opaque token from the corresponding subscription request, if one
was provided.</t>
</list></t>
<section title="Verification Details">
<t>The subscriber MUST confirm that the <spanx style="verb">hub.topic
</spanx> and <spanx style="verb">hub.verify_token</spanx> correspond
to a pending subscription or unsubscription that it wishes to carry
out. If so, the subscriber MUST respond with an HTTP success (2xx)
code with a response body equal to the <spanx style="verb">hub.challenge</spanx>
parameter. If the subscriber does not agree with the action, the
subscriber MUST respond with a 404 "Not Found" response.</t>
<t>For synchronous verification, the hub MUST consider other server
response codes (3xx, 4xx, 5xx) to mean that the verification request
has immediately failed and no retries should occur. If the
subscriber returns an HTTP success (2xx) but the content body does
not match the <spanx style="verb">hub.challenge</spanx> parameter,
the hub MUST also consider verification to have failed.</t>
<t>For asynchronous verification, the hub MUST consider other server
response codes (3xx, 4xx, and 5xx) to mean that the subscription
action was <spanx style="emph">temporarily</spanx> not verified. If
the subscriber returns an HTTP success (2xx) but the content body
does not match the <spanx style="verb">hub.challenge</spanx>
parameter, the hub MUST consider this to be a <spanx style="emph">temporary</spanx>
failure and retry. The hub SHOULD retry verification a reasonable
number of times over the course of a longer time period (e.g., 6
hours) until a definite acknowledgement (positive or negative) is
received. If a definite response still cannot be determined after
this retry period, the subscription action verification MUST be
abandoned, leaving the previous subscription state.</t>
<t>Hubs MAY make the <spanx style="verb">hub.lease_seconds</spanx>
equal to the period the subscriber passed in their subscription
request but MAY change the value depending on the hub's policies. To
sustain a temporary subscription, the subscriber MUST re-request the
subscription on the hub before <spanx style="verb">hub.lease_seconds</spanx>
seconds has elapsed. For permanent subscriptions with no <spanx
style="verb">hub.lease_seconds</spanx> value specified, the behavior
is different as described in the section on <xref
target="autorefresh">automatic subscription refreshing</xref>.</t>
</section>
</section>
<section anchor="autorefresh" title="Automatic Subscription Refreshing">
<t>Before a subscription expires (i.e., before <spanx style="verb">hub.lease_seconds</spanx>
elapses), Hubs MUST recheck with subscribers to see if a continued
subscription is desired. Hubs do this by sending the subscriber a
<xref target="verifysub">verification request</xref> with <spanx
style="verb">hub.mode</spanx> equal to subscribe. This request MUST
match the original verification request sent to the subscriber (but
with a new <spanx style="verb">hub.challenge</spanx>).</t>
<t>The response codes returned by the subscriber MUST be interpreted
the same way as during a subscriber-initiated verification flow.
However, this refresh request MUST behave like an initial subscription
request; this means that if an auto-refresh response from the
subscriber constantly returns an error, the hub MUST give up on the
subscription verification action altogether and remove the
subscription.</t>
<t>In the case of permanent subscriptions (with no <spanx
style="verb">hub.lease_seconds</spanx> specified in the original
request), the <spanx style="verb">hub.lease_seconds</spanx> value
supplied by the hub in the verification request to the subscriber
SHOULD represent how many seconds until the hub expects it will next
initiate automatic subscription refreshing to ensure that the
subscriber is still interested in the topic. This behavior provides
the best of both worlds: maximum simplicity of the subscriber through
infinitely-long subscriptions, but still garbage collectable
subscriptions for hub hygiene.</t>
</section>
</section>
<section anchor="publishing" title="Publishing">
<t>A publisher pings the hub with the topic URL(s) which have been
updated and the hub schedules those topics to be fetched and delivered.
Because it's just a ping to notify the hub of the topic URL (without a
payload), no authentication from the publisher is required.</t>
<section title="New Content Notification">
<t>When new content is added to a feed, a notification is sent to the
hub by the publisher. The hub MUST accept a POST request to the hub
URL containing the notification. This request MUST have a Content-Type
of <spanx style="verb">application/x-www-form-urlencoded
</spanx> (described in Section 17.13.4 of <xref
target="W3C.REC-html401-19991224"></xref>) and the following
parameters in its body:</t>
<t><list style="hanging">
<t hangText="hub.mode">REQUIRED. The literal string "publish".</t>
<t hangText="hub.url">REQUIRED. The topic URL of the topic that
has been updated. This field may be repeated to indicate multiple
topics that have been updated.</t>
<t hangText="oauth_token">OPTIONAL if the Hub requires that the
author and content generator are identified prior to granting
distribution access and/or to provide access control. </t>
</list></t>
<t>The new content notification is a signal to the hub that there is
new content available. The hub SHOULD arrange for a content fetch
request (<xref target="contentfetch"></xref>) to be performed in the
near future to retrieve the new content. If the notification was
acceptable, the hub MUST return a 204 No Content response. If the
notification is not acceptable for some reason, the hub MUST return an
appropriate HTTP error response code (4xx and 5xx). Hubs MUST return a
204 No Content response even when they do not have any subscribers for
all of the specified topic URLs.</t>
</section>
<section anchor="contentfetch" title="Content Fetch">
<t>When the hub wishes to retrieve new content for a topic, the hub
sends an <xref target="RFC2616">HTTP</xref> GET request to the topic
URL. The hub MUST follow HTTP redirects. The Hub SHOULD use best
practices for caching headers in its requests (e.g., <spanx
style="verb">If-None-Match</spanx>, <spanx style="verb">If-Modified-Since</spanx>).</t>
<t>The request SHOULD include the header field <spanx style="verb">User-Agent</spanx>
in the form expected by <xref target="RFC2616">HTTP</xref>. The header
MAY have one or more additional suffixes like <spanx style="verb">(example.com; 20 subscribers)</spanx>
to indicate the number of subscriptions the hub has active for this
topic.</t>
<t>If present, the first suffix MUST indicate the total number of
subscriptions the hub has aggregated across all subscriber domains by
means of the <spanx style="verb">X-Hub-On-Behalf-Of</spanx> header
(<xref target="contentdistribution"></xref>). Any additional suffixes
indicate a breakdown of subscriber counts across subscriber domains.
This allows content publishers to distinguish the source of their
subscriber counts and mitigate subscriber count spam. An example
header could be (ignoring line-wrapping):</t>
<figure>
<artwork><![CDATA[
User-Agent: MyHub (+http://hub.example.com; 26 subscribers)
(sub.example.com; 4 subscribers)
(other-sub.example.com; 22 subscribers)
]]></artwork>
</figure>
<t>If, after a content fetch, the hub determines that the topic feed
content has changed, the hub MUST send information about the changes
to each of the subscribers to the topic (<xref
target="contentdistribution"></xref>). Hubs MUST consider new feed
entries, updated entries, deleted entries or changes to the surrounding
feed document as significant content changes that require content
distribution.</t>
</section>
<section anchor="contentdistribution" title="Content Distribution">
<t>A content distribution request is an <xref
target="RFC2616">HTTP</xref> POST, PUT or DELETE request from hub to the subscriber's
callback URL with the list of new and changed entries. The Content-Type header will
indicate the format of the request.
Hubs MAY transform the content type and request body as desired (e.g.,
for language translation).</t>
<t>If the document represents a single feed being replicated for the
subscriber, then the feed-level elements SHOULD be preserved aside
from the <spanx style="verb">atom:entry</spanx> or <spanx
style="verb">rss:item</spanx> elements. However, the <spanx
style="verb">atom:id</spanx> element MUST be reproduced exactly. The
other <spanx style="verb">atom:updated</spanx> and <spanx
style="verb">atom:title</spanx> elements required by the Atom
specification SHOULD be present. Each <spanx style="verb">atom:entry</spanx>
or <spanx style="verb">rss:item</spanx> element in the feed contains
the content from an entry in the single topic that the subscriber has
an active subscription for. Essentially, in the single feed case the
subscriber will receive a feed document that looks like the original
but with old content removed.</t>
<t>The successful response from the subscriber's callback URL MUST be
an HTTP success (2xx) code. The hub MUST consider all other subscriber
response codes as failures; that means subscribers MUST not use HTTP
redirects for moving subscriptions. The response body from the
subscriber MUST be ignored by the hub. Hubs SHOULD retry notifications
repeatedly until successful (up to some reasonable maximum over a
reasonable time period). Subscribers SHOULD respond to notifications
as quickly as possible; their success response code SHOULD only
indicate receipt of the message, not acknowledgment that it was
successfully processed by the subscriber.</t>
<t>The subscriber's callback response MAY include the header field
<spanx style="verb">X-Hub-On-Behalf-Of</spanx> with an integer value,
possibly approximate, representing the number of subscribers on behalf
of which this feed notification was delivered. This value SHOULD be
aggregated by the hub across all subscribers and used to provide the
subscriber counts in the <spanx style="verb">User-Agent</spanx> header
field sent to publishers (<xref target="contentfetch"></xref>). Hubs
MAY ignore or respect <spanx style="verb">X-Hub-On-Behalf-Of</spanx>
values from subscribers depending on their own policies (i.e., to
prevent spam).</t>
</section>
<section anchor="authednotify"
title="Authenticated Content Distribution">
<t>If the subscriber supplied a value for <spanx style="verb">hub.secret</spanx>
in their subscription request, the hub MUST generate an HMAC signature
of the payload and include that signature in the request headers of
the content distribution request. The <spanx style="verb">X-Hub-Signature</spanx>
header's value MUST be in the form <spanx style="verb">sha1=signature</spanx>
where <spanx style="verb">signature</spanx> is a 40-byte, hexadecimal
representation of a <xref target="RFC3174">SHA1 signature</xref>. The
signature MUST be computed using the <xref target="RFC2104">HMAC
algorithm</xref> with the request body as the data and the <spanx
style="verb">hub.secret</spanx> as the key.</t>
<t>When subscribers receive a content distribution request with the
<spanx style="verb">X-Hub-Signature</spanx> header specified, they
SHOULD recompute the SHA1 signature with the shared secret using the
same method as the hub. If the signature does not match, subscribers
MUST still return a 2xx success response to acknowledge receipt, but
locally ignore the message as invalid. Using this technique along with
HTTPS for subscription requests enables simple subscribers to receive
authenticated content delivery from hubs without the need for
subscribers to run an HTTPS server.</t>
</section>
<section anchor="aggregatedistribution"
title="Aggregated Content Distribution">
<t>For Atom feeds and JSON Activity Streams only. Pending further review.</t>
<t>When a subscriber indicates the same callback URL is used for
multiple subscriptions, hubs MAY choose to combine content delivery
requests into a single payload containing an aggregated set of feeds.
This bulk delivery results in fewer requests and more efficient
distribution. If the subscriber indicated a <spanx style="verb">hub.secret</spanx>
value for these overlapping subscriptions, the secret MUST also be the
same for all subscriptions. This allows the hub to generate a single
<spanx style="verb">X-Hub-Signature</spanx> header to sign the entire
payload. Hubs MUST return an error response (4xx, 5xx) for
subscription requests with overlapping callback URLs and different
secret values.</t>
<t>With an aggregated set of feeds, the hub SHOULD reproduce all of
the elements from the source feed <spanx style="emph">inside</spanx>
the corresponding <spanx style="verb">atom:entry</spanx> in the
content distribution request by using an <spanx style="verb">atom:source</spanx>
element. However, the <spanx style="verb">atom:id</spanx> value MUST
be reproduced exactly within the source element. If the source entry
does not have an <spanx style="verb">atom:source</spanx> element, the
hub MUST create an <spanx style="verb">atom:source</spanx> element
containing the <spanx style="verb">atom:id</spanx> element. The hub
SHOULD also include the <spanx style="verb">atom:title</spanx> element
and an <spanx style="verb">atom:link</spanx> element with <spanx
style="verb">rel="self"</spanx> values that are functionally
equivalent to the corresponding elements in the original topic
feed.</t>
<t>Example aggregated feed:</t>
<figure>
<artwork><![CDATA[<?xml version="1.0"?>
<atom:feed>
<title>Aggregated feed</title>
<updated>2008-08-11T02:17:44Z</updated>
<id>http://myhub.example.com/aggregated?1232427842-39823</id>
<entry>
<source>
<id>http://www.example.com/foo</id>
<link rel="self" href="http://publisher.example.com/foo.xml" />
<author>
<name>Mr. Bar</name>
</author>
</source>
<title>Testing Foo</title>
<link href="http://publisher.example.com/foo24.xml" />
<id>http://publisher.example.com/foo24.xml</id>
<updated>2008-08-11T02:15:01Z</updated>
<content>
This is some content from the user named foo.
</content>
</entry>
<entry>
<source>
<id>http://www.example.com/bar</id>
<link rel="self" href="http://publisher.example.com/bar.xml" />
<author>
<name>Mr. Bar</name>
</author>
</source>
<title>Testing Bar</title>
<link href="http://publisher.example.com/bar18.xml" />
<id>http://publisher.example.com/bar18.xml</id>
<updated>2008-08-11T02:17:44Z</updated>
<content>
Some data from the user named bar.
</content>
</entry>
</atom:feed>
]]></artwork>
</figure>
</section>
</section>
<section anchor="bestpractices" title="Best Practices">
<t>(This section is non-normative.)</t>
<section anchor="hubbestpractices" title="For Hubs">
<t>The vast majority of feeds on the web have multiple <spanx
style="emph">variants</spanx> that contain essentially the same
content but appear on different URLs. A common set of variants is
<spanx style="verb">http://example.com/feed?format=atom</spanx> and
<spanx style="verb">http://example.com/feed?format=rss</spanx>. In
practice, these URLs also fail to set their <spanx style="verb">//atom:feed/link[@rel="self"]</spanx>
values properly, meaning it's difficult for subscribers to discover
which feed URL they truly wanted. Making matters worse, feeds often
have redirects (temporary or permanent) to new hosting locations,
analytics providers, or other feed-processors. To solve this, it's
important for Hub implementations to determine feed URL equivalences
using heuristics. Examples: follow all feed URLs redirects and see if
they end up at the same location; use overlaps in feed HTML alternate
links; use the <spanx style="verb">atom:id</spanx> value across all
domains. This specific problem is considered out of scope of this
specification but this section is meant as a reminder to implementors
that feed URL aliasing is an important issue that hubs should address
instead of putting the burden on publishers and subscribers.</t>
</section>
<section anchor="subbestpractices" title="For Subscribers">
<t>The <spanx style="verb">hub.verify_token</spanx> parameter in
subscription requests enables subscribers to verify the identity and
intent of the hub making the verification request. Subscribers should
use the token to retrieve internal state to ensure the subscription
request outcome is what they intended.</t>
</section>
</section>
</middle>
<back>
<references title="References">
<reference anchor="RFC2104">
<front>
<title abbrev="HMAC">HMAC: Keyed-Hashing for Message
Authentication</title>
<author fullname="Hugo Krawczyk" initials="H." surname="Krawczyk">
<organization>IBM, T.J. Watson Research Center</organization>
</author>
<author fullname="Mihir Bellare" initials="M." surname="Bellare">
<organization>University of California at San Diego, Dept of
Computer Science and Engineering</organization>
</author>
<author fullname="Ran Canetti" initials="R." surname="Canetti">
<organization>IBM T.J. Watson Research Center</organization>
</author>
</front>
<seriesInfo name="RFC" value="2104" />
</reference>
<reference anchor="RFC2606">
<front>
<title>Reserved Top Level DNS Names</title>
<author fullname="D. Eastlake" initials="D.E" surname="Eastlake">
<organization />
</author>
<author fullname="A. Panitz" initials="A.P" surname="Panitz">
<organization />
</author>
</front>
<seriesInfo name="RFC" value="2606" />
</reference>
<reference anchor="RFC2119">
<front>
<title>Key words for use in RFCs to Indicate Requirement
Levels</title>
<author fullname="Scott Bradner" initials="B.S" surname="Bradner">
<organization>Alis Technologies</organization>
</author>
</front>
<seriesInfo name="RFC" value="2119" />
</reference>
<reference anchor="RFC2616">
<front>
<title>Hypertext Transfer Protocol -- HTTP/1.1</title>
<author fullname="R. Fielding" initials="R.F" surname="Fielding">
<organization>UC Irvine</organization>
</author>
<author fullname="J. Gettys" initials="J.G" surname="Gettys">
<organization>Compaq/W3C</organization>
</author>
<author fullname="J. Mogul" initials="J.M" surname="Mogul">
<organization>Compaq</organization>
</author>
<author fullname="H. Frystyk" initials="H.F" surname="Frystyk">
<organization>W3C/MIT</organization>
</author>
<author fullname="L. Masinter" initials="L.M" surname="Masinter">
<organization>Xerox</organization>
</author>
<author fullname="P. Leach" initials="P.L" surname="Leach">
<organization>Microsoft</organization>
</author>
<author fullname="T. Berners-Lee" initials="T.L"
surname="Berners-Lee">
<organization>W3C/MIT</organization>
</author>
</front>
<seriesInfo name="RFC" value="2616" />
</reference>
<reference anchor="RFC2818">
<front>
<title>HTTP Over TLS</title>
<author fullname="E. Rescorla" initials="E." surname="Rescorla">
<organization></organization>
</author>
<date month="May" year="2000" />
<abstract>
<t>This memo describes how to use Transport Layer Security (TLS)
to secure Hypertext Transfer Protocol (HTTP) connections over the
Internet. This memo provides information for the Internet
community.</t>
</abstract>
</front>
<seriesInfo name="RFC" value="2818" />
<format octets="15170" target="ftp://ftp.isi.edu/in-notes/rfc2818.txt"
type="TXT" />
</reference>
<reference anchor="RFC3174">
<front>
<title>US Secure Hash Algorithm 1 (SHA1)</title>
<author fullname="D. Eastlake" initials="D." surname="Eastlake">
<organization></organization>
</author>
<author fullname="P. Jones" initials="P." surname="Jones">
<organization></organization>
</author>
<date month="September" year="2001" />
<abstract>
<t>The purpose of this document is to make the SHA-1 (Secure Hash
Algorithm 1) hash algorithm conveniently available to the Internet