Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Issue 2830443003: auth: Refactor how authentication methods are passed to server/auth library. (Closed)

Created:
3 years, 8 months ago by Vadim Sh.
Modified:
3 years, 8 months ago
Reviewers:
iannucci, hinoka
CC:
chromium-reviews, infra-reviews+luci-go_chromium.org, maruel+w_chromium.org, tandrii+luci-go_chromium.org
Target Ref:
refs/heads/master
Project:
luci-go
Visibility:
Public.

Description

auth: Refactor how authentication methods are passed to server/auth library. This CL removes a bunch of highly confusing public functions and makes server/auth library more difficult to misuse. The changes: * Use auth.Authenticator{...} struct to represent an object that makes authentication, instead of aliasing []Method for this. Even though it makes instantiation more verbose, it is cleaner conceptually and has a room for extensions (like custom HTTP 401 handlers, etc). * Get rid of two separate auth.Use(...) and auth.Authenticate(...) funcs that almost always cargo-culted into very specific usage pattern. Now there's only one auth.Authenticate(Method) function that returns authenticating middleware. * Store *Authenticator in the context with the rest of authentication state. * Get rid of auth.Autologin. It was used in single place only, move it there. Update Milo to use fakeauth package for mocking auth state. Unfortunately, it caused non-essential expectation change that made this CL even scarier. R=iannucci@chromium.org BUG=712506 Review-Url: https://codereview.chromium.org/2830443003 Committed: https://github.com/luci/luci-go/commit/a539fb93ab9faa249f025c4fbbe75733ddbab6d1

Patch Set 1 #

Total comments: 3

Patch Set 2 : more tests #

Patch Set 3 : simplify public API more #

Total comments: 2

Patch Set 4 : nit #

Total comments: 12

Patch Set 5 : replies #

Patch Set 6 : fix test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+345 lines, -494 lines) Patch
M appengine/gaeauth/server/prpc.go View 1 chunk +4 lines, -2 lines 0 comments Download
M examples/appengine/helloworld_flexible/frontend/main.go View 1 2 1 chunk +1 line, -7 lines 0 comments Download
M examples/appengine/helloworld_standard/frontend/handler.go View 1 2 1 chunk +1 line, -2 lines 0 comments Download
M milo/appengine/common/middleware.go View 1 2 1 chunk +5 lines, -9 lines 0 comments Download
M milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/buildbot.build-Debug_page-_newline_1234.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/buildbot.build-Debug_page-_win_chromium_rel_ng_246309.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/buildbot.builder-Basic_Test_no_builds.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/buildbot.builder-Basic_Test_with_builds.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/frontpage-Basic_frontpage.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-Basic_successful_build.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-canceled.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-exception.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-expired.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-internal.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-link.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-nested.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-patch-failure.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-pending.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-pending-logdog.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-running.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-running-logdog.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-running-logdog-no-annotation-stream.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-timeout.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.build-build-unicode.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/expectations/swarming.log-Basic_log.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M milo/appengine/frontend/main_test.go View 3 chunks +2 lines, -23 lines 0 comments Download
M scheduler/appengine/frontend/handler.go View 2 chunks +2 lines, -6 lines 0 comments Download
M scheduler/appengine/ui/common.go View 1 2 2 chunks +6 lines, -1 line 0 comments Download
M server/auth/auth.go View 1 2 3 4 6 chunks +73 lines, -29 lines 0 comments Download
M server/auth/auth_test.go View 1 2 3 4 5 9 chunks +112 lines, -16 lines 0 comments Download
M server/auth/authtest/method.go View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M server/auth/authtest/state.go View 2 chunks +10 lines, -3 lines 0 comments Download
D server/auth/context.go View 1 chunk +0 lines, -128 lines 0 comments Download
D server/auth/context_test.go View 1 chunk +0 lines, -226 lines 0 comments Download
A server/auth/middleware.go View 1 2 1 chunk +26 lines, -0 lines 0 comments Download
M server/auth/state.go View 1 2 3 5 chunks +41 lines, -10 lines 0 comments Download
M server/settings/admin/handlers.go View 1 2 3 4 3 chunks +38 lines, -8 lines 0 comments Download

Messages

Total messages: 20 (10 generated)
Vadim Sh.
https://codereview.chromium.org/2830443003/diff/1/appengine/gaeauth/server/prpc.go File appengine/gaeauth/server/prpc.go (right): https://codereview.chromium.org/2830443003/diff/1/appengine/gaeauth/server/prpc.go#newcode14 appengine/gaeauth/server/prpc.go:14: Methods: []auth.Method{ This is more verbose, but I think ...
3 years, 8 months ago (2017-04-18 23:46:24 UTC) #1
Vadim Sh.
Actually... I'll probably remove an ability to pass multiple Methods to Authenticate(...) middleware. It's rarely ...
3 years, 8 months ago (2017-04-19 02:00:22 UTC) #2
Vadim Sh.
Ryan, FYI. https://codereview.chromium.org/2830443003/diff/40001/milo/appengine/common/middleware.go File milo/appengine/common/middleware.go (right): https://codereview.chromium.org/2830443003/diff/40001/milo/appengine/common/middleware.go#newcode60 milo/appengine/common/middleware.go:60: auth.Authenticate(server.CookieAuth), I think this should be fine: ...
3 years, 8 months ago (2017-04-19 02:40:12 UTC) #5
hinoka
https://codereview.chromium.org/2830443003/diff/40001/milo/appengine/common/middleware.go File milo/appengine/common/middleware.go (right): https://codereview.chromium.org/2830443003/diff/40001/milo/appengine/common/middleware.go#newcode60 milo/appengine/common/middleware.go:60: auth.Authenticate(server.CookieAuth), On 2017/04/19 02:40:12, Vadim Sh. wrote: > I ...
3 years, 8 months ago (2017-04-19 18:37:10 UTC) #6
iannucci
lgtm https://codereview.chromium.org/2830443003/diff/60001/milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html File milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html (right): https://codereview.chromium.org/2830443003/diff/60001/milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html#newcode27 milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html:27: <a href="http://fake/login?dest=%2Ffoobar">login</a> nit: let's use example.com TLD (https://www.iana.org/domains/reserved) ...
3 years, 8 months ago (2017-04-19 21:58:34 UTC) #8
Vadim Sh.
https://codereview.chromium.org/2830443003/diff/60001/milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html File milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html (right): https://codereview.chromium.org/2830443003/diff/60001/milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html#newcode27 milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html:27: <a href="http://fake/login?dest=%2Ffoobar">login</a> On 2017/04/19 21:58:34, iannucci wrote: > nit: ...
3 years, 8 months ago (2017-04-19 22:32:47 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2830443003/80001
3 years, 8 months ago (2017-04-19 22:33:34 UTC) #12
commit-bot: I haz the power
Try jobs failed on following builders: Luci-go Linux Trusty 32-on-64 Tester on luci.infra.try (JOB_FAILED, https://luci-milo.appspot.com/swarming/task/35a12b215fc7ce10) ...
3 years, 8 months ago (2017-04-19 22:37:43 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2830443003/100001
3 years, 8 months ago (2017-04-19 22:40:04 UTC) #17
commit-bot: I haz the power
3 years, 8 months ago (2017-04-19 22:53:45 UTC) #20
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as
https://github.com/luci/luci-go/commit/a539fb93ab9faa249f025c4fbbe75733ddbab6d1

Powered by Google App Engine
This is Rietveld 408576698