What’s the user flow for users that want to authenticate with an identity from application “B”?
To they go to application “B” and then get a link to your application? Or do they go directly to your application?
If your application is capable, by any mean (e.g. a query string parameter or a referrer header) of knowing where the user is coming, you could pass that information to the hosted login page as a parameter.
Then, in the hosted login page, you could use that parameter to specify the connection to be used by Lock (with the allowedConnections
parameter).
If it’s not possible to know that in advance, another option is to present a UI in the hosted login page prior to displaying Lock, where you give users the choice (e.g. "click here to log in using the identity from app “B” or here to log in using the identity from app “A”).
Would any of these paths help?