News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF external API

Started by danielrichter, February 04, 2021, 08:30:47 AM

Previous topic - Next topic

danielrichter

I've implemented a function to register a user / login / logout a user by ID inside the SSI.php.
Because my main application takes care of the whole registration process of a user the registration of a user for SMF board should be handled by API too.

This leads to the following questions:


  • Because my own application and SMF itself are running on different subdomains on different machines, is there any chance to "share" data by using a cache like redis for example?
  • How can I protect my modified SSI.php file to make sure API calls are somehow authorized? By this I mean, when a user is signed in to my own application the user should be logged into SMF too, how can I make sure the API call to SSI.php is authorized, any ideas?

Think my type of setup (different machine for board and main application) makes this topic a bit harder.

Kindred

SSI and API are different things....

SSI merely enables one to use SMF functions and data on external systems.


In order to do an API, it's more complicated (and you really shouldn't use SSI for that)
There *WAS* this -- but it broke somewhere around 2.0.15 and no one ever fixed it.
https://www.simplemachines.org/community/index.php?topic=458832.0
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

danielrichter

@Kindred thanks.
Think I'll build a simple API myself, using my already edited SSI.php on the SMF machine.

Any idea how I can set the cookies, because the API call (to the modified SSI.php) would be made from my main application itself, cookies will not be available for the client triggering the API call.
Hope you understand what problem I mean.

Kindred

there's no chance to share a database connection?

this user made a bridge between SMF and Joomla that shares the connection info...
https://www.simplemachines.org/community/index.php?topic=563225.msg4029974#msg4029974
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

danielrichter

@Kindred, database connection is possible, will this make the process a bit easier, feel free to explain.

All the best;

Kindred

So, it's been years since I was integrating joomla with SMF, and I was only a user at that point, not the developer -- but IIRC, there were some options

1- do a background sync to sync the user list between the originating system and SMF.

or

2- check each time a user connects...

when a user connects to the Forum, you pass some information. (e.g. username & email address) via the bridge
check the SMF database to see if that user exists
if user does not exist, check the originating database and grab info - write it to the SMF members table using the smf register new user function - if I recall, you can set a generic password because you are bypassing the normal SMF login function
if user does exist, mark the user as logged in -- can't recall if this was a direct "update log table" or if it was a login2 function with the username

turn OFF either disable the permission or literally comment out the code to remove all "edit profile" functions on SMF so the user can't accidentally change their information and redirect profile edit actions to point to the profile in the originating system rather than SMF (edit the action array in SMF's root index.php to point to an intermediary file/function which bounces)


a direct connection between the databases means that you can cut out some of the reliance of passing data and cookies, since, once the user is identified, the data which matched SMF needed information can be pulled from the originating database
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

danielrichter

@Kindred

Any idea how I can perform the "login" only by database access (since SMF is running on another machine)?
Any details about this (what lines of code, etc.)?
I'm unsure how to proceed, registration to database isn't hard but on the login / logout function I struggle.

Advertisement: