Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Send "resume" parameter to supported auth server calls #1623

Closed
7 of 8 tasks
ckarlof opened this issue Sep 4, 2014 · 11 comments
Closed
7 of 8 tasks

Send "resume" parameter to supported auth server calls #1623

ckarlof opened this issue Sep 4, 2014 · 11 comments
Assignees

Comments

@ckarlof
Copy link
Contributor

ckarlof commented Sep 4, 2014

Context: mozilla/fxa-auth-server#762

With resume we'll be able to send whatever encoded OAuth context we want. I propose putting the client_id, state, and redirect_uri in an encoded JWT and putting it in resume wherever we're setting service. We still need to set service because it's used for server side metrics, but we can stop setting redirectURL.

This should clean things up a bit.

Items remaining:

@ckarlof ckarlof added this to the train-22 (Sep 22) milestone Sep 4, 2014
@shane-tomlinson shane-tomlinson self-assigned this Sep 8, 2014
@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 9, 2014

Landed in auth server in train-21: mozilla/fxa-auth-server@36f9e28

@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 9, 2014

This is a *** feature in train-22.

If the user creates an account, opens her verification link in a different browser, and then continues in that browser to the relier, our return request will lack the state originally given to us by the relier. In fact, we return some "different browser" error instead.

IMO, it's our responsibility to pass the state back regardless, and the relier's responsibility to respond to the different browser case. Also, the relier might be using the state for other reasons, and it's a flaw that we're not giving it back to them in this case.

The auth server has added a resume parameter for us to use here. Since we might shove other crap in there later as well, I propose we put the state in there as an encoded JWT with one property: state. Other suggestions?

FWIW, the reason this is important is to help make Marketplace's migration work when the user chooses to use a different email address for her FxA and then verifies and continues in a second browser. Corner case for sure, but as @ryanfeeley says, we need to make the Web less excruciatingly painful.

@pdehaan
Copy link
Contributor

pdehaan commented Sep 9, 2014

we need to make the Web less excruciatingly painful.

That @ryanfeeley guy should work in marketing. Or at least get that printed on his business cards.

@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 10, 2014

I made it my Twitter tag line.

@ckarlof ckarlof added the doing label Sep 10, 2014
shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* Remove the singleton FxaClient created in views/base.js, instead create one in app-start and pass it via the router to all objects that need it.
* Update assertion.js to use a passed in fxaClient instead of creating its own.
* Update the tests that need to be updated.

Part of issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* Remove the singleton FxaClient created in views/base.js, instead create one in app-start and pass it via the router to all objects that need it.
* Update assertion.js to use a passed in fxaClient instead of creating its own.
* Update the tests that need to be updated.

Part of issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* Remove the singleton FxaClient created in views/base.js, instead create one in app-start and pass it via the router to all objects that need it.
* Update assertion.js to use a passed in fxaClient instead of creating its own.
* Update the tests that need to be updated.

Part of issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* Remove the singleton FxaClient created in views/base.js, instead create one in app-start and pass it via the router to all objects that need it.
* Update assertion.js to use a passed in fxaClient instead of creating its own.
* Update the tests that need to be updated.

Part of issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
@shane-tomlinson
Copy link

@ckarlof - once the verification email is opened and the user is back at the content server, what responsibilities does the content server have? Does it need to decode the resume JWT, pull out the encoded fields, and redirect?

A question that should precede the following - how is the resume field generated? Does the RP take care of that, our client library, or do we do it in the Relier?

shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 11, 2014

A question that should precede the following - how is the resume field generated? Does the RP take care of that, our client library, or do we do it in the Relier?

We discussed in the standup, but resume will be created and managed by the content server code.

shane-tomlinson pushed a commit that referenced this issue Sep 11, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 12, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
@shane-tomlinson
Copy link

@ckarlof - I'm going to need a bit of hand holding and wanna get some clarity before you head out on vacation.

If the user creates an account, opens her verification link in a different browser, and then continues in that browser to the relier, our return request will lack the state originally given to us by the relier. In fact, we return some "different browser" error instead.

IMO, it's our responsibility to pass the state back regardless, and the relier's responsibility to respond to the different browser case. Also, the relier might be using the state for other reasons, and it's a flaw that we're not giving it back to them in this case.

The auth server has added a resume parameter for us to use here. Since we might shove other crap in there later as well, I propose we put the state in there as an encoded JWT with one property: state. Other suggestions?

I am looking at how to create a JWT over on the jwcrypto docs.

I can create a JWS as in the example:

jwcrypto.sign(payload, keypair.secretKey, function(err, jws) {
       // error in err?

       // serialize it
       console.log(jws.toString());
    });

I can pass that jws to the auth server as the resume parameter.

In the verification code, I can decode that jws using verify:

   // verify it
    jwcrypto.verify(signedObject, publicKey, function(err, payload) {
      // if verification fails, then err tells you why
      // if verification succeeds, err is null, and payload is
      // the signed JS object.
    });

To do that, I need the public key from the original keypair.

If I create a key pair for the signing, I can store those in localStorage, and decode the jws - in the same browser. This doesn't really help the case where the user verifies in a second browser, unless the client can fetch the public key for the user from the server?

On a second browser, I could manually decode the jws and not verify, but that doesn't seem like the right thing to do.

@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 12, 2014

Crap @shane-tomlinson, I'm dumb. I didn't mean JWT. I meant "web safe Base64 encoded JSON", e.g.,

resume=WebSafeBase64Encode('{"state":"123"}')

It doesn't need to be signed. I'm sorry about the confusion.

shane-tomlinson pushed a commit that referenced this issue Sep 15, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 15, 2014
* `resume` is imported from the URL and stored in the Relier.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
@shane-tomlinson
Copy link

Copying over this comment from mozilla/fxa-auth-server#762 (comment).


Related to the work we're doing in #784 for Marketplace migrating their existing accounts. If the legacy (migrating) user verifies her email on a second device and continues there, it will be useful to be able to pass the state to Marketplace to allow the user to continue the migration.

@dannycoates, @ckarlof - To resume on a second device, we need to be able to generate an assertion. Generating an assertion requires a signed certificate, which requires a sessionToken. Neither /recovery_email/verify_code nor /password/forgot/verify_code return a sessionToken. We can get around this by forcing the user to enter their password in the second browser, or we could have those two API calls return a sessionToken. I propose we return a sessionToken.

@shane-tomlinson
Copy link

@ckarlof and @dannycoates - @johngruen and @ryanfeeley say that it's OK to ask the user for their password in the second client, no new auth-server support needed. Thanks!

shane-tomlinson pushed a commit that referenced this issue Sep 16, 2014
* Create a `resume` token from the `state` search parameter. Pass it along to the fxa-js-client.
* If `resume` is available on the URL search string, populate `state`.
* fxa-client sends the token to the auth server in `signUp`, `signUpResend`, `passwordReset`, and `passwordResetResend`

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 17, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 17, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 18, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 20, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 22, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

Introduce the User model.
* Create the User instance in app-start.js. Pass it to the router which passes it to the Views.
* Update the complete_sign_up View to make use of the User model.
* Update the OAuth Relier to set the email on the User model instead of itself.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 22, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

Introduce the User model.
* Create the User instance in app-start.js. Pass it to the router which passes it to the Views.
* Update the complete_sign_up View to make use of the User model.
* Update the OAuth Relier to set the email on the User model instead of itself.

issue #1623
shane-tomlinson pushed a commit that referenced this issue Sep 22, 2014
* Create a `resume` token from OAuth parameters. Pass it along to the fxa-js-client.
* Re-populate OAuth parameters from resume token on email verification.
* Bump fxa-js-client to 0.1.25 with the new `resume` hotness.
* Add functional tests for verifying in a second browser.
* Only show the serviceName in the ready screen if the user can continue with the OAuth flow.

Introduce the User model.
* Create the User instance in app-start.js. Pass it to the router which passes it to the Views.
* Update the complete_sign_up View to make use of the User model.
* Update the OAuth Relier to set the email on the User model instead of itself.

issue #1623
@ckarlof ckarlof modified the milestones: train-23 (Oct 6), train-22 (Sep 22) Sep 22, 2014
@ckarlof
Copy link
Contributor Author

ckarlof commented Sep 22, 2014

I didn't think this through enough. The state is also intended to be used as an anti-forgery token. When verifying on a second browser, even if the user enters her password, then anti-forgery check isn't going to pass on the relier, which is going to be a problem.

If we have mozilla/fxa-auth-server#763 (have email verification call return a sessionToken), then we could do something like:

  • user clicks verification link
  • we finish oauth flow and send back state
  • relier detects that state doesn't match its current session
  • relier regenerates state for client session and re-requests auth for email address
  • some magic happens where we don't show any UI and just re-auth the user

the last step would probably be some rule like, if

  • the email parameter exists
  • we have an active session for that email
  • the relier is whitelisted

then we just auto-finish the OAuth login for that account without showing any UI.

@ckarlof ckarlof removed this from the train-23 (Oct 6) milestone Oct 6, 2014
shane-tomlinson pushed a commit that referenced this issue Oct 7, 2014
The `resume` token isn't actually used at the moment, this is setting us up to verify in a second browser. The resume token only contains the `state` token passed by the OAuth RP.

fixes #1623
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants