Skip to content

Commit

Permalink
Move documentation in ra-auth-cognito
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitix committed Feb 16, 2024
1 parent cd0933b commit c5802f9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ The first time you sign in with any of the users, you'll have to enter their tem

Feel free to play around with this demo, along with the Cognito config, to understand better how it works!

## Using the TOTP MFA

The library offers English and French translations for TOTP MFA pages. If you need other translations, have a look to the [ra-auth-cognito-language-french package](packages/ra-auth-cognito-language-french/README.md).

## Customizing the application name using the TOTP MFA

By default, the library uses the `hostname` as the `applicationName`. If you want to define your own, add a second parameter to the `authProvider`, defining the `applicationName` you want:

```js
authProvider(cognitoConfig, {
applicationName: "My Super App"
});
```


## License

This repository and the code it contains are licensed under the MIT License and sponsored by [marmelab](https://marmelab.com).
Expand Down
95 changes: 55 additions & 40 deletions packages/ra-auth-cognito/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This package provides:

## Supported Cognito Features

- Username/password authentication
- OAuth authentication with Implicit code grant
- Username/password authentication
- OAuth authentication with Implicit code grant

In all cases, users must be added to the user pool with their email set before they may sign-in in react-admin.

Expand Down Expand Up @@ -44,16 +44,16 @@ const userPool = new CognitoUserPool({
const authProvider = CognitoAuthProvider(userPool);

const App = () => {
return (
<Admin
authProvider={authProvider}
dataProvider={dataProvider}
title="Example Admin"
loginPage={Login}
return (
<Admin
authProvider={authProvider}
dataProvider={dataProvider}
title="Example Admin"
loginPage={Login}
>
<Resource name="posts" {...posts} />
</Admin>
);
</Admin>
);
};
export default App;
```
Expand All @@ -75,20 +75,20 @@ const authProvider = CognitoAuthProvider({
mode: 'oauth',
clientId: 'COGNITO_APP_CLIENT_ID',
userPoolId: 'COGNITO_USERPOOL_ID',
hostedUIUrl: 'YOUR AWS HOSTED UI URL',
hostedUIUrl: 'YOUR AWS HOSTED UI URL',
});

const App = () => {
return (
<Admin
authProvider={authProvider}
dataProvider={dataProvider}
title="Example Admin"
loginPage={false} // We don't need the login page in this case
return (
<Admin
authProvider={authProvider}
dataProvider={dataProvider}
title="Example Admin"
loginPage={false} // We don't need the login page in this case
>
<Resource name="posts" {...posts} />
</Admin>
);
</Admin>
);
};
export default App;
```
Expand All @@ -111,9 +111,9 @@ import { LoginForm } from 'ra-auth-cognito';

export const MyLoginPage = () => {
return (
<>
<CssBaseline />
<Box>
<>
<CssBaseline />
<Box>
<Card>
<CardMedia
sx={{ height: 140 }}
Expand All @@ -122,11 +122,11 @@ export const MyLoginPage = () => {
<CardContent>
<LoginForm redirectTo="/" />
</CardContent>
</Card>
</Box>
</>
);
}
</Card>
</Box>
</>
);
};
```

## `useCognitoLogin`
Expand All @@ -141,29 +141,44 @@ import { PasswordSetupForm } from './PasswordSetupForm';

export const MyLoginPage = () => {
const [submit, { isLoading, requireNewPassword }] = useCognitoLogin({
redirectTo: '/'
redirectTo: '/',
});

return (
<>
<CssBaseline />
<Box>
<>
<CssBaseline />
<Box>
<Card>
<CardMedia
sx={{ height: 140 }}
image="/login_background.jpg"
/>
<CardContent>
{requireNewPassword
? <PasswordSetupForm onSubmit={submit} />
: <LoginForm onSubmit={submit} />
}
{requireNewPassword ? (
<PasswordSetupForm onSubmit={submit} />
) : (
<LoginForm onSubmit={submit} />
)}
</CardContent>
</Card>
</Box>
</>
);
}
</Card>
</Box>
</>
);
};
```

## Using the TOTP MFA

The library offers English and French translations for TOTP MFA pages. If you need other translations, have a look to the [ra-auth-cognito-language-french package](https://github.com/marmelab/ra-auth-cognito/tree/main/packages/ra-auth-cognito-language-french/).

## Customizing the application name using the TOTP MFA

By default, the library uses the `hostname` as the `applicationName`. If you want to define your own, add a second parameter to the `authProvider`, defining the `applicationName` you want:

```js
authProvider(cognitoConfig, {
applicationName: 'My Super App',
});
```

## Demo
Expand Down

0 comments on commit c5802f9

Please sign in to comment.