Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: @slack/oauth: add support and examples for CSRF mitigation #1013

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Commits on May 7, 2020

  1. fix: moves dev dependencies to devDependencies

    * Updates the version to 1.1.0
    * Moves TypeScript dependencies that were in the production dependencies
    to the devDependencies
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    40e6930 View commit details
    Browse the repository at this point in the history
  2. feat: adds timing attack mitigation

    If the JWT doesn't expire, it can be used any time.
    
    * Adds configuration option to limit the lifetime of the state token
    * Adds default lifetime of 3 minutes
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    75f18ea View commit details
    Browse the repository at this point in the history
  3. docs: adds documentation for overriding state ttl

    Adds documentation to the README to describe the default state lifetime,
    and how to override it.
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    351003c View commit details
    Browse the repository at this point in the history
  4. feat: adds support for csrf mitigation

    * Replaces generateInstallUrl with makeInstallUrl, which returns both
    the url, and the token that was generated
    * Adds support for passing the token in with the options to
    callbackHandler, so it can be bound to the device in a cookie, and
    compared to the token that we received from Slack
    * Adds support for injecting the web client, so additional test paths
    can be evaluated
    * Improves test coverage
    * Fixes the mock web client responses (appId should be app_id)
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    495811f View commit details
    Browse the repository at this point in the history
  5. docs: updates README with makeInstallUrl

    Because the generateInstallUrl returned a string, it wasn't extensible,
    so I had to either (a) introduce a breaking change, or (b) introduce a
    new function. I chose the latter, and updated the documentation to
    demonstrate (b) in the examples.
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    ba07cc0 View commit details
    Browse the repository at this point in the history
  6. feat: updates v1 example with csrf mitigation

    * Adds dependency on `cookie` library
    * Uses new makeInstallUrl function to get the redirect url, and token
    * Adds the generated token to a secure, http-only cookie before
    redirecting to Slack OAuth
    * Parses the cookie from the headers when Slack redirects back to the
    app
    * Ensures the cookie exists before calling handleCallback, so there
    isn't a wait-for-expiration gap
    * Passes the token to handleCallback so it can be timingSafeCompared to
    the JWT that Slack send back in the query string
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    9afaab1 View commit details
    Browse the repository at this point in the history
  7. feat: updates v2 example with csrf mitigation

    * Adds dependency on `cookie` library
    * Uses new makeInstallUrl function to get the redirect url, and token
    * Adds the generated token to a secure, http-only cookie before
    redirecting to Slack OAuth
    * Parses the cookie from the headers when Slack redirects back to the
    app
    * Ensures the cookie exists before calling handleCallback, so there
    isn't a wait-for-expiration gap
    * Passes the token to handleCallback so it can be timingSafeCompared to
    the JWT that Slack send back in the query string
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    02db29a View commit details
    Browse the repository at this point in the history
  8. fix: uses separate jwt for device sync

    My intention was to only send the random byte array as the value
    for the OAuth state param, and for the JWT to only exist in the
    cookie. However, that represents a potentially complex and/or
    breaking change. However, if the same JWT is used as the state
    param and in the cookie, and adversary who is able to capture the
    redirect url can easily spoof a synchronized device. So the examples
    sign JWTs specifically for the device, and provide the synchronizer
    to the callbackHandler for comparison.
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    67edf26 View commit details
    Browse the repository at this point in the history
  9. fix: updates tests to pass after rebase

    A test breaking change was introduced in master. This changes the test
    to evaluate the new behavior.
    losandes committed May 7, 2020
    Configuration menu
    Copy the full SHA
    d96d522 View commit details
    Browse the repository at this point in the history