Merge lp://staging/~gary/juju-gui/authtoken into lp://staging/juju-gui/experimental

Proposed by Gary Poster
Status: Merged
Merged at revision: 1213
Proposed branch: lp://staging/~gary/juju-gui/authtoken
Merge into: lp://staging/juju-gui/experimental
Diff against target: 1162 lines (+790/-126)
11 files modified
app/app.js (+94/-19)
app/store/env/fakebackend.js (+21/-0)
app/store/env/go.js (+51/-3)
app/store/env/sandbox.js (+32/-3)
app/views/login.js (+8/-2)
test/test_app.js (+186/-2)
test/test_env_go.js (+208/-97)
test/test_fakebackend.js (+31/-0)
test/test_login.js (+1/-0)
test/test_sandbox_go.js (+87/-0)
test/utils.js (+71/-0)
To merge this branch: bzr merge lp://staging/~gary/juju-gui/authtoken
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+196782@code.staging.launchpad.net

Description of the change

Add authtoken support to the GUI

The authtoken support in this branch includes support for both a real environment and the sandbox. In writing this and testing it, I encountered some code that was not working, and some code that was not tested, and some code that was very difficult to test. This branch is utterly gigantic, for which I apologize. It includes the changes I needed to get everything else working. I should factor it out, now that I have figured out what needs to be done, but I'm a bit fatigued, so I'm asking for reviewer indulgence.

There are two ways you should QA. First, in the sandbox, delete the user and password from the config-debug file and then load the GUI in your browser using a URL like this: http://localhost:8888?authtoken=demoToken . This should log you in, remove the authtoken from the URL, and notify you that you used a token to authenticate. Find some other URLs, like in the charm browser, and copy them. Log out with the button on the top right. Paste the previous URL in to the browser, and then insert ?authtoken=demoToken in the URL. *Note that a querystring should come before a hash, so ?authtoken=demoToken#bws-whatever is correct, not the other way around.* Maybe do that log in, log out cycle a couple of times to try a few different URLs. Now log out and try a different token, like ?authtoken=badToken. It should send you to the login page with an appropriate error message.

Now it's time to QA a live environment. Here's how I suggest you do it.

1. In this branch, run BRANCH_IS_GOOD=1 make distfile . When it is finished, it will tell you what file it made.

2. Get a copy of the lp:~juju-gui/charms/precise/juju-gui/trunk/ branch if you don't have one already. If you do have one, make sure it is up to date.

3. mv the file you made in step 1 to the charm's releases directory. rm the old release in that directory.

4. juju bootstrap.

5. In the charm, run make deploy. Wait until it says it is done deploying the code.

6. Start up Python in your local machine. Edit the following code to include the address from step 5 and the appropriate password from your ~/.juju/environments.yaml file.

import itertools
import json
import pprint
import websocket
address = 'PUBLICADDRESS' # e.g. ec2-107-21-197-193.compute-1.amazonaws.com
password = 'YOURPASSWORD'
url = 'wss://{}:443/ws'.format(address)
ws = websocket.create_connection(url)
counter = itertools.count()
def process(request):
    request = request.copy()
    request['RequestId'] = counter.next()
    ws.send(json.dumps(request))
    pprint.pprint(json.loads(ws.recv()))

process(dict(Type='Admin', Request='Login', Params={'AuthTag': 'user-admin', 'Password': password}))
process(dict(Type='GUIToken', Request='Create', Params={}))

The last response should be something like this:

{u'RequestId': 2,
 u'Response': {u'Created': u'2013-11-25T20:11:41.624417Z',
               u'Expires': u'2013-11-25T20:13:41.624417Z',
               u'Token': u'e8ea8ac912fc4ef6a355e82bb65caf6d'}}

7. Now in your browser construct a url that has the GUI address from step 5 and the authtoken from step 6. It should look something like this:

https://PUBLICADDRESS/?authtoken=AUTHTOKEN

Go to this address. It should log you in as it did in the sandbox.

8. Try logging in and out with different methods to see if everything works as you expect.

Thank you very much!!!

https://codereview.appspot.com/33290043/

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :
Download full text (3.9 KiB)

Reviewers: mp+196782_code.launchpad.net,

Message:
Please take a look.

Description:
Add authtoken support to the GUI

The authtoken support in this branch includes support for both a real
environment and the sandbox. In writing this and testing it, I
encountered some code that was not working, and some code that was not
tested, and some code that was very difficult to test. This branch is
utterly gigantic, for which I apologize. It includes the changes I
needed to get everything else working. I should factor it out, now that
I have figured out what needs to be done, but I'm a bit fatigued, so I'm
asking for reviewer indulgence.

There are two ways you should QA. First, in the sandbox, delete the
user and password from the config-debug file and then load the GUI in
your browser using a URL like this:
http://localhost:8888?authtoken=demoToken . This should log you in,
remove the authtoken from the URL, and notify you that you used a token
to authenticate. Find some other URLs, like in the charm browser, and
copy them. Log out with the button on the top right. Paste the
previous URL in to the browser, and then insert ?authtoken=demoToken in
the URL. *Note that a querystring should come before a hash, so
?authtoken=demoToken#bws-whatever is correct, not the other way around.*
  Maybe do that log in, log out cycle a couple of times to try a few
different URLs. Now log out and try a different token, like
?authtoken=badToken. It should send you to the login page with an
appropriate error message.

Now it's time to QA a live environment. Here's how I suggest you do it.

1. In this branch, run BRANCH_IS_GOOD=1 make distfile . When it is
finished, it will tell you what file it made.

