mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-19 05:19:35 +00:00
Upgraded from 99c19923, branch release-3.0. This required fetching or upgrading the following: * k8s.io/api to kubernetes-1.9.1 * k8s.io/apimachinery to kubernetes-1.9.1 * github.com/juju/ratelimit to 1.0.1 * github.com/spf13/pflag to 4c012f6d Also, update Scope's imports/function calls to be compatible with the new client.
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package aetest
|
|
|
|
import (
|
|
"hash/crc32"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"google.golang.org/appengine/user"
|
|
)
|
|
|
|
// Login causes the provided Request to act as though issued by the given user.
|
|
func Login(u *user.User, req *http.Request) {
|
|
req.Header.Set("X-AppEngine-User-Email", u.Email)
|
|
id := u.ID
|
|
if id == "" {
|
|
id = strconv.Itoa(int(crc32.Checksum([]byte(u.Email), crc32.IEEETable)))
|
|
}
|
|
req.Header.Set("X-AppEngine-User-Id", id)
|
|
req.Header.Set("X-AppEngine-User-Federated-Identity", u.Email)
|
|
req.Header.Set("X-AppEngine-User-Federated-Provider", u.FederatedProvider)
|
|
if u.Admin {
|
|
req.Header.Set("X-AppEngine-User-Is-Admin", "1")
|
|
} else {
|
|
req.Header.Set("X-AppEngine-User-Is-Admin", "0")
|
|
}
|
|
}
|
|
|
|
// Logout causes the provided Request to act as though issued by a logged-out
|
|
// user.
|
|
func Logout(req *http.Request) {
|
|
req.Header.Del("X-AppEngine-User-Email")
|
|
req.Header.Del("X-AppEngine-User-Id")
|
|
req.Header.Del("X-AppEngine-User-Is-Admin")
|
|
req.Header.Del("X-AppEngine-User-Federated-Identity")
|
|
req.Header.Del("X-AppEngine-User-Federated-Provider")
|
|
}
|