1. 08 Feb, 2017 1 commit
    • Sean Hammond's avatar
      Don't delete the cached OAuth access token · 0e229735
      Sean Hammond authored
      This fixes an issue that, when the client is embedded on a partner site
      using third-party auth:
      
      1. The client reads grant token that the client embeds in their page
         from the page
      2. The oauth-auth service sends a grant token request, receives back an
         access token which it caches
      3. session.js calls oauth-auth's clearCache(), which deletes the access
         token
      4. The next time the access token is needed the oauth-auth sends a
         second grant token request, with the same grant token, and gets a
         second access token
      
      So two grant token requests are sent, when only one was needed, because
      the cached access token is deleted unnecessarily.
      
      The fix is to make clearCache() in oauth-auth a no-op for now. For now
      it never makes sense for oauth-auth to clear its cached access token.
      OAuth is currently only used when the client is embedded in partner
      sites and the grant token is embedded in the page by the client. Since
      the grant token never changes, there's never any reason to clear the
      access token and request a new one using the same grant token again (you
      would just be requesting a new access token for the same user account).
      0e229735
  2. 06 Feb, 2017 2 commits
  3. 03 Feb, 2017 9 commits
  4. 02 Feb, 2017 6 commits
  5. 01 Feb, 2017 8 commits
  6. 30 Jan, 2017 5 commits
  7. 27 Jan, 2017 2 commits
  8. 26 Jan, 2017 3 commits
  9. 25 Jan, 2017 4 commits
    • Robert Knight's avatar
      Add tests for OAuth authentication · eec82fc7
      Robert Knight authored
      These tests stub the $http service rather than relying on the mock
      $httpBackend from Angular mocks because that makes it easier to work
      with native Promises.
      eec82fc7
    • Robert Knight's avatar
      Include 'authority' argument in call to API endpoint · e18c8996
      Robert Knight authored
      When the user is on a page using 3rd party accounts but is not logged
      in, they will not have an access token.
      
      In this case, the 'authority' argument provides a way for the service to
      determine which authority-specific groups and preferences should be
      included in the returned profile.
      e18c8996
    • Robert Knight's avatar
      Whitelist and document the 'services' config param · 2e36d1f1
      Robert Knight authored
      Document the 'services' config param which the host page may provide to
      the client.
      2e36d1f1
    • Robert Knight's avatar
      Implement API token and profile fetching for OAuth clients · c604c0c3
      Robert Knight authored
      Implement access token and profile retrieval for embedders of the client
      that provide an OAuth grant token as part of the client's configuration.
      
      For a page embedding Hypothesis configured to use a 3rd-party account,
      the start up flow for the client is:
      
       1. Read service configuration from 'services' array in settings
      
       2. Exchange grant token from service config for an access token
          using the `POST /api/token` endpoint
      
       3. Fetch profile data using `GET /api/profile` endpoint
      
      On startup, the app reads the service config and then switches between
      either the cookie-based auth implementation or the OAuth-based auth
      implementation.
      
      In future, the cookie-based auth implementation will be removed in favor
      of OAuth-based auth for first-party accounts as well.
      c604c0c3