Skip to content

Commit

Permalink
Strapi v5 (#72)
Browse files Browse the repository at this point in the history
* Strapi v5 compatibility (#59)

* strapi v5 compatibility

* refactor: changed from commonjs to module

* V5/compatible (#61)

* Fix admin panel path

* Translation bug fixes

* Fix webhook in create.entry

* Pre-release adjustments (#62)

* Allow nodejs 22 (#69)

Strapi 5 supports nodejs 20 and 22.

* NodeJS support version upgrade (#70)

* Feature/whitelist (#71)

* whitelist implementation

* update README

* v1.0.1 to the latest version

* fixing DOM errors

---------

Co-authored-by: Marco Fincato <[email protected]>
Co-authored-by: Jorrit Schippers <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2025
1 parent 63e293c commit 54b16c5
Show file tree
Hide file tree
Showing 46 changed files with 16,766 additions and 10,776 deletions.
13 changes: 0 additions & 13 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
.idea
dist
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,43 @@

This plugin can provide single sign-on.

You will be able to log in to the administration screen using one of the following providers:
- Google
You will be able to log in to the administration screen using one of the following providers:

- Google
- Cognito
- Azure
- OIDC

Currently supports Cognito user pool, Google accounts and OIDC.

Please read the [documents](#user-content-documentationenglish) for some precautions.

**This plugin is developed by one engineer.**
**If possible, consider using the Gold Plan features.**

# Version

| NodeJS | Strapi | strapi-plugin-sso |
|-----------------|--------|-------------------|
| 16.0.0 - 21.0.0 | v4 | 0.\*.\* |
| 18.0.0 - 22.0.0 | v5 | 1.\*.\* |

# Easy to install

```shell
yarn add strapi-plugin-sso
```

or

```shell
npm i strapi-plugin-sso
```

# Requirements
- Strapi Version4

- **strapi-plugin-sso**
- Google Account or AWS Cognito UserPool or a OIDC provider

# Example Configuration

```javascript
// config/plugins.js
module.exports = ({env}) => ({
Expand All @@ -48,7 +57,7 @@ module.exports = ({env}) => ({
GOOGLE_OAUTH_REDIRECT_URI: 'http://localhost:1337/strapi-plugin-sso/google/callback', // URI after successful login
GOOGLE_ALIAS: '', // Gmail Aliases
GOOGLE_GSUITE_HD: '', // G Suite Primary Domain

// Cognito
COGNITO_OAUTH_CLIENT_ID: '[Client ID created in AWS Cognito]',
COGNITO_OAUTH_CLIENT_SECRET: '[Client Secret created in AWS Cognito]',
Expand All @@ -65,27 +74,27 @@ module.exports = ({env}) => ({

// OpenID Connect
OIDC_REDIRECT_URI: 'http://localhost:1337/strapi-plugin-sso/oidc/callback', // URI after successful login
OIDC_CLIENT_ID: '[Client ID from OpenID Provider]',
OIDC_CLIENT_ID: '[Client ID from OpenID Provider]',
OIDC_CLIENT_SECRET: '[Client Secret from OpenID Provider]',

OIDC_SCOPES: 'openid profile email', // https://oauth.net/2/scope/
// API Endpoints required for OIDC
OIDC_AUTHORIZATION_ENDPOINT: '[API Endpoint]',
OIDC_AUTHORIZATION_ENDPOINT: '[API Endpoint]',
OIDC_TOKEN_ENDPOINT: '[API Endpoint]',
OIDC_USER_INFO_ENDPOINT: '[API Endpoint]',
OIDC_USER_INFO_ENDPOINT_WITH_AUTH_HEADER: false,
OIDC_GRANT_TYPE: 'authorization_code', // https://oauth.net/2/grant-types/
// customizable username arguments
OIDC_FAMILY_NAME_FIELD: 'family_name',
OIDC_GIVEN_NAME_FIELD: 'given_name',

USE_WHITELIST: true // allow authentication only at the specified email address.
}
}
})
```

# Support
- ✅ NodeJS >=16.0.0 <21.0.0
- Strapi 4.1.7 or higher
Of the above, the environment variable for the provider you wish to use is all that is needed.

# Documentation(English)

Expand All @@ -99,7 +108,10 @@ module.exports = ({env}) => ({

[OIDC Single Sign On Setup](https://github.com/yasudacloud/strapi-plugin-sso/blob/main/docs/en/oidc/setup.md)

[whitelist](https://github.com/yasudacloud/strapi-plugin-sso/blob/main/docs/whitelist.md)

# Documentation(Japanese)

[Description](https://github.com/yasudacloud/strapi-plugin-sso/blob/main/docs/README.md)

[Google Single Sign On Setup](https://github.com/yasudacloud/strapi-plugin-sso/blob/main/docs/ja/google/setup.md)
Expand All @@ -115,4 +127,5 @@ TODO AzureAD Single Sign On Setup
TODO OIDC Single Sign On Setup

# Demo

![CognitoDemo](https://github.com/yasudacloud/strapi-plugin-sso/blob/main/docs/demo.gif?raw=true "DemoMovie")
52 changes: 52 additions & 0 deletions admin/src/components/AlertMessage/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {Alert} from "@strapi/design-system";
import getTrad from "../../utils/getTrad";
import React from "react";
import {useIntl} from "react-intl";
import styled from "styled-components";

const AlertMessage = styled.div`
margin-left: -250px;
position: fixed;
left: 50%;
top: 2.875rem;
z-index: 10;
width: 31.25rem;
`

export function SuccessAlertMessage({onClose}) {
const {formatMessage} = useIntl();
return (
<AlertMessage>
<Alert
title="Success"
variant={'success'}
closeLabel={''}
onClose={onClose}
>
{formatMessage({
id: getTrad('page.save.success'),
defaultMessage: 'Updated settings'
})}
</Alert>
</AlertMessage>
)
}

export function ErrorAlertMessage() {
const {formatMessage} = useIntl();
return (
<AlertMessage>
<Alert
title="Error"
variant={'danger'}
closeLabel={''}
onClose={onClose}
>
{formatMessage({
id: getTrad('page.save.error'),
defaultMessage: 'Update failed.'
})}
</Alert>
</AlertMessage>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import pluginId from '../../pluginId';

const Initializer = ({ setPlugin }) => {
Expand All @@ -19,8 +18,4 @@ const Initializer = ({ setPlugin }) => {
return null;
};

Initializer.propTypes = {
setPlugin: PropTypes.func.isRequired,
};

export default Initializer;
File renamed without changes.
80 changes: 80 additions & 0 deletions admin/src/components/Role/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {
Button,
Checkbox,
Table,
Thead,
Tbody,
Tr,
Td,
Th,
} from '@strapi/design-system';
import getTrad from "../../utils/getTrad";
import React from "react";
import styled from "styled-components";
import {useIntl} from "react-intl";

const ButtonWrapper = styled.div`
margin: 10px 0 0 0;
& button {
margin: 0 0 0 auto;
}
`
const Description = styled.p`
font-size: 16px;
margin: 20px 0;
`

export default function Role({ssoRoles, roles, onSaveRole, onChangeRoleCheck}) {
const {formatMessage} = useIntl();
return (
<>
<Table colCount={roles.length + 1} rowCount={ssoRoles.length}>
<Thead>
<Tr>
<Th>
{/* Not required, but if it doesn't exist, it's an error. */}
<Checkbox style={{display: 'none'}}/>
</Th>
{
roles.map(role => (
<Th key={role['id']}>
{role['name']}
</Th>
))
}
</Tr>
</Thead>
<Tbody>
{
ssoRoles.map((ssoRole) => (
<Tr key={ssoRole['oauth_type']}>
<Td>{ssoRole['name']}</Td>
{
roles.map((role) => (
<Th key={role['id']}>
<Checkbox
checked={ssoRole['role'] && ssoRole['role'].includes(role['id'])}
onCheckedChange={(value) => onChangeRoleCheck(value, ssoRole['oauth_type'], role['id'])}
>{''}</Checkbox>
</Th>
))
}
</Tr>
))
}
</Tbody>
</Table>
<Description>{formatMessage({
id: getTrad('page.notes'),
defaultMessage: 'This will not be reflected for already registered users.'
})}</Description>
<ButtonWrapper>
<Button variant='default' onClick={onSaveRole}>{formatMessage({
id: getTrad('page.save'),
defaultMessage: 'Save'
})}</Button>
</ButtonWrapper>
</>
)
}
Loading

0 comments on commit 54b16c5

Please sign in to comment.