Hmmh. You could set up one app as the single source of truth and then write a very simple API on this server to authenticate users.
Like this:
import { Accounts } from 'meteor/accounts-base';
...
Meteor.startup(() => {
Accounts.registerLoginHandler("custom", (loginRequest) => {
if(!loginRequest.custom) return undefined;
...
const username = loginRequest.user;
const password = loginRequest.password;
...
//do auth stuff here against your single source of truth like
const result = HTTP.call("GET", "https://authserver.foo/auth",
{
auth: `${username}:${password}`
}
);
...
//if successfully authed
const servicename = "foo";
const serviceData = {
id: username,
//add more data if you wish
}
return Accounts.updateOrCreateUserFromExternalService(
serviceName,
serviceData
)
}
}
That’s the server code for the other apps. The https://authserver.foo/auth endpoint you have to write yourself (and probably also one for changing password, adding/removing users)
On the clients you then define this function:
import { Accounts } from 'meteor/accounts-base';
...
const tryToLogin = (user, pass, callback) => {
const loginRequest = {
custom: true,
user: user,
password: pass
}
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: callback
});
}
}
and you actually call it like this (like in an event handler for a form submit):
tryToLogin(username, password, (err, res) => {
if(err) {
//deal with the error, likely a wrong user/pass
} else {
//logged in successfully, deal with that
}
})
This is a very barebones solution, though and doesn’t deal with edge cases.
It’s basically an abbreviated OAuth variant - you do not need to go full OAuth because you fully control all the servers you’re talking to.
Edit: And, yeah, don’t use the accounts-password package if you want to implement this.