| OLD | NEW |
| (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 } |
| OLD | NEW |