2. Get a copy of the lp:~juju-gui/charms/precise/juju-gui/trunk/ branch
if you don't have one already. If you do have one, make sure it is up
to date.

3. mv the file you made in step 1 to the charm's releases directory. rm
the old release in that directory.

4. juju bootstrap.

5. In the charm, run make deploy. Wait until it says it is done
deploying the code.

6. Start up Python in your local machine. Edit the following code to
include the address from step 5 and the appropriate password from your
~/.juju/environments.yaml file.

import itertools
import json
import pprint
import websocket
address = 'PUBLICADDRESS' # e.g.
ec2-107-21-197-193.compute-1.amazonaws.com
password = 'YOURPASSWORD'
url = 'wss://{}:443/ws'.format(address)
ws = websocket.create_connection(url)
counter = itertools.count()
def process(request):
     request = request.copy()
     request['RequestId'] = counter.next()
     ws.send(json.dumps(request))
     pprint.pprint(json.loads(ws.recv()))

process(dict(Type='Admin', Request='Login', Params={'AuthTag':
'user-admin', 'Password': password}))
process(dict(Type='GUIToken', Request='Create', Params={}))

The last response should be something like this:

{u'RequestId': 2,
  u'Response': {u'Created': u'2013-11-25T20:11:41.624417Z',
                u'Expires': u'2013-11-25T20:13:41.624417Z',
                u'Token': u'e8ea8ac912fc4ef6a355e82bb65caf6d'}}

7. Now in your browser construct a url that has the GUI address from
step 5 and the ...

Read more...

Revision history for this message
Madison Scott-Clary (makyo) wrote :

Minors, will QA next.

https://codereview.appspot.com/33290043/diff/1/app/app.js
File app/app.js (right):

https://codereview.appspot.com/33290043/diff/1/app/app.js#newcode521
app/app.js:521: // proxy, withing an authenticated websocket session,
use a
*within

https://codereview.appspot.com/33290043/diff/1/app/store/env/go.js
File app/store/env/go.js (right):

https://codereview.appspot.com/33290043/diff/1/app/store/env/go.js#newcode342
app/store/env/go.js:342: // Indicate if the authentication were from a
token.
*was

https://codereview.appspot.com/33290043/

Revision history for this message
Jeff Pihach (hatch) wrote :

LGTM very thorough thanks!

https://codereview.appspot.com/33290043/

1214. By Gary Poster

respond to review

Revision history for this message
Madison Scott-Clary (makyo) wrote :
Revision history for this message
Gary Poster (gary) wrote :
Download full text (3.5 KiB)

*** Submitted:

Add authtoken support to the GUI

The authtoken support in this branch includes support for both a real
environment and the sandbox. In writing this and testing it, I
encountered some code that was not working, and some code that was not
tested, and some code that was very difficult to test. This branch is
utterly gigantic, for which I apologize. It includes the changes I
needed to get everything else working. I should factor it out, now that
I have figured out what needs to be done, but I'm a bit fatigued, so I'm
asking for reviewer indulgence.

There are two ways you should QA. First, in the sandbox, delete the
user and password from the config-debug file and then load the GUI in
your browser using a URL like this:
http://localhost:8888?authtoken=demoToken . This should log you in,
remove the authtoken from the URL, and notify you that you used a token
to authenticate. Find some other URLs, like in the charm browser, and
copy them. Log out with the button on the top right. Paste the
previous URL in to the browser, and then insert ?authtoken=demoToken in
the URL. *Note that a querystring should come before a hash, so
?authtoken=demoToken#bws-whatever is correct, not the other way around.*
  Maybe do that log in, log out cycle a couple of times to try a few
different URLs. Now log out and try a different token, like
?authtoken=badToken. It should send you to the login page with an
appropriate error message.

Now it's time to QA a live environment. Here's how I suggest you do it.

1. In this branch, run BRANCH_IS_GOOD=1 make distfile . When it is
finished, it will tell you what file it made.

2. Get a copy of the lp:~juju-gui/charms/precise/juju-gui/trunk/ branch
if you don't have one already. If you do have one, make sure it is up
to date.

3. mv the file you made in step 1 to the charm's releases directory. rm
the old release in that directory.

4. juju bootstrap.

5. In the charm, run make deploy. Wait until it says it is done
deploying the code.

6. Start up Python in your local machine. Edit the following code to
include the address from step 5 and the appropriate password from your
~/.juju/environments.yaml file.

import itertools
import json
import pprint
import websocket
address = 'PUBLICADDRESS' # e.g.
ec2-107-21-197-193.compute-1.amazonaws.com
password = 'YOURPASSWORD'
url = 'wss://{}:443/ws'.format(address)
ws = websocket.create_connection(url)
counter = itertools.count()
def process(request):
     request = request.copy()
     request['RequestId'] = counter.next()
     ws.send(json.dumps(request))
     pprint.pprint(json.loads(ws.recv()))

process(dict(Type='Admin', Request='Login', Params={'AuthTag':
'user-admin', 'Password': password}))
process(dict(Type='GUIToken', Request='Create', Params={}))

The last response should be something like this:

{u'RequestId': 2,
  u'Response': {u'Created': u'2013-11-25T20:11:41.624417Z',
                u'Expires': u'2013-11-25T20:13:41.624417Z',
                u'Token': u'e8ea8ac912fc4ef6a355e82bb65caf6d'}}

7. Now in your browser construct a url that has the GUI address from
step 5 and the authtoken from step 6. It should look something like
this:

https://...

Read more...

Revision history for this message
Gary Poster (gary) wrote :

Thanks again to both of you, and apologies for the size.

https://codereview.appspot.com/33290043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches