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

Remember endpoint we authenticated against in returned SyncAuth #2864

Merged
merged 2 commits into from
Dec 4, 2023

Conversation

sartak
Copy link
Contributor

@sartak sartak commented Dec 3, 2023

Hi, thanks for Anki. I have 1.1mil reviews going back 14 years. :)

I'm working on reusing the Rust backend in a project, and I hit a bug related to using a custom sync server.

let auth = backend.sync_login(SyncLoginRequest {
  username,
  password,
  endpoint: Some("http://custom-sync-endpoint"),
})?;

let status = backend.sync_status(auth)?;

This pair of method calls authenticates against http://custom-sync-endpoint, but then when it checks the sync status, it unexpectedly queries the public ankiweb. This is because the anki_proto::sync::SyncAuth returned in sync_login_inner() hardcodes endpoint: None.

With this PR, the SyncAuth is populated correctly so that sync_status method correctly queries http://custom-sync-endpoint instead of ankiweb. (And if the user isn't using a custom sync server, we still preserve the endpoint: None behavior.)

This bug doesn't affect desktop Anki because the Python client stashes the hkey out of the SyncAuth return value here in sync_login, and then constructs a new SyncAuth from scratch later in sync_auth.

@sartak sartak changed the title Include endpoint we authed against in response Include endpoint we authed against in SyncAuth Dec 3, 2023
@sartak sartak changed the title Include endpoint we authed against in SyncAuth Remember endpoint we authenticated against in returned SyncAuth Dec 3, 2023
@dae
Copy link
Member

dae commented Dec 4, 2023

Thanks Shawn!

@dae dae merged commit f447f89 into ankitects:main Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants