Skip to content

Commit 0bdfac4

Browse files
author
Garion Herman
committed
DOCS Fix typos, add notes about secure verification and i18n
1 parent 72d162a commit 0bdfac4

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

docs/en/creating-mfa-method-frontend.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
# Creating a new MFA method: Frontend
1+
# Creating a new MFA method: Front-end
22

33
## Introduction
44

55
The MFA module provides a clear path for creating additional authentication methods. In this document we'll cover how to
66
implement the front-end portion of the required code, using the Basic Math method as an example. Some prior experience
77
with React / Redux is recommended.
88

9-
The front-end components of MFA make use of [`react-injector`](https://github.com/silverstripe/react-injector/) (Injector) to allow sharing of React components and Redux
10-
reducers between separate JS bundles. You can find more documentation on the Injector API in the [SilverStripe docs](https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/reactjs_redux_and_graphql/#the-injector-api).
9+
The front-end components of MFA make use of [`react-injector`](https://github.com/silverstripe/react-injector/)
10+
(Injector) to allow sharing of React components and Redux reducers between separate JS bundles. You can find more
11+
documentation on the Injector API in the [SilverStripe docs](https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/reactjs_redux_and_graphql/#the-injector-api).
1112

1213
You'll find it easiest to get up and running by matching the NPM dependencies and Webpack configuration used in the TOTP
13-
and WebAuthn modules, with a single entry point that handles registering your components with Injector.
14+
and WebAuthn modules, with a single entry point that handles registering your components with Injector. We also suggest
15+
making use of the i18n library, exposed to components as `window.ss.i18n`, and shown in the examples below.
1416

1517
## Create components
1618

@@ -85,13 +87,15 @@ export default Register;
8587
Your verification component will look similar to your registration one - it should accept the following props:
8688

8789
- `onCompleteVerification`: A callback that should be invoked when the user has completed the challenge presented, with
88-
any data that your `VerifyHandlerInterface::verify()` implementation needs to confirm the user's identity.
90+
any data that your `VerifyHandlerInterface::verify()` implementation needs to confirm the user's identity. **NOTE:**
91+
It is _imperative_ that your backend code is involved in the verification process, as providing secrets to the browser
92+
or otherwise relying solely on it to approve the authentication can result in significant security flaws.
8993
- `moreOptionsControl`: A React component to render in your UI, which presents a button for users to pick a different
9094
method to authenticate with. We recommend referencing the layout of the TOTP / WebAuthn implementations.
9195
- Any data you return from your `VerifyHandlerInterface::start()` implementation will also be provided to the
9296
component as props. For example, the WebAuthn module sends a challenge for the security key to sign.
9397

94-
A Register component for Basic Math might look like this:
98+
A Verify component for Basic Math might look like this:
9599

96100
```jsx
97101
import React, { Component } from 'react';
@@ -126,7 +130,7 @@ class BasicMathVerify extends Component {
126130
if (!numbers) {
127131
return (
128132
<div>
129-
<h3>Loading...</h1>
133+
<h3>{i18n._t('BasicMathLogin.LOADING', 'Loading...')}</h3>
130134
{ moreOptionsControl }
131135
</div>
132136
);

0 commit comments

Comments
 (0)