Credential Management API की सुविधा की जांच

खास जानकारी

WebAuthn, वेब पर सार्वजनिक पासकोड क्रेडेंशियल पर आधारित पुष्टि करने की सुविधा उपलब्ध कराकर, सुरक्षा को बेहतर बनाने में मदद करता है. जल्द ही, Chrome, Firefox, और Edge (अपडेट की गई खास जानकारी के साथ) में भी यह सुविधा काम करेगी. यह एक नए तरह का Credential ऑब्जेक्ट जोड़ता है. हालांकि, इससे उन वेबसाइटों को नुकसान पहुंच सकता है जो Credential Management API का इस्तेमाल करती हैं. ऐसा तब होता है, जब वे इस्तेमाल किए जा रहे क्रेडेंशियल के टाइप का पता लगाए बिना ही इस एपीआई का इस्तेमाल करती हैं.

अगर फ़िलहाल सुविधा की पहचान करने के लिए ऐसा किया जा रहा है, तो

if (navigator.credentials && navigator.credentials.preventSilentAccess) {
    // use CM API
}

इसके बजाय, ये काम करें

if (window.PasswordCredential || window.FederatedCredential) {
    // Call navigator.credentials.get() to retrieve stored
    // PasswordCredentials or FederatedCredentials.
}

if (window.PasswordCredential) {
    // Get/Store PasswordCredential
}

if (window.FederatedCredential) {
    // Get/Store FederatedCredential
}

if (navigator.credentials && navigator.credentials.preventSilentAccess) {
    // Call navigator.credentials.preventSilentAccess()
}

उदाहरण के तौर पर, सैंपल कोड में किए गए बदलाव देखें.

ज़्यादा जानने के लिए आगे पढ़ें.

Credential Management API क्या है

Credential Management API (CM API), वेबसाइटों को उपयोगकर्ता एजेंट के क्रेडेंशियल स्टोर का प्रोग्राम के हिसाब से ऐक्सेस देता है. इससे, कॉल करने वाले ऑरिजिन के लिए उपयोगकर्ता के क्रेडेंशियल को सेव/वापस लाया जा सकता है.

बुनियादी एपीआई ये हैं:

  • navigator.credentials.get()
  • navigator.credentials.store()
  • navigator.credentials.create()
  • navigator.credentials.preventSilentAccess()

ओरिजनल CM API स्पेसिफ़िकेशन में दो तरह के क्रेडेंशियल के बारे में बताया गया है:

  • PasswordCredential
  • FederatedCredential

PasswordCredential एक क्रेडेंशियल है, जिसमें उपयोगकर्ता का आईडी और पासवर्ड शामिल होता है. FederatedCredential एक क्रेडेंशियल है, जिसमें उपयोगकर्ता का आईडी और आइडेंटिटी प्रोवाइडर को दिखाने वाली स्ट्रिंग शामिल होती है.

इन दो क्रेडेंशियल की मदद से, वेबसाइटें ये काम कर सकती हैं:

  • उपयोगकर्ता को पहले से सेव किए गए पासवर्ड या फ़ेडरेटेड क्रेडेंशियल की मदद से साइन-इन करने की सुविधा दें. ऐसा तब होगा, जब वे लैंडिंग पेज पर पहुंचेंगे (अपने-आप साइन-इन होने की सुविधा),
  • पासवर्ड पर आधारित या फ़ेडरेटेड क्रेडेंशियल को सेव करना, जिसका इस्तेमाल करके उपयोगकर्ता ने साइन इन किया है,
  • उपयोगकर्ता के साइन-इन क्रेडेंशियल को अप-टू-डेट रखना. जैसे, पासवर्ड बदलने के बाद

WebAuthn क्या है

WebAuthn (वेब ऑथेंटिकेशन), CM API में सार्वजनिक पासकोड वाले क्रेडेंशियल जोड़ता है. उदाहरण के लिए, यह वेबसाइटों को FIDO 2.0 के मुताबिक पुष्टि करने वाले डिवाइसों का इस्तेमाल करके, दो तरीकों से पुष्टि करने की सुविधा लागू करने का एक स्टैंडर्ड तरीका देता है.

तकनीकी तौर पर, WebAuthn PublicKeyCredential इंटरफ़ेस की मदद से, CM API को बेहतर बनाता है.

समस्या क्या है?

पहले, हम डेवलपर को इस कोड का इस्तेमाल करके, सीएम एपीआई की सुविधा का पता लगाने के लिए गाइड करते थे:

if (navigator.credentials && navigator.credentials.preventSilentAccess) {
  // Use CM API
}

But as you can see from the descriptions above, the `navigator.credentials` is
now expanded to support public-key credentials in addition to password
credentials and federated credentials.

The problem is that user agents don't necessarily support all kinds of
credentials. If you continue feature detect using `navigator.credentials`, your
website may break when you are using a certain credential type not supported by
the browser.

**Supported credential types by browser<s**
table class="properties with-head><ing-t><in>t<&q><uot>;<tb>odytr
th/th
thPasswordCredential / Feder<ate>d<Cr>edential/th
thPubli<cKe>y<Cre><de><nt>ial/th
</tr><tr>thChrome
/<tht><dA>vailable
/tdtdI<n d><eve><lo><pm>ent
/td/<trt><rt>hFir<efo><x<>/span>
/thtdN/A
/tdtdAiming <to ><shi><p ><on> 60
/<td/><tr>trth<Edg><e<>/span>
/thtdN/A
/tdtdImp<lemented with a href="https://blogs.windows.com/msedgedev/2016/04/12/a-world-without-passwords-windows-hello->in-micros<of>t-edge/"older API/a. New API (navigator.cr<ede><nti><als) c><oming >soon.
/td/tr/tbody/table


## The solution
You can avoid this by modifying feature detection code as follows to explicitly
test for the credential type that you intend to use.

```js
if (window.PasswordCredential || window.FederatedCredential) {
    // Call navigator.credentials.get() to retrieve stored
    // PasswordCredentials or FederatedCredentials.
}

if (window.PasswordCredential) {
    // Get/Store PasswordCredential
}

if (window.FederatedCredential) {
    // Get/Store FederatedCredential
}

if&& (navigator.credentials  navigator.credentials.preventSilentAccess) {
    // Call navigator.credentials.preventSilentAccess()
}

उदाहरण के तौर पर, सैंपल कोड में किए गए असल बदलाव देखें.

रेफ़रंस के लिए, WebAuthn में जोड़े गए PublicKeyCredential का पता लगाने का तरीका यहां बताया गया है:

if (window.PublicKeyCredential) {
    // use CM API with PublicKeyCredential added in the WebAuthn spec
}

टाइमलाइन

WebAuthn को सबसे पहले Firefox में लागू किया गया था. इसे मई 2018 की शुरुआत में स्टेबल वर्शन के तौर पर उपलब्ध कराने का प्लान है.

आखिरकार

अगर आपका कोई सवाल है, तो उसे @agektmr या agektmr@chromium.org पर भेजें.