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

Auth frontend #425

Merged
merged 5 commits into from
Dec 27, 2018
Merged

Auth frontend #425

merged 5 commits into from
Dec 27, 2018

Conversation

smacker
Copy link
Contributor

@smacker smacker commented Dec 20, 2018

I changed the token response to be compatible with our regular response format.

This PR doesn't cover proper serialization of responses, there are only a few new lines of code to create the same data shape for frontend. We can copy-past it from gitbase-web later or create some improved version.

I also introduced new /api/me endpoint. I think it belongs to auth service.

API js code is a little bit different (simpler) than what we did in other projects.
Apparently, we don't need all that checks if we follow correct types.

Implemented in separate PR:

  • frontend router
  • logout button

TODO:

w.Write(b)
}

func errorJSON(w http.ResponseWriter, r *http.Request, code int, errors ...error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this defined, but then http.Error is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just for testing. As I mentioned in PR description: "This PR doesn't cover proper serialization of responses"

Signed-off-by: Maxim Sukharev <[email protected]>
AllowedOrigins: []string{"*"},
// TODO: make it customizable
// we can't pass "*" because it's incompatible with "credentials: include" request
AllowedOrigins: []string{"http://127.0.0.1:3000"},
Copy link
Contributor

Choose a reason for hiding this comment

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

why 3000?

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 default dev port for create-react-app.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK thanks. Then maybe we could add a comment saying why this is here, it's not so obvious that this is required for development.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@carlosms
Copy link
Contributor

I have a question. Is it unavoidable to have client-side routing? It feels it might add complexity down the road.

Are there any problems with leaving the current if you have in this PR? Could it be used for now, and re-think if a router makes sense when we have a proper UI design?

@smacker
Copy link
Contributor Author

smacker commented Dec 26, 2018

Router is required by the issue description written by you.

Do you suggest to add more ifs for /login, /unauthorized, /logout?

@smacker smacker mentioned this pull request Dec 26, 2018
@carlosms
Copy link
Contributor

I'm not suggesting anything, and I'm not against using client-side routing. I was asking why is it needed.

Going through the alternatives in my mind I see I was not aware of the need for client-side routing because I was thinking on the way we defined the SSO OKR design doc, with separate endpoints for login and logout. Which in this case will probably complicate things too much, and it makes sense to keep it as a single page app with all the token logic in the same place.

On the other hand, if the goal of the frontend was to keep it as simple as possible, we could also skip routing and have the frontend work as the / path only, and use /login as api endpoint, just like this PR is doing right now.

Anyway I see the router already implemented in #433 so I guess there is no point in discussing if we need to implement it or not.

@carlosms
Copy link
Contributor

Link to issue: #399

@smacker
Copy link
Contributor Author

smacker commented Dec 26, 2018

I don't mind dropping routing PR if everybody agrees to change original requirements and serve everything on / (except callback from github). You can review the new code and let me know if you think we don't need it.

@carlosms
Copy link
Contributor

LGTM, we can discuss the need for a router in #433.

@smacker
Copy link
Contributor Author

smacker commented Dec 27, 2018

I apply 7 days rule here and merge.

@smacker smacker merged commit 2da3a3a into src-d:master Dec 27, 2018
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