How to add a new provider in users-permissions plugin in Strapi V4?

System Information
  • Strapi Version: 4.0.2
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I have the same question. Anyone any ideas? The documentation on Roles & Permissions - Strapi Developer Docs doesn’t seems to be working anymore (was working on v3)

I found a minimal way to extend users-permissions plugin:

Create users-permissions folder in src/extensions and go into the src/extensions/users-permissions/;
Create strapi-server.js;
Copy corresponding source code from plugin to server/index.js, fix the require files path except boostrap and services module;
Copy corresponding source code from plugin to server/bootstrap/index.js, fix the require files path and add / customize your provider here;
Copy corresponding source code from plugin to server/service/index.js, fix the require files path except providers module;
Copy corresponding source code from plugin to server/service/providers.js, fix the require files path and add / customize your provider here;

I will write a tutorial later.

@adriaanh Add a customize Users-Permissions provider for Strapi V4 | by smoothdvd | Feb, 2022 | Medium

1 Like

Thank you sir, very helpfull

Awesome, thanks. Will try it but it feels like there sho
uld be an easier way.

@adriaanh @Flosrn
Find a more easy way, according Plugins extension - Strapi Developer Docs

in src/extensions/users-permissions/strapi-server.js

'use strict';

module.exports = (plugin) => {
  plugin.bootstrap = require('./server/bootstrap');
  plugin.services['providers'] = require('./server/services/providers');
  return plugin;
};

No need ./src/extensions/users-permissions/server/index.js ./src/extensions/users-permissions/server/service/index.js.

Is there no way to add a new provider by calling the user-permissions provider-registry?

Should we be able to do something like this from our own plugin’s bootstrap.js?

module.exports = ({ strapi }) => {
// bootstrap phase
const registry = strapi.service(
“plugin::users-permissions.providers-registry”
);
registry.register(“new_provider”, () => new_provider_function);
};

i am using typescript with strapi v4, i can add apple provider into user permission pluggins ?