Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

fix(scopes): Formalize and document scope-handling rules. #551

Merged
merged 1 commit into from
Aug 15, 2018

Conversation

rfk
Copy link
Contributor

@rfk rfk commented May 2, 2018

Connects to #575

While working on adding OAuth support for sync, I figured we should have a canonical reference for what sorts of scope we support and how we check for matches. So I started something, and here's the rendered view:

https://github.com/mozilla/fxa-oauth-server/blob/scopes-documentation/docs/scopes.md

I want to add some explicit testcases for this in the code here, but am putting the doc up for early feedback. @vladikoff does this seem sane? I think it differs slightly from the proposal in the original scoped-keys doc, in that it uses the URL fragment for qualifications like "readonly". But I quite like the ability to check scopes by parsing them as URL resource references.

@ghost ghost assigned rfk May 2, 2018
@ghost ghost added the waffle:active label May 2, 2018
docs/scopes.md Outdated

* Be an absolute `https://` URL.
* Have no query component.
* Have a fragment component consisting only of alphanumeric ascii characters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random drive-by comment, but this wording makes it sound like the fragment part is mandatory because of the MUST before the list. Maybe clarify here with an "if specified..." clause, or split out to a separate MAY list?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or include MUST / MAY in each bullet rather than aggregated at the top)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good call, I will update.

docs/scopes.md Outdated
introduced during earily development.

**No new short-name scope values should be added.**
Instead we prefer to use URLs for new scope values,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+No new short-name scope values should be added.
Instead we prefer to use URLs for new scope values,

Ah interesting 👍 . I'm surprised to hear this but i guess this makes sense after looking at Google's list of these scopes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always revisit this as time goes on, if we find the URL syntax to be unwieldy.

* `https://identity.mozilla.com/apps/oldsync#read` indicates
read-only access to the user's data in Firefox Sync.
* `https://identity.mozilla.com/apps/oldsync/history#write` indicates
write-only access to the user's history data in Firefox Sync.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah!!

vladikoff
vladikoff previously approved these changes May 3, 2018
Copy link
Contributor

@vladikoff vladikoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+, @rfk let's add the link to the fxa-shared implementation that we have in this doc as well (once that lands). I think that should be useful for future readers

@rfk
Copy link
Contributor Author

rfk commented May 3, 2018

Thanks @vladikoff; I think I'll leave this open until I have a corresponding PR to use it in some of our other codebases, in case that reveals some opportunities for API cleanup.

@shane-tomlinson
Copy link

@rfk - is there anything else you want to add to this?

@GitCop
Copy link

GitCop commented Jul 4, 2018

Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:

  • Commit: 5d198fc
  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/mozilla/fxa-oauth-server


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Jul 4, 2018

Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:

  • Commit: 5d198fc
  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/mozilla/fxa-oauth-server


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Jul 4, 2018

Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:

  • Commit: 5d198fc
  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/mozilla/fxa-oauth-server


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

GitCop commented Jul 4, 2018

Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:

  • Commit: 5d198fc
  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/mozilla/fxa-oauth-server


This message was auto-generated by https://gitcop.com

@shane-tomlinson
Copy link

@rfk - what's left to do here?

@rfk
Copy link
Contributor Author

rfk commented Jul 9, 2018

I made a combined tracking issue to summarize status: #575

@rfk rfk force-pushed the scopes-documentation branch 6 times, most recently from c01f8f5 to 83f8875 Compare July 9, 2018 23:01
@rfk rfk dismissed vladikoff’s stale review July 19, 2018 04:16

This'll need re-review given the evolution of the shared checking code.

@rfk rfk force-pushed the scopes-documentation branch 3 times, most recently from 8713663 to 6c5a8e4 Compare July 23, 2018 06:26
@rfk rfk added train-117 and removed train-116 labels Jul 23, 2018
@rfk
Copy link
Contributor Author

rfk commented Jul 23, 2018

This has been updated to use a tag of fxa-shared rather than a github ref; @mozilla/fxa-devs r?

* `profile:write` implies `profile:email:write`.
* `profile:email:write` implies `profile:email`.
* `profile profile:email:write` implies `profile:email`.
* `profile profile:email:write` implies `profile:display_name`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean profile profile:display_name:write implies profile:display_name?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean profile profile:display_name:write implies profile:display_name?

profile implies profile:display_name (both read-only), the profile:email:write is needed to write to the email.

Copy link
Contributor

@vbudhram vbudhram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfk This looks good and makes sense to me. However, I wouldn't mind extra eyes on this since I am not very familiar with the repo.

Copy link

@shane-tomlinson shane-tomlinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple comments about the docs, logic looks good to me.

* `profile:locale`: access the user's locale.
* `profile:avatar`: access the user's avatar picture.
* `profile:display_name`: access the user's human-readable display name.
* `profile:amr`: access information about the user's authentication methods and 2FA status.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be any indication on whether any of these are read vs read/write? uid/locale/amr I imagine are read-only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that the amr cannot be modified, but "profile:amr:write" is still a well-formed scope with well-defined semantics (that doesn't happen to grant you any addition powers over "profile:amr".

but not to other data types.
* `https://identity.mozilla.com/apps/oldsync#read` indicates
read-only access to the user's data in Firefox Sync.
* `https://identity.mozilla.com/apps/oldsync/history#write` indicates

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would one want write-only access to history?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're a mobile app that wants to record visits that can show up in the activity-stream on the user's desktop, but we don't want to let you read the sites that the user has been visiting on other devices.

docs/scopes.md Outdated

We say that a scope value A *implies* another scope value B
if they are exactly equal,
of if A represents a more general capability than B.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of if=> or if

* `profile:write` implies `profile:email:write`.
* `profile:email:write` implies `profile:email`.
* `profile profile:email:write` implies `profile:email`.
* `profile profile:email:write` implies `profile:display_name`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean profile profile:display_name:write implies profile:display_name?

profile implies profile:display_name (both read-only), the profile:email:write is needed to write to the email.

docs/scopes.md Outdated
* `profile profile:email:write` does *not* imply `profile:write`.
* `https` does *not* imply `https://identity.mozilla.com/apps/oldsync`.
* `https://identity.mozilla.com/apps/oldsync` does *not* imply `profile`.
* `https://identity.mozilla.com/apps/oldsync#read` does *not* imply `https://identity.mozila.com/apps/oldsync/bookmarks`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the URL after "does not imply" do you want "mozila" or "mozilla"? Applies to this and the following 6 lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be mozilla yeap :)

@rfk
Copy link
Contributor Author

rfk commented Aug 15, 2018

Thanks @vbudhram @shane-tomlinson, nits fixed.

@rfk rfk merged commit 237886d into master Aug 15, 2018
@shane-tomlinson shane-tomlinson added this to the FxA-0: quality milestone Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants