Skip to content

Commit 0d1116c

Browse files
committed
Add method FidoMetadataDownloader.refreshBlob()
1 parent 1f823bc commit 0d1116c

File tree

5 files changed

+1734
-1461
lines changed

5 files changed

+1734
-1461
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
== Version 2.1.0 (unreleased) ==
2+
3+
New features:
4+
5+
- Added method `FidoMetadataDownloader.refreshBlob()`.
6+
7+
18
== Version 2.0.0 ==
29

310
This release removes deprecated APIs and changes some defaults to better align

webauthn-server-attestation/README.adoc

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ The
3131
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html[`FidoMetadataDownloader`]
3232
class will attempt to download a new BLOB only when its
3333
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
34-
is executed,
35-
and then only if the cache is empty or if the cached BLOB is invalid or out of date.
34+
or
35+
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`]
36+
method is executed.
37+
As the names suggest,
38+
`loadCachedBlob()` downloads a new BLOB only if the cache is empty
39+
or the cached BLOB is invalid or out of date,
40+
while `refreshBlob()` always downloads a new BLOB and falls back
41+
to the cached BLOB only when the new BLOB is invalid in some way.
3642
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataService.html[`FidoMetadataService`]
3743
will never re-download a new BLOB once instantiated.
3844
+
39-
You should use some external scheduling mechanism to re-run `loadCachedBlob()` periodically
45+
You should use some external scheduling mechanism to re-run `loadCachedBlob()`
46+
and/or `refreshBlob()` periodically
4047
and rebuild new `FidoMetadataService` instances with the updated metadata contents.
4148
You can do this with minimal disruption since the `FidoMetadataService` and `RelyingParty`
4249
classes keep no internal mutable state.
@@ -95,11 +102,14 @@ Unlike other classes in this module and the core library,
95102
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html[`FidoMetadataDownloader`]
96103
is NOT THREAD SAFE since its
97104
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
98-
method reads and writes caches.
105+
and
106+
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`]
107+
methods read and write caches.
99108
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataService.html[`FidoMetadataService`],
100109
on the other hand, is thread safe,
101-
and `FidoMetadataDownloader` instances can be reused for subsequent `loadCachedBlob()` calls
102-
as long as only one `loadCachedBlob()` call executes at a time.
110+
and `FidoMetadataDownloader` instances can be reused
111+
for subsequent `loadCachedBlob()` and `refreshBlob()` calls
112+
as long as only one call executes at a time.
103113
=====
104114
+
105115
[source,java]
@@ -323,15 +333,19 @@ The library implements these as closely as possible, but with some slight depart
323333

324334
** Step 3 states "The `nextUpdate` field of the Metadata BLOB specifies a date when the download SHOULD occur at latest".
325335
`FidoMetadataDownloader` does not automatically re-download the BLOB.
326-
Instead, each time its
336+
Instead, each time the
327337
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
328338
method is executed it checks whether a new BLOB should be downloaded.
339+
The
340+
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`]
341+
method always attempts to download a new BLOB when executed,
342+
but also does not trigger re-downloads automatically.
329343
+
330-
If no BLOB exists in cache, or the cached BLOB is invalid, or if the current date is greater than or equal to `nextUpdate`,
331-
then a new BLOB is downloaded.
332-
If the new BLOB is valid, has a correct signature, and has a `no` field greater than the cached BLOB,
344+
Whenever a newly downloaded BLOB is valid, has a correct signature,
345+
and has a `no` field greater than the cached BLOB (if any),
333346
then the new BLOB replaces the cached one;
334-
otherwise, the new BLOB is discarded and the cached one is kept until the next execution of `.loadCachedBlob()`.
347+
otherwise, the new BLOB is discarded and the cached one is kept
348+
until the next execution of `.loadCachedBlob()` or `.refreshBlob()`.
335349

336350
* Metadata entries are not stored or cached individually, instead the BLOB is cached as a whole.
337351
In processing rules step 8, neither `FidoMetadataDownloader` nor

webauthn-server-attestation/doc/Migrating_from_v1.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ FidoMetadataService metadataService = FidoMetadataService.builder()
6666

6767
You may also need to add external logic to occasionally re-run
6868
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
69+
and/or
70+
link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`]
6971
and reconstruct the `FidoMetadataService`,
7072
as `FidoMetadataService` will not automatically update the BLOB on its own.
7173

0 commit comments

Comments
 (0)