Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Closes #3729: allow tokenserver url override - #5984

Closed
tublitzed wants to merge 1 commit into
mozilla-mobile:masterfrom
tublitzed:feat/allow-tokenserver-url-override
Closed

tublitzed wants to merge 1 commit into
mozilla-mobile:masterfrom
tublitzed:feat/allow-tokenserver-url-override

Conversation

@tublitzed

@tublitzed tublitzed commented Feb 18, 2020 •

Copy link
Copy Markdown

The first step in supporting self hosted sync for Fenix is allowing the tokenserver url to be passed into the FxaAccountManager. This allows users to override the default tokenserver url, via Sync Config.


Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or does not need one
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues closed by this pull request are added to the milestone of the version currently in development.
  • Breaking Changes: If this is a breaking change, please push a draft PR on Reference Browser to address the breaking issues.

@tublitzed
tublitzed requested a review from grigoryk February 18, 2020 19:33
@codecov

codecov Bot commented Feb 18, 2020

Copy link
Copy Markdown

Codecov Report

Merging #5984 into master will decrease coverage by 1.67%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #5984      +/-   ##
============================================
- Coverage     78.77%   77.09%   -1.68%     
+ Complexity     5533      176    -5357     
============================================
  Files           597       32     -565     
  Lines         26522     1144   -25378     
  Branches       3877      177    -3700     
============================================
- Hits          20892      882   -20010     
+ Misses         4065      210    -3855     
+ Partials       1565       52    -1513
Impacted Files Coverage Δ Complexity Δ
...va/mozilla/components/support/locale/Extensions.kt 75% <0%> (ø) 0% <0%> (ø) ⬇️
...ava/mozilla/components/lib/jexl/value/JexlValue.kt 63.11% <0%> (ø) 0% <0%> (ø) ⬇️
.../java/mozilla/components/lib/jexl/parser/Parser.kt 92.37% <0%> (ø) 32% <0%> (ø) ⬇️
.../src/main/java/mozilla/components/lib/jexl/Jexl.kt 77.14% <0%> (ø) 7% <0%> (ø) ⬇️
...nts/support/locale/LocaleAwareAppCompatActivity.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...ava/mozilla/components/lib/jexl/grammar/Grammar.kt 82.47% <0%> (ø) 2% <0%> (ø) ⬇️
...omponents/support/locale/LocaleAwareApplication.kt 0% <0%> (ø) 0% <0%> (ø) ⬇️
...in/java/mozilla/components/lib/jexl/lexer/Token.kt 100% <0%> (ø) 4% <0%> (ø) ⬇️
...va/mozilla/components/lib/jexl/lexer/LexerInput.kt 89.47% <0%> (ø) 16% <0%> (ø) ⬇️
...mozilla/components/lib/jexl/evaluator/Evaluator.kt 70% <0%> (ø) 17% <0%> (ø) ⬇️
... and 571 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82c84b3...74ac5fd. Read the comment docs.

* periodic syncing will be disabled.
* @property tokenServerUrl Optional, override default tokenServerUrl to support self-hosted sync storage.
*/
data class SyncConfig(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grigoryk - So it seems that the ServerConfig (which was the suggestion on where to overwrite this value in the original issue) is pulled from here in application services and doesn't currently support setting a custom token server url.

Since #3729 was filed specifically for this repo, I wanted to first confirm with you that you still think it makes sense for the ServerConfig to set this value. If so, I can close this PR and first open a PR over in application services to support setting a token server url. Then, once that merges, I can re-open this one and adjust to use that value instead.

Since that's a much larger scope of changes, I figured it'd make sense to confirm this approach with you first.

@tublitzed

Copy link
Copy Markdown
Author

It's also worth noting here that I think we may also need to make additional changes to support #3762. I'm able to verify here that I can successfully overwrite the tokenserver url used for sync....but cannot get a successful sync after doing so. When setting to local sync server(http://localhost:5000/token/1.0/sync/1.5), I get a network error (is this a known issue with the android studio emulator and localhost?) and when setting to staging sync server (https://token.stage.mozaws.net/1.0/sync/1.5) I get a 401. I'm not sure if there's something else that's happening in desktop when you overwrite the token server url via identity.sync.tokenserver.uri in about:config...still need to dig into that. I think we might be missing an extra step here though. Flagging this here in case anyone has ideas as to what that might be. Otherwise, I'll keep digging.

@tublitzed

Copy link
Copy Markdown
Author

Hey, @grigoryk can I get a r+ here?

@grigoryk grigoryk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that we don't need this PR as-is. Let's make ServerConfig in the appservices configurable enough to allow overriding values obtained from .well-known/fxa-client-configuration (https://github.com/mozilla/application-services/blob/master/components/fxa-client/src/config.rs#L120). Once that's done, I don't think we'll need any changes in a-c at all - everything we care about (content_url, tokenserver_url) will be directly configurable from Fenix.

Instead of localhost, try using 127.0.0.1? That should work in the emulator.

As to why you got a 401 when configuring a staging tokenserver - I'm not sure, actually! Does this configuration work for you in other clients (desktop)? E.g. use production auth server in conjunction with a staging token server? I would expect that to work, and code in your PR looks like it should definitely work.

return
}

var tokenServerUrl = syncConfig?.tokenServerUrl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more succinct way to write this (and avoid using a var):
val tokenServerUrl = syncConfig?.toknServerUrl ?: account.getTokenServerEndpointURL()

tokenServerUrl = account.getTokenServerEndpointURL()
}

logger.info("caching tokenServerUrl: $tokenServerUrl")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not log the URL itself - it could be considered PII. Just mention the fact that this is a custom tokenServerUrl.

@tublitzed tublitzed closed this Mar 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants