Bug 181082 - Update Credential Management API for WebAuthentication
Summary: Update Credential Management API for WebAuthentication
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jiewen Tan
URL:
Keywords: InRadar
Depends on:
Blocks: 167375
  Show dependency treegraph
 
Reported: 2017-12-21 03:33 PST by Jiewen Tan
Modified: 2022-06-27 16:35 PDT (History)
8 users (show)

See Also:


Attachments
Patch (195.85 KB, patch)
2017-12-21 03:50 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 1/2 (142.95 KB, patch)
2017-12-21 13:38 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (84.62 KB, patch)
2017-12-21 15:08 PST, Jiewen Tan
bfulgham: review-
Details | Formatted Diff | Diff
Part 2/2 (82.75 KB, patch)
2017-12-21 16:58 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (82.84 KB, patch)
2017-12-21 17:19 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (82.80 KB, patch)
2017-12-21 17:52 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (82.82 KB, patch)
2017-12-21 18:19 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (83.74 KB, patch)
2017-12-21 19:11 PST, Jiewen Tan
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (2.31 MB, application/zip)
2017-12-21 20:16 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (2.56 MB, application/zip)
2017-12-21 20:25 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews114 for mac-elcapitan (2.92 MB, application/zip)
2017-12-21 20:38 PST, EWS Watchlist
no flags Details
Part 2/2 (87.74 KB, patch)
2017-12-22 01:10 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Part 2/2 (87.83 KB, patch)
2017-12-27 12:29 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiewen Tan 2017-12-21 03:33:42 PST
Update Credential Management API for WebAuthentication
Comment 1 Jiewen Tan 2017-12-21 03:34:12 PST
<rdar://problem/36055239>
Comment 2 Jiewen Tan 2017-12-21 03:50:01 PST
Created attachment 330026 [details]
Patch
Comment 3 Brent Fulgham 2017-12-21 08:14:16 PST
Comment on attachment 330026 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=330026&action=review

r- because the patch doesn't apply to the current tree (so no ews results), and because it is very large. Please break it into two steps as I suggest in the review notes below.

> Source/WebCore/ChangeLog:15
> +        5. Set runtime flag of Credential Management API in order to enable testing.

I think this would be easier to review if we did it in steps.

Can you have a "patch 1" that just moves the folder from credentials -> credentialsmanagement, and removes the useless dummy implementations.
Then, have a "patch 2" that adds new IDLs for WebAuthN, add the new dummy functions, and add the runtime flag?
Comment 4 Jiewen Tan 2017-12-21 11:05:24 PST
(In reply to Brent Fulgham from comment #3)
> Comment on attachment 330026 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=330026&action=review
> 
> r- because the patch doesn't apply to the current tree (so no ews results),
> and because it is very large. Please break it into two steps as I suggest in
> the review notes below.
> 
> > Source/WebCore/ChangeLog:15
> > +        5. Set runtime flag of Credential Management API in order to enable testing.
> 
> I think this would be easier to review if we did it in steps.
> 
> Can you have a "patch 1" that just moves the folder from credentials ->
> credentialsmanagement, and removes the useless dummy implementations.
> Then, have a "patch 2" that adds new IDLs for WebAuthN, add the new dummy
> functions, and add the runtime flag?

NP.
Comment 5 Jiewen Tan 2017-12-21 13:38:20 PST
Created attachment 330057 [details]
Part 1/2
Comment 6 Daniel Bates 2017-12-21 13:57:03 PST
Comment on attachment 330057 [details]
Part 1/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330057&action=review

> Source/WebCore/ChangeLog:3
> +        [Part 1/2] Update Credential Management API for WebAuthentication

Typically we put the  "Part 1/2" above the "Reviewed by" line and have this line match the title of the bug verbatim.

> LayoutTests/ChangeLog:9
> +        * credentials/idlharness-expected.txt:

Should we rename the directory from credentials to credentialmanagement?

> LayoutTests/credentials/idlharness-expected.txt:37
> +FAIL PasswordCredential interface: existence and properties of interface object assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface object length assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface object name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface: existence and properties of interface prototype object assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface: attribute password assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> +FAIL PasswordCredential interface: attribute name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing

Would it be bad to remove all the password credential and password credential-related tests from this file instead of landing expected failure results?
Comment 7 Jiewen Tan 2017-12-21 14:02:27 PST
Comment on attachment 330057 [details]
Part 1/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330057&action=review

Thanks Dan for r+ my patch.

>> Source/WebCore/ChangeLog:3
>> +        [Part 1/2] Update Credential Management API for WebAuthentication
> 
> Typically we put the  "Part 1/2" above the "Reviewed by" line and have this line match the title of the bug verbatim.

I assume you mean below?

>> LayoutTests/ChangeLog:9
>> +        * credentials/idlharness-expected.txt:
> 
> Should we rename the directory from credentials to credentialmanagement?

No need. My second patch will move the whole tests into wpt tests.

>> LayoutTests/credentials/idlharness-expected.txt:37
>> +FAIL PasswordCredential interface: attribute name assert_own_property: self does not have own property "PasswordCredential" expected property "PasswordCredential" missing
> 
> Would it be bad to remove all the password credential and password credential-related tests from this file instead of landing expected failure results?

Ditto.
Comment 8 Jiewen Tan 2017-12-21 14:56:17 PST
Committed r226245: <https://trac.webkit.org/changeset/226245>
Comment 9 Jiewen Tan 2017-12-21 15:08:10 PST
Reopening to attach new patch.
Comment 10 Jiewen Tan 2017-12-21 15:08:11 PST
Created attachment 330072 [details]
Part 2/2
Comment 11 Brent Fulgham 2017-12-21 15:27:54 PST
Comment on attachment 330072 [details]
Part 2/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330072&action=review

I think this looks good, but I had some wording changes and a method name change I'd like you to make. Also, can you please explain the std::optional change I asked about in the notes below?

> Source/WebCore/ChangeLog:12
> +        which is required by WebAuthN. Besides, it also sets the CredentialManagement runtime flag to enable testing.

You don't need 'Besides' here.

> Source/WebCore/ChangeLog:13
> +        Noted, it introduces a dummy PublicKeyCredential interface for testing functionalities of the Credential interface,

'Noted, it introduces' should be 'Note that it introduces'

> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:48
> +bool CredentialsContainer::isSameOriginWithItsAncestors()

I think this should be called 'doesHaveSameOriginAsItsAncestors()'

> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:67
> +    auto task = [promiseIndex, weakThis, isSameOriginWithItsAncestors = isSameOriginWithItsAncestors(), operation = WTFMove(operation)] () {

Should we be using WTFMove() on the weakThis?

> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:85
> +    // FIXME: Optional options are passed with no contents. It should be std::optional.

I don't understand this comment. You seem to be changing this code to pass CredentialRequestOptions directly, from a std::optional argument.

> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h:-41
> -    void get(std::optional<CredentialRequestOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);

I don't get why you are making this change, if you want to go back to std::optional. Can you clarify?

> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h:58
> +    bool isSameOriginWithItsAncestors();

I think this should be called 'doesHaveSameOriginAsItsAncestors()'

> Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp:46
> +        m_credentialsContainer = CredentialsContainer::create(frame);

Can we have a CredentialsContainer with a nullptr frame? Is returning a null-constructed CredentialsContainer appropriate?

> Source/WebCore/page/RuntimeEnabledFeatures.h:251
> +    bool m_isCredentialManagementEnabled { true };

I don't think we want to turn this on yet. Test cases should be able to flip this switch on in the test case.

> LayoutTests/imported/w3c/web-platform-tests/credential-management/idl.https-expected.txt:19
> +PASS CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess()" with the proper type 

Yay!
Comment 12 Brent Fulgham 2017-12-21 15:29:38 PST
Comment on attachment 330057 [details]
Part 1/2

Clearing Dan's review flag, since this piece has already been landed.
Comment 13 Jiewen Tan 2017-12-21 16:22:01 PST
Comment on attachment 330072 [details]
Part 2/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330072&action=review

Thanks Brent for reviewing the patch.

>> Source/WebCore/ChangeLog:12
>> +        which is required by WebAuthN. Besides, it also sets the CredentialManagement runtime flag to enable testing.
> 
> You don't need 'Besides' here.

Fixed.

>> Source/WebCore/ChangeLog:13
>> +        Noted, it introduces a dummy PublicKeyCredential interface for testing functionalities of the Credential interface,
> 
> 'Noted, it introduces' should be 'Note that it introduces'

Fixed.

>> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:48
>> +bool CredentialsContainer::isSameOriginWithItsAncestors()
> 
> I think this should be called 'doesHaveSameOriginAsItsAncestors()'

Fixed.

>> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:67
>> +    auto task = [promiseIndex, weakThis, isSameOriginWithItsAncestors = isSameOriginWithItsAncestors(), operation = WTFMove(operation)] () {
> 
> Should we be using WTFMove() on the weakThis?

Yes!

>> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:85
>> +    // FIXME: Optional options are passed with no contents. It should be std::optional.
> 
> I don't understand this comment. You seem to be changing this code to pass CredentialRequestOptions directly, from a std::optional argument.

There seems a bug in our code biding generator such that it generates an empty CredentialRequestOptions object instead of std::nullopt when there is no options passed from JS. Hence, if we use std::optional here, it will always be initialized with that empty object. It makes no point to check options then. To reveal this problem, I explicitly choose to use CredentialRequestOptions&& instead of std::optional<CredentialRequestOptions>. This will help us to confirm a bug fix in the code biding generator later on.

>> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h:-41
>> -    void get(std::optional<CredentialRequestOptions>, DOMPromiseDeferred<IDLInterface<BasicCredential>>&&);
> 
> I don't get why you are making this change, if you want to go back to std::optional. Can you clarify?

Ditto.

>> Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h:58
>> +    bool isSameOriginWithItsAncestors();
> 
> I think this should be called 'doesHaveSameOriginAsItsAncestors()'

Fixed.

>> Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp:46
>> +        m_credentialsContainer = CredentialsContainer::create(frame);
> 
> Can we have a CredentialsContainer with a nullptr frame? Is returning a null-constructed CredentialsContainer appropriate?

I think it might be more appropriate to store a weak pointer of a Document then as the API requires SecureContext and is only exposed in Window. Thanks for pointing it out.

>> Source/WebCore/page/RuntimeEnabledFeatures.h:251
>> +    bool m_isCredentialManagementEnabled { true };
> 
> I don't think we want to turn this on yet. Test cases should be able to flip this switch on in the test case.

Fixed. Could we override it for WebKitTestRunner and DumpRenderTree to make testing easier?
Comment 14 Jiewen Tan 2017-12-21 16:58:19 PST
Created attachment 330078 [details]
Part 2/2
Comment 15 Jiewen Tan 2017-12-21 17:19:47 PST
Created attachment 330080 [details]
Part 2/2
Comment 16 Jiewen Tan 2017-12-21 17:52:41 PST
Created attachment 330084 [details]
Part 2/2
Comment 17 Jiewen Tan 2017-12-21 18:09:37 PST
EWS Mac bots don't allow me to move weakThis. Not sure what's wrong with them...
Copy by value then.
Comment 18 Jiewen Tan 2017-12-21 18:19:14 PST
Created attachment 330088 [details]
Part 2/2
Comment 19 Jiewen Tan 2017-12-21 19:11:35 PST
Created attachment 330093 [details]
Part 2/2
Comment 20 EWS Watchlist 2017-12-21 20:16:30 PST Comment hidden (obsolete)
Comment 21 EWS Watchlist 2017-12-21 20:16:31 PST Comment hidden (obsolete)
Comment 22 EWS Watchlist 2017-12-21 20:25:45 PST Comment hidden (obsolete)
Comment 23 EWS Watchlist 2017-12-21 20:25:46 PST Comment hidden (obsolete)
Comment 24 EWS Watchlist 2017-12-21 20:38:32 PST Comment hidden (obsolete)
Comment 25 EWS Watchlist 2017-12-21 20:38:34 PST Comment hidden (obsolete)
Comment 26 Jiewen Tan 2017-12-22 01:10:24 PST
Created attachment 330112 [details]
Part 2/2
Comment 27 Jiewen Tan 2017-12-27 12:29:59 PST
Created attachment 330224 [details]
Part 2/2
Comment 28 Brent Fulgham 2017-12-28 13:15:19 PST
(In reply to Jiewen Tan from comment #17)
> EWS Mac bots don't allow me to move weakThis. Not sure what's wrong with
> them...
> Copy by value then.

Interesting. We should show Chris, JF, or somebody with strong C++ knowledge to see what's going on!
Comment 29 Brent Fulgham 2017-12-28 13:20:00 PST
Comment on attachment 330224 [details]
Part 2/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330224&action=review

Thanks for your work on this, Jiewen! r=me.

> Source/WebCore/Modules/credentialmanagement/CredentialCreationOptions.idl:29
> +    boolean publicKey; // fake for now

Is this just a one-bit payload that may change to a larger data type in the future? I'm not sure what 'fake for now' means here.

> LayoutTests/imported/w3c/web-platform-tests/credential-management/idl.https-expected.txt:19
> +PASS CredentialsContainer interface: navigator.credentials must inherit property "preventSilentAccess()" with the proper type 

Yay!
Comment 30 Jiewen Tan 2017-12-30 22:19:00 PST
Comment on attachment 330224 [details]
Part 2/2

View in context: https://bugs.webkit.org/attachment.cgi?id=330224&action=review

Thanks Brent for r+ my patch.

>> Source/WebCore/Modules/credentialmanagement/CredentialCreationOptions.idl:29
>> +    boolean publicKey; // fake for now
> 
> Is this just a one-bit payload that may change to a larger data type in the future? I'm not sure what 'fake for now' means here.

The actual type for the publicKey member is quite complicated. I am just faking the type for this patch to avoid extra complexity.
Comment 31 WebKit Commit Bot 2018-01-02 12:28:36 PST
Comment on attachment 330224 [details]
Part 2/2

Clearing flags on attachment: 330224

Committed r226332: <https://trac.webkit.org/changeset/226332>
Comment 32 WebKit Commit Bot 2018-01-02 12:28:38 PST
All reviewed patches have been landed.  Closing bug.