mdn / kuma

The project that powers MDN.
https://developer.mozilla.org
Mozilla Public License 2.0
1.93k stars 679 forks source link

subplat integration #7972

Closed peterbe closed 3 years ago

peterbe commented 3 years ago

As of this, imagine you tell the sub plat that our "download URL" is https://developer.mozilla.org/users/subplat/download/ then, after a user has paid, they click that green ("Click here to download") button. What that will do is force the user to sign in again, but with "silent authentication" which means it redirects them to /users/fxa/login/authenticate/?prompt=none (it should be fast) and this time, in the FxA OIDC callback it should get a "second chance" to see that the user has indeed signed in and has paid.

To test, add this to your kuma .env:

SUBSCRIPTION_SUBSCRIBE_URL=https://accounts.stage.mozaws.net/subscriptions/products/prod_Jtbg9tyGyLRuB0?plan=price_1JFoTYKb9q6OnNsLalexa03p
SUBSCRIPTION_SETTINGS_URL=https://accounts.stage.mozaws.net/subscriptions

SUBPLAT_CONFIGURATION_CHECK=true

You also, need to check out https://github.com/mdn/yari/pull/4498 in Yari so you can get the link. But you can also ignore Yari entirely and just manually type in http://localhost:8000/users/subplat/subscribe/ independent of being signed in or not.

Note I don't know if it's correct use to just add ?prompt=none to the FxA authentication URL. I'll ping Ben.

peterbe commented 3 years ago

@escattone One thing that occurs to me now is that one of the settings is called SUBSCRIPTION_SUBSCRIBE_URL but the other one is called SUBPLAT_CONFIGURATION_CHECK. If the first word (before the _) is the "namespace", clearly it's different. Naming things is hard. Perhaps that imperfection is a good reason to pause and contemplate what it really should be (consistently) named.

codecov-commenter commented 3 years ago

Codecov Report

Merging #7972 (e2ec074) into master (0d79744) will increase coverage by 0.26%. The diff coverage is 97.00%.

:exclamation: Current head e2ec074 differs from pull request most recent head 619053e. Consider uploading reports for the commit 619053e to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7972      +/-   ##
==========================================
+ Coverage   90.59%   90.85%   +0.26%     
==========================================
  Files          67       70       +3     
  Lines        2317     2417     +100     
  Branches      159      169      +10     
==========================================
+ Hits         2099     2196      +97     
- Misses        192      194       +2     
- Partials       26       27       +1     
Impacted Files Coverage Δ
kuma/urls.py 88.88% <ø> (ø)
kuma/users/views/subplat.py 86.36% <86.36%> (ø)
kuma/settings/common.py 95.65% <100.00%> (+0.13%) :arrow_up:
kuma/settings/pytest.py 100.00% <100.00%> (ø)
kuma/users/apps.py 100.00% <100.00%> (ø)
kuma/users/checks.py 100.00% <100.00%> (ø)
kuma/users/tests/test_checks.py 100.00% <100.00%> (ø)
kuma/users/tests/test_subplat.py 100.00% <100.00%> (ø)
kuma/users/urls.py 100.00% <100.00%> (ø)
... and 2 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 0d79744...619053e. Read the comment docs.

peterbe commented 3 years ago

I still can't get this to work, in practice. I think we might need some help. https://mozilla.slack.com/archives/C4D36CAJW/p1629389458083800 for those with access

I tried messing with mozilla_django_oidc so that I force-add &prompt=none to the authentication URL. Now, there's no prompt but it always comes back (redirects) back with ?error=invalid_request.

escattone commented 3 years ago

Closing due to #7986