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

feat(profile): Add oauth-authenticated /account/profile endpoint. #1070

Merged
merged 2 commits into from Nov 2, 2015

Conversation

@rfk
Copy link
Member

@rfk rfk commented Oct 1, 2015

A preliminary suggestion for how /account/profile might work, posting for feedback. Needs docs before final merge. @seanmonstar care to take a look?

Fixes #1053.

}
var scopes = auth.credentials.scopes
for (var i = 0; i < scopes.length; i++) {
if (scopes[i] === 'profile') {

This comment has been minimized.

@seanmonstar

seanmonstar Oct 1, 2015
Member

How about:

var allowed = set('profile', 'profile:write', 'profile:' + item, 'profile:' + item + ':write');
for (var i = 0, len = scopes.length; i < len; i++) {
  if (allowed[scopes[i]]) {
    return true;
  }
}

Assuming set is some sort of function to easily make an object:

function set() {
  var obj = {};
  for (var i = 0, len = arguments.length; i < len; i++) {
    obj[arguments[i]] = 1;
  }
  return obj;
}

Bonus points if these sets are consts created once, instead of every request.

This comment has been minimized.

@rfk

rfk Oct 28, 2015
Author Member

We discussed this a little IRL and it sounds like the right answer is to provide an abstraction for scope-checking in a shared utility lib of some kind. But we don't have to do that in this PR.

default: false,
env: 'OAUTH_INSECURE'
}
},

This comment has been minimized.

@seanmonstar

seanmonstar Oct 1, 2015
Member

This assumes the oauth server is a process on the same machine?

I know in our dev servers, we seem to like to put several services behind paths as well.

This comment has been minimized.

@rfk

rfk Oct 28, 2015
Author Member

Are you asked whether this should just be a URL rather than individual host/port/protocol components? If so then yes, I think that would make sense, but we'll have to figure out how that plays with the hapi oauth integration lib.

@rfk
Copy link
Member Author

@rfk rfk commented Oct 9, 2015

@seanmonstar do you feel like picking up dev work on this, so we can ship it alongside the service-tokens stuff in (hopefully!) train-48? I can help but I'm trying to keep myself off the critical path where possible.

@seanmonstar
Copy link
Member

@seanmonstar seanmonstar commented Oct 9, 2015

okie doke!

@seanmonstar seanmonstar self-assigned this Oct 9, 2015
@seanmonstar seanmonstar force-pushed the issue-1053-oauth-profile-info branch 2 times, most recently to e4af078 Oct 27, 2015
@seanmonstar
Copy link
Member

@seanmonstar seanmonstar commented Oct 27, 2015

@rfk trying to understand how far along this was. After a rebase, it seems that it works? You mentioned docs are needed, was there something else?

@rfk
Copy link
Member Author

@rfk rfk commented Oct 28, 2015

@seanmonstar so I think it's largely ready to go then. Let's switch back to author=rfk and r=seanmonstar to keep things consistent. I'll take a look at cleaning up the oauth config into maybe using a URL rather than individual components, if that seems sensible to you.

One concrete thing you could take a look at in the meantime, is diving into the hapi-fxa-oauth plugin [1] for a general-purpose r? on whether it's doing all the right things. The codes's quite small and I trust @dannycoates to get it right, but having another set of eyes on there before we put it in front of our core account data is probably a good idea :-)

[1] https://github.com/mozilla/hapi-fxa-oauth

@rfk rfk assigned rfk and unassigned seanmonstar Oct 29, 2015
@rfk rfk force-pushed the issue-1053-oauth-profile-info branch from e4af078 to e868514 Oct 29, 2015
@rfk
Copy link
Member Author

@rfk rfk commented Oct 29, 2015

OK @seanmonstar, I think this is ready for r?. Unfortunately it will (should!) fail travis because it expects the yet-to-be-released changes from mozilla/hapi-fxa-oauth#1, so we'll have to update deps and shrinkwrap before final merge.

@rfk rfk force-pushed the issue-1053-oauth-profile-info branch from e868514 to c128f8f Oct 30, 2015
@rfk
Copy link
Member Author

@rfk rfk commented Oct 30, 2015

Oh FFS race condition on concurrent_tests.js, you gotta be kidding me...

@rfk rfk force-pushed the issue-1053-oauth-profile-info branch 2 times, most recently from 6749e94 to b1c6144 Oct 30, 2015
@rfk rfk force-pushed the issue-1053-oauth-profile-info branch from b1c6144 to bc85618 Oct 30, 2015
@rfk
Copy link
Member Author

@rfk rfk commented Oct 30, 2015

OK, upstream version bumped, race condition in tests fixed, this should be good to merge.

@rfk rfk assigned seanmonstar and unassigned rfk Oct 30, 2015
seanmonstar added a commit that referenced this pull request Nov 2, 2015
feat(profile): Add oauth-authenticated /account/profile endpoint.
@seanmonstar seanmonstar merged commit e22b65a into master Nov 2, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@seanmonstar seanmonstar deleted the issue-1053-oauth-profile-info branch Nov 2, 2015
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

2 participants