Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

approach to link existing local accounts with oauth2 #661

Closed
rpisarew opened this issue Aug 27, 2017 · 5 comments
Closed

approach to link existing local accounts with oauth2 #661

rpisarew opened this issue Aug 27, 2017 · 5 comments

Comments

@rpisarew
Copy link

Have any one an approach or tips, how to link local accounts with oauth2?

@rpisarew
Copy link
Author

I found this in the default verifier:

verifier.js

      // Check request object for an existing entity
      if (req && req[options.entity]) {
        existing = req[options.entity];
      }

      // Check the request that came from a hook for an existing entity
      if (!existing && req && req.params && req.params[options.entity]) {
        existing = req.params[options.entity];
      }

      // If there is already an entity on the request object (ie. they are
      // already authenticated) attach the profile to the existing entity
      // because they are likely "linking" social accounts/profiles.
      if (existing) {
        return this._updateEntity(existing, data).then(function (entity) {
          return done(null, entity);
        }).catch(function (error) {
          return error ? done(error) : done(null, error);
        });
      }

It looks like it do this what i want, but the problem are the cookies.
My backend doesn't recognize my login, because the cookie is on the frontend domain (localhost:8000) and my backend runs on localhost:3030.

Frontend:

Proxy section of my server.js

app.use('/auth', proxy({
  target: process.env.BACKEND_URL || 'http://localhost:3030',
  changeOrigin: true
}))

Backend:

  • Host: localhost
  • Port: 3030

Have any one a solution for that? Or how u handle your cookies with a separate backend?

@claustres
Copy link
Contributor

Section 4 in https://blog.feathersjs.com/how-to-setup-oauth-flow-with-featherjs-522bdecb10a8 might help. If everything is setup correctly this should work, I guess you might have mixed front/back URLs in your OAuth2 provider and app configs.

@rpisarew
Copy link
Author

@claustres
Thank you for the link, they mention the same problem in the 'Cross-domain issue' section and they give two approaches for that. I will try it :)

@daffl
Copy link
Member

daffl commented Aug 28, 2018

With cookies enabled and the existing JWT set as feathers-jwt in the cookie, account linking is now possible with @feathersjs/authentication-jwt@^2.0.0 and @feathersjs/authentication-oauth@^1.2.0.

@daffl daffl closed this as completed Aug 28, 2018
@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants