Giter Site home page Giter Site logo

strapi-plugin-sso-azure-ad-basic's Introduction

Strapi plugin sso-azure-ad-basic

NPM version Build Status NPM Downloads MIT License

This is an updated fork of the original Strapi plugin.

This is a basic plugin using Azure Active Directory identity for Single Sign On (SSO). The configurations are controlled by environment variables inside .env file.

How it works

Normally you get the token to authenticate and authorize your app to access Azure services. Can I use it to authorize Strapi services? Yes by using azure token to authenticate a user in Strapi. The idea is to map Azure AD roles with the Strapi roles. If the role match then the user will be authenticated and it will return Strapi generated JWT token as if the user logs in. This works even if the user is not yet created. If authenticated and the role match the user will be created automatically. If the user already exist, the user information will be updated. This way you can use it to authorize Azure services at the same time authorize your own Strapi services by either using the Strapi token or the azure token.

To authenticate, use the returned token as parameter. After authenticated, it will still use the Strapi jwt token since you are just accessing its internal APIs.

This will work both for admin and API users.

For API users, in the client pass the azureToken (token returned after logging in from Azure) to /verifyTokenAPIUser endpoint.

Supported Strapi versions

Strapi v3.6.x and above

Installation

npm install @ndigitals/strapi-plugin-sso-azure-ad-basic --save

or

yarn add @ndigitals/strapi-plugin-sso-azure-ad-basic

Configuration/Setup

Inside plugin strapi-files copy admin to admin/ project root directory and copy hooks.js to Strapi config. Also copy the hooks folder to the Strapi root directory. If the folders already exist, only copy the files or code that are missing.

Setup up environment variables

Create .env if not yet available on the project root directory

Add the following variables:

AZURE_AD_ROLE_MAPPING=[{"azureRole":"Application Administrator","strapiRole":"Super Admin"},{"azureRole":"Application Developer","strapiRole":"Technologist"}]
AZURE_AD_ROLE_MAPPING_API_USERS=[{"azureRole":"Application Administrator","strapiRole":"Authenticated"}]
AZURE_AD_CLIENT_ID=57e34ea2-2dae-4445-b7dc-5320cdfc969c
AZURE_AD_REDIRECT_URL=http://localhost:8000/admin/auth/login

Note that AZURE_AD_ROLE_MAPPING and AZURE_AD_ROLE_MAPPING_API_USERS is a string representation of an array of objects

It is required that you map your Strapi roles to the corresponding role from Azure AD.

Copy hooks file and folder

This will make sure that the verifytoken and verifytokenapiuser api is public

Build and run your project

npm run build && npm run develop

or

yarn build && yarn develop

strapi-plugin-sso-azure-ad-basic's People

Contributors

timnolte avatar dependabot[bot] avatar

Stargazers

Harvey Gomez avatar

Watchers

 avatar

strapi-plugin-sso-azure-ad-basic's Issues

Support for Node 18

Hi,

When trying to install this package in a Strapi project with the command shown in the README using Node 18 I get the following error in the terminal:

npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "=>3.6.0" of package "@strapi/strapi@=>3.6.0": Tags may not have any characters that encodeURIComponent encodes.

If I downgrade to Node 14 then I can install the package but not with version 18.
Is it possible to add support for this now that 14 is end of life and 16 is about to end support? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.