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

Stop hard-coding 'http' protocol for sync server interactions in AuthProvider.ts #106

Merged
merged 4 commits into from
May 23, 2024

Conversation

brentkeller
Copy link
Collaborator

Solves

We're unable to properly connect to sync servers hosted with TLS because the AuthProvider is always trying to make certain requests using http://.

Description

I've added a private method in AuthProvider.ts to determine which protocol to use based on the given server url we're working with. In this case I'm making a simple check that returns "http" if the url contains "localhost" and otherwise defaults to "https".

brentkeller and others added 2 commits May 23, 2024 17:34
http is great for local development and tests but we want secure connections everywhere else
Rather than get better at guessing, default to the old behavior of assuming http unless we're told otherwise.
since this is a pure function (not dependent on any class members) it
doesn't need to be a method on the class, can just be a stand-alone
utility function
@HerbCaudill
Copy link
Member

Looks good.

I've changed AuthProvider.#parseServer to a stand-alone helper function, buildServerUrl. Since this is a pure function (not dependent on any class members) it doesn't need to be a method on the class, can just be a stand-alone utility function.

Also this way it can be easily tested in isolation - I've added a couple of simple tests for the heck of it.

@HerbCaudill HerbCaudill merged commit 156b887 into main May 23, 2024
1 check passed
@HerbCaudill HerbCaudill deleted the fix-hardcoded-http branch May 23, 2024 15:58
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.

None yet

3 participants