What is the expected behavior?
I want to add a new login provider.
There is no documentation about that, right?
Actually there is no documentation about this point.
Your provider is in this list ? https://github.com/simov/grant
No, I need to use the Grant - Custom Providers. 😞
"myProvider": {
"authorize_url": "[AUTHORIZE_URL]",
"access_url": "[ACCESS_URL]",
"oauth": 2,
"key": "[CONSUMER_KEY]",
"secret": "[CONSUMER_SECRET]",
"callback": "/handle_myProvider_callback"
}
Besides these files, what else do I need to modify? Something escapes me.
plugins/users-permissions/admin/src/components/PopUpForm/index.js
plugins/users-permissions/admin/src/containers/HomePage/data.json
plugins/users-permissions/admin/src/translations/en.json
plugins/users-permissions/config/functions/bootstrap.js
plugins/users-permissions/services/Providers.js
You can check in plugins/users-permissions/controllers/Providers.js L.130 (connect action) if the grant middleware is correctly setup when you try to connect with /connect/myProvider
@lauriejim I can't find this file:

Hi, @abdonrd
did you work out how to add a Grant Custom Provider to strapi yet?
I also need to add a Custom Provider to the strapi backend.
I got the same code structure as you in dir plugins/users-permissions/controllers
and i only find this in the strap document for how to enable the provider.
https://strapi.io/documentation/guides/authentication.html#providers
can anyone give any suggestion ?
@abdonrd Sorry it's Auth.js file.
@zhuang17 not yet! 😕
@lauriejim the grantConfig constant from the connect function:
it doesn't have my new provider (called newProvider):

@lauriejim these are my current changes:
https://github.com/abdonrd/strapi-demo/compare/new-provider?expand=1
@abdonrd
did you add your custom provider (ibm) to the auth providers of grant in DB ?
you may first need to add some code in plugins/users-permissions/config/functions/bootstrap.js to add the custom provider config.
@zhuang17 I have not changed anything in the DB. These are my current changes:
https://github.com/abdonrd/strapi-demo/compare/new-provider?expand=1
@abdonrd
that bootstrap.js code will only store grant values into db when the first time setup the db.
That code will not do merge providers and save into db if you add one grant provider there.
unless you create a new db to setup.
or I guess you could add custom code after https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-users-permissions/config/functions/bootstrap.js#L81
this will make sure you new provider information will be writen into db when you restart server.
const grantProviders = await pluginStore.get({key: 'grant'})
if (grantProviders && !grantProviders.myProvider) {
const mergedGrantProviders = {
...grantProviders,
myProvider: {
enabled: false,
icon: 'some icon',
"authorize_url": "[AUTHORIZE_URL]",
"access_url": "[ACCESS_URL]",
"oauth": 2,
"key": "[CONSUMER_KEY]",
"secret": "[CONSUMER_SECRET]",
"callback": "/handle_myProvider_callback"
}
}
await pluginStore.set({key: 'grant', value: mergedGrantProviders});
}
@zhuang17 Oh! I had not realized that! I will try wiht a new database.
Hello,
Have you found any solution to do it, i'm facing the same problem
Thank you
@adneneBen,
i suggest you can reference to abdonrd’s demo here,
https://github.com/abdonrd/strapi-demo/compare/new-provider?expand=1
and pay a attention to the bootstrap code here when you are using grant.
https://github.com/strapi/strapi/issues/891#issuecomment-380404414
you can integrate with other auth provider (no matter based on grant or not)
@lauriejim
for now we have to add some code directly into the plugin code when adding new auth provider.
it maybe a little troublesome when we upgrade the strap version.
(when we upgrade to new version, we will need to install the new user_permission plugin code into the old codebase, which means we will need to merge our code change with the changes of the user_permission plugin itself. please correct me if i missed anything here)
do you have any suggestion to separate those code, or make it easier to manage ?
Hi @zhuang17 you are right, the migration process is really not optimized and the experience it not good! It's one of big things we have to improve in Strapi.
Actually nop, I haven't solution for that.
Hey @abdonrd what's the state of this issue ?
Next week I'll try to try again with the information in this issue.
But anyway, I guess it's still missing documentation.
Okay great :)
@abdonrd any update on this? (Just trying to help clear up old issues)
I did not manage to make it work well. Also related with #927.
Anyway, to my knowledge, the process is still not documented anywhere.
An even better option would be to give the option to add a custom provider from the administration panel.
On the other hand, I did manage to make an example work with Grant & Koa with this configuration:
"customprovider": {
"authorize_url": "[AUTHORIZE_URL]",
"access_url": "[ACCESS_URL]",
"oauth": 2,
"key": "[CONSUMER_KEY]",
"secret": "[CONSUMER_SECRET]",
"callback": "/handle_customprovider_callback",
"scope": ["openid"]
}
Also, in the /handle_customprovider_callback I get the user profile directly from the JWT.
@lauriejim if our provider is that list, what would be the easiest way to add them to Strapi? In my case I would like to add Discord.
(The Grant list you provided near the top of the thread)
Same boat here but my situation is a quite a lot worse as I need SAML + ADFS. "Luckily" as i understood strapi to be very much an alpha product and doesn't (yet) do decent enough auth/authorisation for our needs we simply route all API calls needed via a proxy which adds the missing bits.
Adding these 3 PRs here (two of which have been merged) as examples on adding a new provider:
Discord: https://github.com/strapi/strapi/pull/1664
Microsoft: https://github.com/strapi/strapi/pull/1613
(Not Merged yet) Twitch: https://github.com/strapi/strapi/pull/1616
If someone can update the documentation file https://github.com/strapi/strapi/edit/master/docs/3.x.x/en/guides/authentication.md by adding step to add new provider, based on PR linked by @derrickmehaffy
Will appreciate community contribution on this point.
If no one is already on it I will start working on it by tomorrow.
@avallete I don't think anyone has started work on the documentation, so your help would be great :smile:
PR has been made.
Writing it done really made me think that we could use some refactoring on this code allowing to add 'provider as plugin'. This would make integration and test of new providers more atomic and easy.
Maybe it would be worthy to open a issue about this point ?
@avallete I completely agree with this. @Aurelsicoko thoughts?
I'm completely agree @avallete. Like upload and email providers.
You can open an issue about your proposal.
💯 , we should definitely do this!
@opgbaudouin Can you please explain further what missing bits did you add to Strapi via Proxy? Because I'm also in the same boat as you and unable to figure out in Strapi way possible.
@rahilwazir : I'm afraid i had to give up on Strapi (at this point). Great as it is for simple things quickly ran out of needed 'security' features (per field security permissions). I used an external server to handle the ADFS handling and created a new account on strapi that would have those permissions. Effectively faking a register/login to strapi server side. I.e. proxying it - after you get the JWT you can go back to normal.
@opgbaudouin Thank you. In my case, I don't need to handle ADFS. It's just SAML 2.0 (OKTA idP). I have opened a new issue to further discuss SAML integration in Strapi. Let's discuss there if you are interested.
+1 for SAML provider. https://github.com/simov/grant only supports OAuth provider.
Getting hung up starting to try this and I'm wondering if something changed in newly generated Strapi projects since the guide was written. The guide describes making changes to files in the directory packages/strapi-plugin-users-permissions, which I see in the Strapi repo, but there's nothing along those lines in my generated project. Is there a step I'm missing?
Most helpful comment
Getting hung up starting to try this and I'm wondering if something changed in newly generated Strapi projects since the guide was written. The guide describes making changes to files in the directory
packages/strapi-plugin-users-permissions, which I see in the Strapi repo, but there's nothing along those lines in my generated project. Is there a step I'm missing?