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

Side by Side Diff: server/auth/middleware.go

Issue 2830443003: auth: Refactor how authentication methods are passed to server/auth library. (Closed)
Patch Set: fix test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/auth/context_test.go ('k') | server/auth/state.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package auth
6
7 import (
8 "github.com/luci/luci-go/server/router"
9 )
10
11 // Authenticate returns a middleware that performs authentication.
12 //
13 // This is simplest form of this middleware that uses only one authentication
14 // method. It is sufficient in most cases.
15 //
16 // This middleware either updates the context by injecting the authentication
17 // state into it (enabling functions like CurrentIdentity and IsMember), or
18 // aborts the request with an HTTP 401 or HTTP 500 error.
19 //
20 // Note that it passes through anonymous requests. CurrentIdentity returns
21 // identity.AnonymousIdentity in this case. Use separate authorization layer to
22 // further restrict the access, if necessary.
23 func Authenticate(m Method) router.Middleware {
24 a := &Authenticator{Methods: []Method{m}}
25 return a.GetMiddleware()
26 }
OLDNEW
« no previous file with comments | « server/auth/context_test.go ('k') | server/auth/state.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698