خلاصه
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 چیست؟
The Credential Management API (CM API) gives websites programmatic access to the user agent’s credential store for storing/retrieving user credentials for the calling origin.
میاناهای برنامهسازی کاربردی پایه عبارتاند از:
navigator.credentials.get()navigator.credentials.store()navigator.credentials.create()navigator.credentials.preventSilentAccess()
مشخصات اصلی CM API دو نوع اعتبارنامه را تعریف میکند:
PasswordCredentialFederatedCredential
PasswordCredential اطلاعات اعتباریای است که حاوی شناسه و گذرواژه کاربر است.
FederatedCredential اعتباری است که حاوی شناسه کاربر و رشتهای است که ارائهدهنده هویت را نشان میدهد.
با این ۲ اعتبارنامه، وبسایتها میتوانند:
- به کاربر اجازه دهید بهمحض ورود به سیستم (ورود خودکار به سیستم)، با اعتبارنامه فدرال یا مبتنی بر گذرواژه که قبلاً ذخیره شده است به سیستم وارد شود،
- اعتبارنامه فدراسیونی یا مبتنی بر گذرواژه را که کاربر با آن به سیستم وارد شده است ذخیره کنید،
- اعتبارنامه ورود به سیستم کاربر را بهروز نگه دارید (مثلاً پساز تغییر گذرواژه)
اصالتسنجی وب چیست
WebAuthn (اصالتسنجی وب) اطلاعات کاربری کلید عمومی را به CM API اضافه میکند. برای مثال، این API روشی استانداردشده برای پیادهسازی اصالتسنجی با دو عامل بااستفاده از دستگاههای اصالتسنجی سازگار با FIDO 2.0 دراختیار وبسایتها قرار میدهد.
در سطح فنی، WebAuthn میانای برنامهسازی کاربردی CM را با میانای 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()
}
تغییرات واقعی اعمالشده در کد نمونه را بهعنوان مثال ببینید.
برای مرجع، در اینجا نحوه تشخیص PublicKeyCredential اضافهشده در WebAuthn آورده شده است:
if (window.PublicKeyCredential) {
// use CM API with PublicKeyCredential added in the WebAuthn spec
}
خط زمان
اولین پیادهسازی دردسترس WebAuthn در Firefox است و برنامهریزی شده است که حدود اوایل مه ۲۰۱۸ پایدار شود.
در نهایت
اگر سؤالی دارید، آن را به @agektmr یا agektmr@chromium.org ارسال کنید.