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

Align sync auth with other SDKs #1579

Closed
kneth opened this issue Dec 18, 2017 · 7 comments
Closed

Align sync auth with other SDKs #1579

kneth opened this issue Dec 18, 2017 · 7 comments

Comments

@kneth
Copy link
Contributor

kneth commented Dec 18, 2017

The current auth API is hard to new users to understand and use. I suggest that Realm JS is aligned with the other Realm SDKs.

  • The current methods (registerWithProvider, login) are deprecated and to be removed as soon as possible.
  • A new classRealm.Sync.Credentials is added. It will interface supported 3rd party provides, e.g., JWT, Google and Facebook.
  • Methods for logging in and and logging out are added to Realm.Sync.User.

An example:

credentials = Realm.Sync.Credentials.facebook(getFacebookToken())
Realm.Sync.User.login(credentials, "http://objectserver.realm.io/auth").then(user => {
    // user is now logged and and can open a Realm
}).catch(error => {
    // an error has occurred and be handled
})
@nirinchev
Copy link
Member

This could be related: #1571

@bigfish24
Copy link
Contributor

bigfish24 commented Dec 18, 2017

This is a good discussion to have since I think we should simplify the auth to just:

  1. Username/password
  2. JWT (custom)
  3. Anonymous

I think just having 1 method like authenticate or login would be sufficient to pass a credential and return a user.

@nirinchev
Copy link
Member

I'm not sure about that - if the goal is to allow people to bootstrap quickly, the JWT flow isn't exactly ideal. It requires writing code to issue my own tokens and hosting this on another service. If I already have that in place, great, but if I don't, it's fairly annoying.

@kneth
Copy link
Contributor Author

kneth commented Dec 19, 2017

@bigfish24 I would assume that Facebook and Google auth are important in a React Native context?

@nirinchev Will credentials = Realm.Sync.Credentials.JWT(getJWTToken()) make it harder to get started with JWT?

@nirinchev
Copy link
Member

What would getJWTToken do? I think the main obstacle for getting started with JWT is simply the fact you have to host your own server/service that exposes some http API to login and returns a signed JWT. None of that is hard per se, it's more of a hassle to do it - you have to sign up with a cloud provider, provision a server or an application that hosts your logic, provision ssl certificates, etc. In any case, that doesn't tie directly to our SDKs - once you have that token issued, passing it to Realm is fairly easy and the Credentials-based API is straightforward enough and aligned with other SDKs.

@kneth
Copy link
Contributor Author

kneth commented Dec 19, 2017

getJWTToken() is the main obstacle you refer to 😄 - I just leave it as an exercise for the reader.

I agree that we shouldn't duplicate effort (#1571).

@kneth
Copy link
Contributor Author

kneth commented Sep 21, 2018

I close this as #2002 has been merged and released.

@kneth kneth closed this as completed Sep 21, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants