Giter Club home page Giter Club logo

Comments (10)

 avatar commented on May 27, 2024

I think this is probably related to issue #51 on sync_gateway, I have two DB's defined, everything works fine in guest mode but breaks with Persona auth on.

from couchbase-lite-ios.

 avatar commented on May 27, 2024

I'm going to close this issue and let it be handled over on the sync_gateway issue list under #51. If I have problems syncing with a single DB I'll raise a new issue here.

from couchbase-lite-ios.

snej avatar snej commented on May 27, 2024

CBL seems to be trying to access the /_session without the DB prefix.

That means you have an older version of CBL from before we moved the _persona endpoint on the server side.

from couchbase-lite-ios.

 avatar commented on May 27, 2024

Jens

Hi, I have something that claims to be a Person build, the framework header CBLReplication.h contains, I rebuilt the Framework twice as that was my first thought, I also visually checked that some of the latest mods were present.

I have moved to one DB now and I am getting a lot more traffic but still no Persona login, I'm still digging.

Andy

/** The base URL of the remote server, for use as the "origin" parameter when requesting Persona authentication. /
@Property (readonly) NSURL
personaOrigin;

/** Email address for remote login with Persona (aka BrowserID). This is stored persistently in
the replication document, but it's not sufficient for login (you also need to go through the
Persona protocol to get a signed assertion, which you then pass to the
-registerPersonaAssertion: method.)/
@Property (nonatomic, copy) NSString
personaEmailAddress;

/** Registers a Persona 'assertion' (ID verification) string that will be used on the next login to the remote server. This also sets personaEmailAddress.
Note: An assertion is a type of certificate and typically has a very short lifespan (like, a
few minutes.) For this reason it's not stored in the replication document, but instead kept
in an in-memory registry private to the Persona authorizer. You should initiate a replication
immediately after registering the assertion, so that the replicator engine can use it to
authenticate before it expires. After that, the replicator will have a login session cookie
that should last significantly longer before needing to be renewed. */

  • (bool) registerPersonaAssertion: (NSString*)assertion attribute((nonnull));

from couchbase-lite-ios.

snej avatar snej commented on May 27, 2024

Ah, I just noticed you said _session not _persona.

Looking at the code, CBLReplicator still access /_session to check for an existing login cookie. The sync gateway handles this endpoint as long as there's only a single db; but if there are multiple dbs it doesn't, because it's ambiguous which one is meant. Thus your error.

Crap, not sure what to do about this, since the replicator does need to be compatible with CouchDB as well. Let me think...

from couchbase-lite-ios.

 avatar commented on May 27, 2024

Could you provide an aggregate set of sessions on /_session (from all active DB's) assuming session ID's a GUIDS

from couchbase-lite-ios.

snej avatar snej commented on May 27, 2024

Here's a patch that will fall back to /db/_session if /_session isn't found. Could you try it out?

diff --git a/Source/CBL_Replicator.m b/Source/CBL_Replicator.m
index d1ae714..b8f34ad 100644
--- a/Source/CBL_Replicator.m
+++ b/Source/CBL_Replicator.m
@@ -484,14 +484,22 @@ NSString* CBL_ReplicatorStoppedNotification = @"CBL_ReplicatorStopped";
         [self fetchRemoteCheckpointDoc];
         return;
     }
+    [self checkSessionAtPath: @"/_session"];
+}

+- (void) checkSessionAtPath: (NSString*)sessionPath {
     // First check whether a session exists
     [self asyncTaskStarted];
     [self sendAsyncRequest: @"GET"
-                      path: @"/_session"
+                      path: sessionPath
                       body: nil
               onCompletion: ^(id result, NSError *error) {
                   if (error) {
+                      // CouchDB has /_session, but the Sync Gateway uses /db/_session
+                      if (error.code == kCBLStatusNotFound && $equal(sessionPath, @"/_session")) {
+                          [self checkSessionAtPath: @"_session"];
+                          return;
+                      }
                       LogTo(Sync, @"%@: Session check failed: %@", self, error);
                       self.error = error;
                   } else {

from couchbase-lite-ios.

 avatar commented on May 27, 2024

Jens

I can't do a complete end-to-end test at the moment as my Persona auth is broken for one DB, but you can see the first two sync_gateway entries below indicate that the db/_session URL was called.

Once I figure out what's wrong with my Persona login I'll do a full two DB test with the patch.

21:54:06.260931 HTTP: GET /mydb/_session
21:54:06.261353 HTTP: GET /mydb/_session

from couchbase-lite-ios.

snej avatar snej commented on May 27, 2024

OK, thanks. I'll commit the change since it does seem to have helped.

from couchbase-lite-ios.

 avatar commented on May 27, 2024

I have fixed my Persona Auth issue, I'll probably generate a pull request in the next couple of days, but it has allowed me to test against sync_gateway with two DB's and the client both authenticates with one of the two DB's and syncs with it (only push to sync_gateway covered in test).

from couchbase-lite-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.