Skip to content
This repository has been archived by the owner. It is now read-only.

Issue 2497 refactor to idp #3982

Merged
merged 26 commits into from Nov 10, 2013
Merged

Issue 2497 refactor to idp #3982

merged 26 commits into from Nov 10, 2013

Conversation

@ozten
Copy link
Member

@ozten ozten commented Oct 16, 2013

Background for pull request: Issue #2497 (comment)

Creating a pull request to try to get some frontend help.

Thanks to @shane-tomlinson for previously reviewing and getting it this far.

Known Issues:

  • siteName and other options aren't passed in from Desktop code, I'm investigating in gecko

Needs Frontend <3

  • rpinfo changes in dev broke this patch, minimal hardcoded changes were made to get it working again
    • Need help doing this correctly
@seanmonstar
Copy link
Member

@seanmonstar seanmonstar commented Oct 16, 2013

fabulous! gets reviewing goggles

res.json({ 'public-key': publicKey.toSimpleObject() });
res.json({
'public-key': publicKey.toSimpleObject(),
'provisioning': '/provision',

This comment has been minimized.

@seanmonstar

seanmonstar Oct 16, 2013
Member

indent is off

@@ -12,6 +12,7 @@ Hub = (function() {
currID = 0;

function on(message, callback, context) {
console.log('HUB ON ' + message);

This comment has been minimized.

@seanmonstar

seanmonstar Oct 16, 2013
Member

reminder to kill these console.logs before merge

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

Ya, the version of Desktop codebase that this runs against has horrible dev tools, so I need these crutches.

'/common/js/helpers.js',
'/common/js/gettext.js',
'/common/js/browser-support.js',
'common/js/enable_cookies_url.js',

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

is this supposed to have a / prepended?

// secondary addresses
const HOSTNAME = urlparse(config.get('public_url')).host;

try {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

It seems like this try/catch could be generalized and placed into primary.js

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

my bad, secrets.js

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

This call is made from 7 sites in the code. Not all of them wrap in a try/catch.
I'd rather not do this change which is outside of the scope of this PR.

var wellKnown;
primary.checkSupport(domain, function(err, r) {
if (!err && r && r.urls) {
wellKnown = {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

Can both of these well known settings be extracted into functions?

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

Sure, what do you mean exactly? Something like this?

function prepareWellKnown(pubKey, provUrl, authUrl) {
  provUrl = provUrl || config.get('public_url') + '/provision';
  ...
  return {
    "public-key": pubKey,
    provisioning: provUrl,
    ...
  }
}
options = options || {};
var self = this;

window.resizeTo(700, 440); // Gross

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

resizeBy might give you better mileage, resizeTo includes browser chrome which can differ depending on toolbars.

// params.origin = user.getOrigin();
var rpInfo = bid.Models.RpInfo.create({origin: 'http://192.168.186.138:10001'});
user.setRpInfo(rpInfo);
dialogHelpers.createUser.call(self, email, info.password, function(info) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

Can these be extracted into functions? The pyramid o' doom is getting awfully deep.

// TODO merge broke us - user.setRPInfo must now be called like in
// resources/static/dialog/js/modules/dialog.js line 130, 286
// params.origin = user.getOrigin();
var rpInfo = bid.Models.RpInfo.create({origin: 'http://192.168.186.138:10001'});

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

ya, we need this info for the origin somehow. Are all the RP parameters passed here? If so, we'll need tos/pp, siteLogo and backgroundColor as well.

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

So... What we need is a way to get those parameters into this dialog.... We could drag over the channel stuff that allows you to call navigator.id.registerChannel, and then pass them in that way. We could use query strings. We could possibly stuff that info into local or sessionStorage? Indexeddb? Dunno what the best route forward is, would like to find out what capabilities you have.

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

Do you have a SHA for before and after the rpinfo stuff?

What are the inputs and were do they come from? We should probably solve this in content space, but natively is also an option.

});
}
},
function(err) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

I wanna kill the error rendering with a spoon.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
BrowserID.Modules.IdPAuthentication= (function() {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

so, FWIU, this is a super mini state machine. With as yuck as the state machine is, we may want to use the generalized portion of it here if there is ever a point where the user can go back a screen within the IdP. I can help you with that if necessary.

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

I'm trying to do this, but not really sure what to do. Can you make a pull request off of issue-2497-refactor-to-idp with a sketch (or complete implementation) of what you mean?

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Nov 7, 2013
Member

OTOH, we should hold off on adding the state machine functionality until we have more direction. No need to add complexity where it's not yet needed.

</section>
<% } %>

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

I believe the error/waiting/delay sections will need to be added here to handle when those events occur.

getJSON('/wsapi/session_context', function(session, text, xhr) {
if (session.authenticated) {
getJSON('/wsapi/list_emails', function(data, text, xhr) {
if (data.emails.indexOf(email) === -1) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

Is there ever a chance in hell we'll use this universally? If so, [].indexOf will break in IE8.

This comment has been minimized.

@ozten

ozten Oct 17, 2013
Author Member

If IE8 implements persona natively and re-uses these flows, I'll eat my hat. :)

},
error: function(xhr, status, err) {
// TODO: Handle errors
if (console && 'function' === typeof console.log) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Oct 17, 2013
Member

There is navigator.id.raiseProvisioningFailure I believe for this case.

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Oct 17, 2013

So... The devil hiding in the details, password resets and transition states. Are they going to be handled?

@ozten
Copy link
Member Author

@ozten ozten commented Oct 17, 2013

The devil hiding in the details, password resets and transition states. Are they going to be handled?

Can we land this and start getting UX feedback, before implementing those features?

@ozten
Copy link
Member Author

@ozten ozten commented Oct 17, 2013

Trying to get awsbox working, I've merged from dev, but got bitrot for the second time.

I was able to see that logging.js moved and fix that.

The other issue is that the dialog just comes up blank.

To unblock myself, I've copied over scripts/deploy.js and changed the dependency to awsbox@0.6.2... but we'll have to figure out what changed about the dialog code that has broken the initial screen display for the new /auth screen. Any ideas?

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 18, 2013

@ozten I'll do some git twiddling on Monday, see if I can cleanly apply your changes on top of current dev.

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

ok, looking now.

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

@ozten nice work so far!

I was able to cleanly cherry-pick all the changes onto current dev (except for the commits merging dev into this branch). My branch is at https://github.com/6a68/browserid/tree/issue-2497-idp-rebased-not-merged.

One tiny logging path change was needed to get tests running, that's on the HEAD of that branch, a7fd566.

The local RP seems fine to me on my branch, I can log in and out.

@ozten
Copy link
Member Author

@ozten ozten commented Oct 21, 2013

@6a68 is rocking the merge from dev to update this branch, you rule!

Please try to reproduce the blank dialog I was seeing.

You can download a Persona enabled Desktop build:
http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/aking@mozilla.com-62351505bca9/

Set a couple preferences (about:config):

dom.identity.enabled = true
dom.identity.persona_fallback = http://127.0.0.1:10002
toolkit.identity.debug = true

Restart Firefox.

dom.identity.persona_fallback defaults to our new ephemeral server https://desktoppersona.personatest.org/ but you can change this to any environment.

Steps to reproduce:

  1. Launch Firefox with a clean profile
  2. Go to http://127.0.0.1:10001
  3. Click Get an assertion
  4. Enter foo@bar.com

Actual: empty dialog

Expected: prompt to set a password

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

@ozten happy to help :-)

I've got the special FF build, I toggled the settings you mentioned (actually tried using the desktoppersona fallback as well as localhost), but I'm not sure what to do next.

When I try to log into RPs, I click the persona button but nothing happens. Tried 123done, mozillians, nothing. Also not seeing errors in the JS console--maybe there's a desktop-specific console for the native code that I'm unaware of?

I'll poke a bit more at my branch and yours, see if I can at least get an empty dialog using your branch.

@ozten
Copy link
Member Author

@ozten ozten commented Oct 21, 2013

So in nightly if you go to about:config and search for identity does it look like this

Clicking get Assertion should look like this

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

It looks like the blank dialog error was caused by using hashes, but the recently-landed #3971 I think means we should be using querystring instead.

@ozten said this got him past the blank dialog problem in a local branch, I've updated my issue-2497-idp-rebased-not-merged branch with the fix (commit (9e8ed0f)[https://github.com/6a68/browserid/commit/9e8ed0f]).

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

@ozten i don't have the toolkit.identity.enabled pref at all, but I have the other three matching your screenshot.

The second image is broken for me.

@ozten
Copy link
Member Author

@ozten ozten commented Oct 21, 2013

Thanks Jared!

Using your patch, I see Error: Relay frame could not be found.

Thanks for continuing to dig for breaking changes from merging.

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 21, 2013

I have my current branch running on https://rebasedidp.personatest.org. Will pick this up again in the morning. 🍻

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 22, 2013

@ozten looks like this line probably shouldn't have that IP hard-coded. I'm not totally clear on where we can get the proper domain info in this context, though. any ideas?

@jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Oct 23, 2013

heh, I caused the Relay Error: we look for the hash, not the querystring, when we setup the channel. Removing that, or changing that code to look for ?NATIVE as window.location.search, returns us to the mysterious empty dialog situation we had before. Continuing to dig.

@ozten
Copy link
Member Author

@ozten ozten commented Nov 7, 2013

@fmarier or @shane-tomlinson I've removed temporary hacks, console.log, etc. We should be good to merge as discussed.

General note: The Goldilocks API breaks the Native implementation, so use http://192.168.186.138:10001/watch.html instead of http://192.168.186.138:10001/

@ozten
Copy link
Member Author

@ozten ozten commented Nov 7, 2013

G R E E N

mediator.subscribe("new_user", newUserComplete(self));

var rpInfo = bid.Models.RpInfo.create({
origin: "http://127.0.0.1:10001",

This comment has been minimized.

@fmarier

fmarier Nov 7, 2013
Contributor

Did you forget to take these out?

@fmarier
Copy link
Contributor

@fmarier fmarier commented Nov 10, 2013

r+ from me. makes Travis happy. tested by Shane and Austin.

fmarier added a commit that referenced this pull request Nov 10, 2013
@fmarier fmarier merged commit 173be4f into dev Nov 10, 2013
1 check passed
1 check passed
@rik
default The Travis CI build passed
Details
@ozten
Copy link
Member Author

@ozten ozten commented Nov 10, 2013

All the man needed was a Guiness at the airport!

Thanks!

@jaredhirsch jaredhirsch deleted the issue-2497-refactor-to-idp branch Apr 20, 2014
seanmonstar added a commit to seanmonstar/browserid-verifier that referenced this pull request May 30, 2014
This allows the verifier to work-around a Persona bug that has
been fixed (mozilla/persona#3982) but not
yet deployed.

Fixes mozilla#19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants