mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
6fde3632ef
The vendor/ folder was created with the help of @FiloSottile's gvt and vendorcheck. Any dependencies of Caddy plugins outside this repo are not vendored. We do not remove any unused, vendored packages because vendorcheck -u only checks using the current build configuration; i.e. packages that may be imported by files toggled by build tags of other systems. CI tests have been updated to ignore the vendor/ folder. When Go 1.9 is released, a few of the go commands should be revised to again use ./... as it will ignore the vendor folder by default.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright 2014 Google Inc. All rights reserved.
|
|
// Use of this source code is governed by the Apache 2.0
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build !appengine
|
|
|
|
package user
|
|
|
|
import (
|
|
"golang.org/x/net/context"
|
|
|
|
"google.golang.org/appengine/internal"
|
|
)
|
|
|
|
// Current returns the currently logged-in user,
|
|
// or nil if the user is not signed in.
|
|
func Current(c context.Context) *User {
|
|
h := internal.IncomingHeaders(c)
|
|
u := &User{
|
|
Email: h.Get("X-AppEngine-User-Email"),
|
|
AuthDomain: h.Get("X-AppEngine-Auth-Domain"),
|
|
ID: h.Get("X-AppEngine-User-Id"),
|
|
Admin: h.Get("X-AppEngine-User-Is-Admin") == "1",
|
|
FederatedIdentity: h.Get("X-AppEngine-Federated-Identity"),
|
|
FederatedProvider: h.Get("X-AppEngine-Federated-Provider"),
|
|
}
|
|
if u.Email == "" && u.FederatedIdentity == "" {
|
|
return nil
|
|
}
|
|
return u
|
|
}
|
|
|
|
// IsAdmin returns true if the current user is signed in and
|
|
// is currently registered as an administrator of the application.
|
|
func IsAdmin(c context.Context) bool {
|
|
h := internal.IncomingHeaders(c)
|
|
return h.Get("X-AppEngine-User-Is-Admin") == "1"
|
|
}
|