Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Address remaining "authentication" tasks #20

Merged
merged 16 commits into from
Sep 29, 2017
Merged

Address remaining "authentication" tasks #20

merged 16 commits into from
Sep 29, 2017

Conversation

as-cii
Copy link
Contributor

@as-cii as-cii commented Sep 27, 2017

This is a follow-up to #4 and takes care of the remaining tasks to provide an authentication facility for real-time-client and, as a result, for the real-time package as well.

@jasonrudolph: I think this addresses all the TODOs you originally added, but I'd ❤️ to have your feedback on this.

/cc: @nathansobo

Nathan Sobo and others added 9 commits September 27, 2017 11:51
Copy link
Contributor

@jasonrudolph jasonrudolph left a comment

Choose a reason for hiding this comment

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

This is coming along nicely, @as-cii. I've noted a few questions in the review below. I hope this helps.

test('throws an error when GitHub API is inaccessible', async () => {
const request = {
get: async function (url, {headers}) {
const body = JSON.stringify({message: 'Bad credentials'})
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this line, or can we remove it?

const request = {
get: async function (url, {headers}) {
const body = JSON.stringify({message: 'Bad credentials'})
throw new RequestError('a request error')
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can't reach the GitHub API, will request-promise-core throw a RequestError?

const identity = await identityProvider.identityForToken(oauthToken)
res.send(identity)
} catch (error) {
res.status(401).send({message: 'No identity found for OAuth token'})
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we're translating any GitHub API failure response into a 401. I wonder if we want to capture more details about the underlying failure that we got from the GitHub API. For example, if the user has exceeded their GitHub API rate limit, we'll get a 403 response from the GitHub API. In that case, the token is valid, but the user just needs to chill out for a bit. It might confuse the user if we say that there was "No identity found for the OAuth token." What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we definitely need to have more specific errors and audit downstream code paths for handling those errors in a specific way. I'd like to revisit our approach to handling server errors in general, possibly throwing appropriate exceptions from the rest gateway.

@atom-build atom-build temporarily deployed to atom-tachyon-staging-pr-20 September 27, 2017 17:13 Inactive
Signed-off-by: Antonio Scandurra <as-cii@github.com>
@nathansobo nathansobo temporarily deployed to atom-tachyon-staging-pr-20 September 28, 2017 11:44 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants