Skip to content

[WIP] work on #541 #731

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

Closed
wants to merge 6 commits into from
Closed

Conversation

Vertmo
Copy link
Contributor

@Vertmo Vertmo commented Oct 13, 2018

Before your pull request is reviewed and merged, please ensure that:

  • there are no linting errors -- npm run lint
  • your code is in a uniquely-named feature branch and has been rebased on top of the latest master. If you're asked to make more changes, make sure you rebase onto master then too!
  • your pull request is descriptively named and links to an issue number, i.e. Fixes #123
  • all the changes you wanted to do are made

I started work on #541 (adding API keys to a user profile). I already worked on the design of the "Advanced Settings" page, which you can find by clicking on "Advanced Settings" in the /account page (or by navigating to /account/advanced).
As you can see by the mockup, users won't be able to see keys on their interface (since we'll store them hashed), so the only time they'll be able to copy them will be at creation (I took inspiration in GitHub's Personal Access Token system).
Next, I'll be working on adding this keys to the database, and to add the logic to generate, hash them, and store them.

@Vertmo Vertmo force-pushed the generate-api-keys branch 3 times, most recently from 42b650e to a2ed20e Compare October 14, 2018 22:03
@catarak
Copy link
Member

catarak commented Oct 15, 2018

yay! i'm so excited there's progress happening on this front. i'll do an in-depth code review in a bit.

@Vertmo
Copy link
Contributor Author

Vertmo commented Oct 15, 2018

Now, this is starting to look good (in my opinion). I think there are still some modifications to do design wise (especially regarding the dialog when you create a key, which might not be up to standards), but I'd like your opinion on it before I go refining things anymore. Anyway take your time, I won't be here next week to check out your response anyway ^^

@Vertmo Vertmo force-pushed the generate-api-keys branch 2 times, most recently from 05f0a75 to 1123ce7 Compare October 24, 2018 18:32
Copy link
Member

@catarak catarak left a comment

Choose a reason for hiding this comment

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

Finally had a chance to take a look at this, and I added a couple of comments. I'm going to keep thinking about the overall design.

Do you have an idea about how to implement the api token authentication? I think it should be basic authentication, the same way that you can authenticate on the github api with your username and personal access token.

@@ -0,0 +1,74 @@
import PropTypes from 'prop-types';
Copy link
Member

Choose a reason for hiding this comment

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

I'm not totally convinced this should be a separate page. it might be nice if it were in a lower section on the settings page. This is the current design for the settings page, though obviously it is not totally implemented. Maybe it would make sense to put the "Advanced Settings" under the user settings with a dashed border?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, I don't think we should overwhelm "normal" users who are only interested in writing a few sketches with some advanced options like this; that's why I wanted to hide such advanced options on another page. But your guess is as good as mine.

@Vertmo
Copy link
Contributor Author

Vertmo commented Nov 4, 2018

Basic auth seems like the best way to do it yes, but we should also think of how the API will end up evolving. Right now we're only planning on using it for sketch uploads right ? Do you have an idea of which other features will be available through the API later on ?

@Vertmo Vertmo force-pushed the generate-api-keys branch from 25d1a7f to 4919f08 Compare November 4, 2018 12:46
@catarak
Copy link
Member

catarak commented Nov 5, 2018

For API features, I'm thinking pretty basic CRUD for sketches. The goal is for the web editor to be able to interface with other platforms, e.g. a user could have their code on the web editor and GitHub, could upload examples they have locally on their computer easily.

@Vertmo
Copy link
Contributor Author

Vertmo commented Nov 5, 2018

That makes sense. Should I'll get working on the basic authentification as soon as I can !

@Vertmo Vertmo force-pushed the generate-api-keys branch 2 times, most recently from 5caf307 to 9271124 Compare November 6, 2018 17:03
@Vertmo
Copy link
Contributor Author

Vertmo commented Nov 6, 2018

Okay, I have added a Strategy for Basic Auth using passport-http. Changes dans fixes asides, I think this is starting to look correct. Tell me what you think ^^

@catarak
Copy link
Member

catarak commented Nov 6, 2018

i'm not sure how to test if the basic authentication with the key is working. do you have a test route? also, i haven't had a chance to think about the design, but i will.

@Vertmo
Copy link
Contributor Author

Vertmo commented Nov 6, 2018

Locally yes, I added :
app.get('/temp', passport.authenticate('basic', { session: false }), (req, res) => res.json(req.user)); to server/server.js.

You can then test with curl -X GET --user username:base64(key) -i localhost:8000/temp.

@Vertmo
Copy link
Contributor Author

Vertmo commented Nov 20, 2018

@catarak Is there anything I can do to further progress on that front ?

@catarak
Copy link
Member

catarak commented Nov 20, 2018

sorry for the delay, i'm not sure! i have a bit of a backup of PR's and i'm trying to get through some of those right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants