API endpoint allowing users to authenticate in Firebase using Wordpress details.
This is an API endpoint which is used by BRCS - Bot Remote Control System.
It allows to authenticate users in Firebase
with Wordpress
details (using jwt
).
If user doesn't exist in Firebase
it will be created first and then authenticated.
It works one-way-only so it creates and authenticates users from Wordpress
in Firebase
(doesn't work vice-versa yet).
In general what I wanted to achieve and what I actually achieved using this:
Wordpress Woocommerce
online shop and wanted users from mobile app to have exactly the same authentication database as users from online shopWordpress
database, but users using mobile app were authenticated by Wordpress
first, then "copied" over to Firebase
auth and then logged in to mobile app using Firebase
SDKYou are thinking.. why not Wordpress
only? Because I love Firebase
features for mobile apps!
pm2
for auto-restarting, deployment and auto-scaling404
for bots and crawlers)cloudflare
protection/fb/status
=> GET
/fb/auth
=> POST
=> format: {"username":"test","password":"test"}
WP REST API V2
enabledI will be honest here. There may be some steps missing so you will have to figure it out yourself (I've stopped using it because mobile app which uses it is not developed anymore).
npm install --g babel-cli pm2
npm install
./keys/server.crt
&& ./keys/server.key
=> generate your own keys./serviceAccountKey.json
=> get whole file from Firebase
project./newrelic.js
./ecosystem.config.js
./dev_ecosystem.config.js
./settings.js
./package.json
=> modify name of your app (if changed) in pre-defined commandspm2
on your deployment machine (pm2 link
)pmx monitor
on deployment machine:Wordpress
on same machine with Login API
)
pm2 install pm2-server-monit
pm2 install pm2-php-fpm
pm2 install pm2-memcached
pm2 install pm2-mysql
pm2 install pm2-slack
pm2 install pm2-logrotate
2096
for API and 43554
for pmx monitor
in my case)cloudflare
caching (somewhere on theirs website in domain settings)pm2 deploy ecosystem.config.js dev setup
pm2 deploy ecosystem.config.js prod
pm2 save
You can do all these steps above with one command npm run pm2devcleandeploy
or if you already did setup you can do npm run pm2devdeploy
.
You can also remotely destroy already running instances with: npm run pm2devdeploydestroy
and read logs using npm run pm2devdeploylogs
or clean them up with npm run pm2devdeploycleanup
.