Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS Cognito provider #6917

Merged
merged 28 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7204dde
Adding support to for grant object subdomain property assignment
ralphsomeday Jul 6, 2020
9e35d1a
Adding instructions on how to configure a customer provider subdomain
ralphsomeday Jul 6, 2020
bb2ff5a
[strapi] pass the subdomain from grantConfig
JiboStore Sep 8, 2020
c0406f9
Merge pull request #1 from JiboStore/master
ralphsomeday Sep 8, 2020
9f9ef94
removing section about subdomain for auth provider to add the change …
ralphsomeday Sep 8, 2020
45485b6
Adding the right custom property 'cognito host' + updating the docume…
ralphsomeday Sep 8, 2020
2058eec
Changing amazon icon to aws as the amazon login provider is different…
ralphsomeday Sep 9, 2020
2bebc61
Removed env var for cognito host subdomain and added an extra subdoma…
ralphsomeday Sep 22, 2020
2df2a62
solving merge conflicts
ralphsomeday Sep 28, 2020
64dfe7d
commit to solve some merge conflicts
ralphsomeday Sep 28, 2020
1b077fc
solving merge conflicts
ralphsomeday Sep 28, 2020
f409dfa
Merge branch 'master' into master
ralphsomeday Sep 28, 2020
48ac474
Adding AWS Cognito provider configuration and key in all language fil…
ralphsomeday Sep 28, 2020
a4a531f
Adding AWS Cognito provider configuration and key in all language fil…
ralphsomeday Sep 28, 2020
36a8a4e
Merge branch 'master' of https://github.com/ralphsomeday/strapi
ralphsomeday Sep 28, 2020
233e5d2
Merge branch 'master' into master
alexandrebodin Sep 29, 2020
d46881f
Merge branch 'master' into master
ralphsomeday Sep 29, 2020
d26ecf4
adding subdomain to aws cognito provider+only showing the subdomain p…
ralphsomeday Sep 29, 2020
278f790
fixing some warnings and react errors that came out from the travis b…
ralphsomeday Sep 30, 2020
09fa46f
fixing lint issue
ralphsomeday Sep 30, 2020
c6498ac
Taking into account feedback from soupette
ralphsomeday Sep 30, 2020
f72bb80
Updating code to take into account soupette feedback
ralphsomeday Sep 30, 2020
1dfd824
Merge branch 'master' into master
ralphsomeday Oct 3, 2020
a3b94a7
Updating documentation with AWS Cognito provider configuration in use…
ralphsomeday Oct 3, 2020
63a6cfc
Updating doc using Pierre feedback and adding a provider for aws cogn…
ralphsomeday Oct 5, 2020
e8fe42c
Merge branch 'master' into master
ralphsomeday Oct 5, 2020
f8efa5d
Updating the redirect URL to the front-end app
ralphsomeday Oct 5, 2020
ef0fc1f
Merge branch 'master' into master
petersg83 Oct 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/v3.x/plugins/users-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,42 @@ Wait a few seconds while the application is created.

:::

::: tab AWS Cognito

#### Using ngrok

AWS Cognito accepts the `localhost` urls. <br>
The use of `ngrok` is not needed.

#### AWS Cognito configuration

- Visit the AWS Management Console <br> [https://aws.amazon.com/console/](https://aws.amazon.com/console/)
- If needed, select your **Region** in the top right corner next to the Support dropdown
- Select the **Services** dropdown in the top left corner
- Click on **Cognito** in the `Security, Identity & Compliance` section
- Then click on the **Manage User Pools** button
- If applicable either create or use an existing user pool. You will find hereafter a tutorial to create a User Pool <br> [https://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-create-user-pool.html](https://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-create-user-pool.html)
- Go to the **App clients** section in your cognito user pool and create a new client with the name `Strapi Auth` and set all the parameters and then click on **Create app client**
- You should now have an **App client id** and by clicking on the button **Show Details** you will be able to see the **App client secret**. Do copy those two values **App client id** and **App client secret** somewhere for later use when configuring the AWS Cognito provider in Strapi.
- Go to the **App integration section** and click on **App client settings**
- Look for your app client named `Strapi Auth` and enable Cognito User Pool by checking it in the **Enabled Identity Providers** section of your newly created App client
- Fill in your callback URL and Sign out URL with the value `http://localhost:1337/connect/cognito/callback` or the one provided by your AWS Cognito provider in Strapi
- In the **Oauth 2.0** section select `Authorization code grant` and `Implicit grant` for the **Allowed OAuth Flows** and select `email`, `openid` and `profile` for the **Allowed OAuth Scopes**
- You can now click on **Save changes** and if you have already configured your domain name then you should be able to see a link to the **Launch Hosted UI**. You can click on it in order to display the AWS Cognito login page. In case you haven't yet configured your domain name, use the link **Choose domain name** at the bottom right of the page in order to configure your domain name. On that page you will have an `Amazon Cognito Domain` section where a `Domain prefix` is already setup. Type a domain prefix to use for the sign-up and sign-in pages that are hosted by Amazon Cognito, this domain prefix together with the `.auth.YOUR_REGION.amazoncognito.com` will be the **Host URI (Subdomain)** value for your strapi configuration later on.

ralphsomeday marked this conversation as resolved.
Show resolved Hide resolved
#### Strapi configuration

- Visit the User Permissions provider settings page <br> [http://localhost:1337/admin/settings/users-permissions/providers](http://localhost:1337/admin/settings/users-permissions/providers)
- Click on the **Cognito** provider
- Fill the information (replace with your own client ID and secret):
- **Enable**: `ON`
- **Client ID**: fill in the **App client id** (`5bd7a786qdupjmi0b3s10vegdt`)
- **Client Secret**: fill in the **App client secret** (`19c5c78dsfsdfssfsdfhpdb4nkpb145vesdfdsfsffgh7vwd6g45jlipbpb`)
- **Host URI (Subdomain)**: fill in the URL value that you copied earlier (`myapp67b50345-67b50b17-local.auth.eu-central-1.amazoncognito.com`)
- **The redirect URL to your front-end app**: if you are using strapi react-login [https://github.com/strapi/strapi-examples/tree/master/login-react/](https://github.com/strapi/strapi-examples/tree/master/login-react/) use `http://localhost:3000/connect/cognito/redirect` but if you do not yet have a front-end app to test your Cognito configuration you can then use the following URL `http://localhost:1337/auth/cognito/callback`

:::

::: tab Twitter

#### Using ngrok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getYupInnerErrors,
request,
} from 'strapi-helper-plugin';
import { get, upperFirst } from 'lodash';
import { get, upperFirst, has } from 'lodash';
import { Row } from 'reactstrap';
import pluginPermissions from '../../permissions';
import { useForm } from '../../hooks';
Expand Down Expand Up @@ -52,6 +52,15 @@ const ProvidersPage = () => {
() => providers.filter(provider => provider.enabled).length,
[providers]
);
const isProviderWithSubdomain = useMemo(() => {
if (!providerToEditName) {
return false;
}

const providerToEdit = providers.find(obj => obj.name === providerToEditName);

return has(providerToEdit, 'subdomain');
}, [providers, providerToEditName]);
const disabledProvidersCount = useMemo(() => {
return providers.length - enabledProvidersCount;
}, [providers, enabledProvidersCount]);
Expand Down Expand Up @@ -80,8 +89,16 @@ const ProvidersPage = () => {
const pageTitle = formatMessage({ id: getTrad('HeaderNav.link.providers') });

const formToRender = useMemo(() => {
return providerToEditName === 'email' ? forms.email : forms.providers;
}, [providerToEditName]);
if (providerToEditName === 'email') {
return forms.email;
}

if (isProviderWithSubdomain) {
return forms.providersWithSubdomain;
}

return forms.providers;
}, [providerToEditName, isProviderWithSubdomain]);

const handleClick = useCallback(() => {
buttonSubmitRef.current.click();
Expand Down Expand Up @@ -159,7 +176,7 @@ const ProvidersPage = () => {
formToRender,
handleToggle,
modifiedData,
providerToEditName,
providerToEditName
]
);

Expand Down Expand Up @@ -218,13 +235,13 @@ const ProvidersPage = () => {
<Row>
{formToRender.form.map(input => {
const label = input.label.params
? { ...input.label, params: { provider: upperFirst(providerToEditName) } }
: input.label;
? { ...input.label, params: { provider: upperFirst(providerToEditName) } }
: input.label;

const value =
input.name === 'noName'
? `${strapi.backendURL}/connect/${providerToEditName}/callback`
: get(modifiedData, [providerToEditName, ...input.name.split('.')], '');
input.name === 'noName'
? `${strapi.backendURL}/connect/${providerToEditName}/callback`
: get(modifiedData, [providerToEditName, ...input.name.split('.')], '');

return (
<SizedInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { sortBy } from 'lodash';
const createProvidersArray = data => {
return sortBy(
Object.keys(data).reduce((acc, current) => {
const { icon: iconName, enabled } = data[current];
const { icon: iconName, enabled, subdomain } = data[current];
ralphsomeday marked this conversation as resolved.
Show resolved Hide resolved
const icon = iconName === 'envelope' ? ['fas', 'envelope'] : ['fab', iconName];

acc.push({ name: current, icon, enabled });
if (subdomain) {
ralphsomeday marked this conversation as resolved.
Show resolved Hide resolved
acc.push({ name: current, icon, enabled, subdomain });
} else {
acc.push({ name: current, icon, enabled });
}

return acc;
}, []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,103 @@ const forms = {
}),
}),
},
providersWithSubdomain: {
form: [
{
autoFocus: true,
label: getTrad('PopUpForm.Providers.enabled.label'),
name: 'enabled',
type: 'bool',
description: getTrad('PopUpForm.Providers.enabled.description'),
size: { xs: 6 },
validations: {
required: true,
},
},
{
autoFocus: false,
label: getTrad('PopUpForm.Providers.key.label'),
name: 'key',
type: 'text',
placeholder: getTrad('PopUpForm.Providers.key.placeholder'),
size: { xs: 12 },
validations: {
required: true,
},
},
{
autoFocus: false,
label: getTrad('PopUpForm.Providers.secret.label'),
name: 'secret',
type: 'text',
placeholder: getTrad('PopUpForm.Providers.secret.placeholder'),
size: { xs: 12 },
validations: {
required: true,
},
},
{
autoFocus: false,
label: getTrad('PopUpForm.Providers.subdomain.label'),
name: 'subdomain',
type: 'text',
placeholder: getTrad('PopUpForm.Providers.subdomain.placeholder'),
size: { xs: 12 },
validations: {
required: true,
},
},
{
autoFocus: false,
label: getTrad('PopUpForm.Providers.redirectURL.front-end.label'),
placeholder: 'http://www.client-app.com',
name: 'callback',
type: 'text',
size: { xs: 12 },
validations: {
required: true,
},
},
{
label: {
id: getTrad('PopUpForm.Providers.redirectURL.label'),
params: {
provider: 'VK',
},
},
name: 'noName',
type: 'text',
validations: {},
size: {
xs: 12,
},
disabled: true,
},
],
schema: yup.object().shape({
enabled: yup.bool().required(translatedErrors.required),
key: yup.string().when('enabled', {
is: true,
then: yup.string().required(translatedErrors.required),
otherwise: yup.string(),
}),
secret: yup.string().when('enabled', {
is: true,
then: yup.string().required(translatedErrors.required),
otherwise: yup.string(),
}),
subdomain: yup.string().when('enabled', {
is: true,
then: yup.string().required(translatedErrors.required),
otherwise: yup.string(),
}),
callback: yup.string().when('enabled', {
is: true,
then: yup.string().required(translatedErrors.required),
otherwise: yup.string(),
}),
}),
},
};

export default forms;
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"PopUpForm.Providers.secret.label": "سر العميل (Client Secret)",
"PopUpForm.Providers.secret.placeholder": "نص",
"PopUpForm.header.edit.email-templates": "تحرير قوالب البريد الإلكتروني",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "تم تحديث الإعدادات",
"plugin.description.long": "حماية الـAPI الخاص بك مع عملية مصادقة كاملة استناداً إلى JWT. يأتي هذا الملحق أيضًا مع إستراتيجية ACL التي تسمح لك بإدارة الأذونات بين مجموعات المستخدمين.",
"plugin.description.short": "حماية الـAPI الخاص بك مع عملية مصادقة كاملة استناداً إلى JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "Upravit e-mailové šablony",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Nastavení bylo aktualizování",
"plugin.description.long": "Chraňte své API pomocí kompletního autentifikačního procesu, založeného na JWT. Tento zásuvný modul obsahuje ACL strategii, která vám umožní spravovat oprávnění mezi skupinami uživatelů.",
"plugin.description.short": "Chraňte své API pomocí kompletního autentifikačního procesu, založeného na JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "E-Mail-Templates bearbeiten",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Einstellungen aktualisiert",
"plugin.description.long": "Beschütze deine API mit einem vollständigen Authentifikationsprozess basierend auf JWT. Zudem bietet dieses Plugin eine ACL-Strategie, die erlaubt, die Befugnisse zwischen Benutzergruppen festzulegen.",
"plugin.description.short": "Beschütze deine API mit einem vollständigen Authentifikationsprozess basierend auf JWT.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "Edit Email Templates",
"PopUpForm.header.edit.providers": "Edit Provider",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"Settings.roles.deleted": "Role deleted",
"Settings.roles.edited": "Role edited",
"Settings.section-label": "Users & Permissions plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"PopUpForm.Providers.secret.label": "Secreto Cliente",
"PopUpForm.Providers.secret.placeholder": "TEXTO",
"PopUpForm.header.edit.email-templates": "Editar Plantillas de Email",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Los ajustes se han actualizado",
"plugin.description.long": "Proteja su API con un proceso de autenticación completo basado en JWT. Este plugin viene también con una estrategia ACL que le permite administrar los permisos entre los grupos de usuarios.",
"plugin.description.short": "Proteja su API con un proceso de autenticación completo basado en JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "Editer E-mail Templates",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Les configurations ont bien été sauvegardés",
"plugin.description.long": "Protégez votre API avec un système d'authentification complet basé sur JWT (JSON Web Token). Ce plugin ajoute aussi une stratégie ACL (Access Control Layer) qui vous permet de gérer les permissions entre les groupes d'utilisateurs.",
"plugin.description.short": "Protégez votre API avec un système d'authentification complet basé sur JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "Modifica il template delle Email",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Impostazioni aggiornate",
"plugin.description.long": "Proteggi le tue API con un processo completo di autenticazione basato su JWT. Questo plugin è implementato con una strategia ACL che ti consente di gestire i permessi tra i gruppi di utenti.",
"plugin.description.short": "Proteggi le tue API con un processo completo di autenticazione basato su JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"PopUpForm.Providers.secret.label": "クライアントの秘密",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "メールテンプレートの編集",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "設定が更新されました",
"plugin.description.long": "JWTに基づいた完全な認証プロセスでAPIを保護します。このプラグインには、ユーザーのグループ間で権限を管理できるACL戦略もあります。",
"plugin.description.short": "JWTに基づく完全な認証プロセスでAPIを保護する",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"PopUpForm.Providers.secret.label": "클라이언트 시크릿(Client Secret)",
"PopUpForm.Providers.secret.placeholder": "텍스트",
"PopUpForm.header.edit.email-templates": "이메일 템플릿 수정",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "설정을 업데이트했습니다.",
"plugin.description.long": "JWT 기반의 인증 프로세스로 API를 보호하세요. 이 플러그인에서 사용자 그룹간 권한을 관리할 수 있는 ACL 전략도 설정할 수 있습니다.",
"plugin.description.short": "JWT 기반의 인증 프로세스로 API를 보호하세요.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEKS",
"PopUpForm.header.edit.email-templates": "Edit Templat E-mel",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Tetapan telah dikemas kini",
"plugin.description.long": "Lindungi API anda dengan proses pengesahan penuh berdasarkan JWT. Plugin ini juga dilengkapi dengan strategi ACL yang membolehkan anda mengurus pengizinan antara kumpulan pengguna.",
"plugin.description.short": "Lindungi API anda dengan proses pengesahan penuh berdasarkan JWT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"PopUpForm.Providers.secret.label": "Client Secret",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "E-mail sjablonen aanpassen",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Instellingen zijn geüpdatet",
"plugin.description.long": "Beveilig je API met een volledig authenticatie proces op JWT. Deze extensie komt ook met een ACL strategie welke ervoor zorgt dat je de permissies tussen groepen van gebruikers kan beheren.",
"plugin.description.short": "Beveilig je API met een volledig authenticatie proces op JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"PopUpForm.Providers.secret.label": "Klucz sekretny klienta",
"PopUpForm.Providers.secret.placeholder": "TEKST",
"PopUpForm.header.edit.email-templates": "Zmień szablony e-mail",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "Ustawienia zostały zaktualizowane",
"plugin.description.long": "Chroń API za pomocą procesu pełnego uwierzytelniania opartego na JWT. Ta wtyczka zawiera również strategię ACL, która pozwala zarządzać uprawnieniami między grupami użytkowników.",
"plugin.description.short": "Chroń API za pomocą procesu pełnego uwierzytelniania opartego na JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"PopUpForm.Providers.secret.label": "Segredo do Cliente",
"PopUpForm.Providers.secret.placeholder": "TEXT",
"PopUpForm.header.edit.email-templates": "Editar modelos de email",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "As configurações foram atualizadas",
"plugin.description.long": "Proteja sua API com um processo de autenticação completo baseado no JWT. Esse plugin também vem com uma estratégia de ACL que permite gerenciar as permissões entre os grupos de usuários.",
"plugin.description.short": "Proteja sua API com um processo de autenticação completo baseado no JWT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"PopUpForm.Providers.secret.label": "Segredo de cliente",
"PopUpForm.Providers.secret.placeholder": "TEXTO",
"PopUpForm.header.edit.email-templates": "Editar Modelos de Email",
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
"notification.success.submit": "As configurações foram atualizadas",
"plugin.description.long": "Proteja a sua API com um processo completo de autenticação baseado em JWT. Este plugin também vem com estratégia de ACL que permite gerir permissões entre grupos de utilizadores.",
"plugin.description.short": "Proteja a sua API com um processo completo de autenticação baseado em JWT",
Expand Down