-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
server, ui: login: template logged in user into index.html #25195
Conversation
18e200f
to
4099f7d
Compare
Reviewed 4 of 4 files at r1. pkg/server/authentication.go, line 309 at r1 (raw file):
suggest reversing the logic so the zero value is the safe one... pkg/server/authentication.go, line 313 at r1 (raw file):
suggest exposing two different constructors rather than passing in the bool pkg/server/authentication.go, line 327 at r1 (raw file):
i think i made this comment on the original pr... i don't think we should be returning the error. we should log it, but the actor attempting to log in shouldn't be able to see details beyond the status code. pkg/server/authentication.go, line 332 at r1 (raw file):
probably worth updating tests to reflect this pkg/server/server.go, line 1450 at r1 (raw file):
are you sure you want to move this all the way down here? if so, the comment isn't really relevant anymore... pkg/server/server.go, line 1459 at r1 (raw file):
suggest moving this to a new file and adding tests for the various cases. pkg/server/server.go, line 1478 at r1 (raw file):
pkg/ui/ui.go, line 101 at r1 (raw file):
if we can get these to be build-time rather than code-time, that would be ideal, but if that's too complicated hard-coding isn't that bad. Comments from Reviewable |
It's my opinion that, rather than having index.html be generated with "loggedInUser" set, we should have the authenticationMux set a second, non-httponly cookie on the outgoing response which contains the logged in user name. I think that the index.html generation here is a bit heavy-handed for this particular enhancement. Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. pkg/server/authentication.go, line 313 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
+1 pkg/server/authentication.go, line 327 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Agreed, this could unintentionally leak details to an unauthenticated client. Comments from Reviewable |
a reasonable perspective, however, this also seems like a good strategy for addressing #19024 |
Thanks @mrtracy; I hadn't really considered passing the username as a cookie accessible from JS. In past projects, a server-templated JS object has proven useful for a lot of things (version, auth, data loading, feature flags, etc) so I figured it was worth introducing, despite maybe not being the most expedient way to do login. |
4099f7d
to
0dab315
Compare
Review status: 1 of 4 files reviewed at latest revision, 8 unresolved discussions. pkg/server/authentication.go, line 309 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Done. pkg/server/authentication.go, line 313 at r1 (raw file): Previously, mrtracy (Matt Tracy) wrote…
Done, although the names are clunky. Lmk if you have better ideas. pkg/server/server.go, line 1478 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Done. Thanks; this didn't seem idiomatic and somehow I forgot about pkg/ui/ui.go, line 101 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Yeah, I couldn't think of a way of passing them that was worth the complexity. The names of the three bundles were hardcoded in the webpack config anyway, so we haven't really increased the amount of hardcoding. Comments from Reviewable |
eec27f0
to
30a03be
Compare
Update: after some debugging with Andrei, looks like the crash should be fixed by #24945. The problem was that in |
30a03be
to
9112cb6
Compare
Review status: 0 of 8 files reviewed at latest revision, 2 unresolved discussions. pkg/server/authentication.go, line 313 at r1 (raw file): Previously, vilterp (Pete Vilter) wrote…
I just removed "DisallowAnonymous" since that's considered the default. pkg/server/authentication.go, line 327 at r1 (raw file): Previously, mrtracy (Matt Tracy) wrote…
Updated to log the real error and then respond with a generic error. Comments from Reviewable |
@mrtracy would you please take one more look at this when you get a chance? |
Review status: 0 of 8 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. pkg/server/authentication.go, line 327 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Isn't this going to log "Web Session Error" when you load up index.html the first time, without yet having logged in? Comments from Reviewable |
Had a comment on the log message for unauthenticated requests, otherwise this is Review status: 0 of 8 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. Comments from Reviewable |
Review status: 0 of 8 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. pkg/server/authentication.go, line 327 at r1 (raw file): Previously, mrtracy (Matt Tracy) wrote…
Indeed. I think we still want to log if it hits any but the first conditional in Actually, I think Comments from Reviewable |
9112cb6
to
e9d50cb
Compare
Reviewed 4 of 8 files at r2, 4 of 4 files at r3. pkg/server/authentication.go, line 327 at r1 (raw file): Previously, couchand (Andrew Couch) wrote…
Nevermind on that last point, it's too much work for too little benefit. I just pushed it inside the Comments from Reviewable |
e9d50cb
to
6f7e4d7
Compare
...instead of serving a static index.html generated at build time via a webpack plugin. This allows the UI to decide whether it needs to show a login UI (and show the logged in username if there is one) without making an additional request to the backend. Release note: None
Release note: None
Release note: None
Release note: None
6f7e4d7
to
fbc5c5a
Compare
bors r+ |
25195: server, ui: login: template logged in user into index.html r=couchand a=vilterp ...instead of serving a static index.html generated at build time via a webpack plugin. This allows the UI to decide whether it needs to show a login UI (and show the logged in username if there is one) without making an additional request to the backend. Fixes #25171 TODO: - [x] make sure this doesn't break `make buildshort` - [x] favicon not showing up - tests - [x] insecure: can get assets, index.html doesn't have user - secure - [x] logged out: can get assets, index.html doesn't have user - [x] logged in: can get assets, index.html has user - [x] fix race condition where health check endpoint crashes server before it's fully started up Release note: None Co-authored-by: Pete Vilter <[email protected]> Co-authored-by: Andrew Couch <[email protected]>
Build succeeded |
By telling Webpack to proxy the path `/` through to the Cockroach process. Webpack used to serve `/` itself from a static file, but as of cockroachdb#25195 we generate `/` dynamically in Go, so we can use it to pass login state to the UI. Fixes cockroachdb#25858 Release note: None
By telling Webpack to proxy the path `/` through to the Cockroach process. Webpack used to serve `/` itself from a static file, but as of cockroachdb#25195 we generate `/` dynamically in Go, so we can use it to pass login state to the UI. Fixes cockroachdb#25858 Release note: None
25868: sql: Log event for TRUNCATE TABLE r=a-robinson a=a-robinson Fixes #25867 Release note (sql change): TRUNCATE TABLE commands are now logged in the event log. 25871: ui: unbreak `make watch` r=vilterp a=vilterp By telling Webpack to proxy the path `/` through to the Cockroach process. Webpack used to serve `/` itself from a static file, but as of #25195 we generate `/` dynamically in Go, so we can use it to pass login state to the UI. Fixes #25858 Release note: None 25875: ui: fix action names broken by #25823 r=couchand a=couchand In that PR, I mechanically replaced identifiers when there were new warnings about shadowing, but in two places I accidentally changed semantics due to the shorthand form of object literals. 🤦♂️ Release note: None Co-authored-by: Alex Robinson <[email protected]> Co-authored-by: Pete Vilter <[email protected]> Co-authored-by: Andrew Couch <[email protected]>
Better separate concerns by making package ui responsible for providing an HTTP handler that can serve its assets. As a side effect of the refactor, fix rendering of the "no UI installed" page in short binaries, which was broken in cockroachdb#25195. This is not pure code movement, so ui.Handler should be reviewed as if it were new code.
Better separate concerns by making package ui responsible for providing an HTTP handler that can serve its assets. As a side effect of the refactor, fix rendering of the "no UI installed" page in short binaries, which was broken in cockroachdb#25195. This is not pure code movement, so ui.Handler should be reviewed as if it were new code.
Better separate concerns by making package ui responsible for providing an HTTP handler that can serve its assets. As a side effect of the refactor, fix rendering of the "no UI installed" page in short binaries, which was broken in cockroachdb#25195. This is not pure code movement, so ui.Handler should be reviewed as if it were new code. Release note: None
Better separate concerns by making package ui responsible for providing an HTTP handler that can serve its assets. As a side effect of the refactor, fix rendering of the "no UI installed" page in short binaries, which was broken in cockroachdb#25195. This is not pure code movement, so ui.Handler should be reviewed as if it were new code. Release note: None
...instead of serving a static index.html generated at build time via a webpack plugin. This allows the UI to decide whether it needs to show a login UI (and show the logged in username if there is one) without making an additional request to the backend.
Fixes #25171
TODO:
make buildshort
Release note: None