initial commit

This commit is contained in:
Eric Chiang
2016-07-25 13:00:28 -07:00
commit cab271f304
1438 changed files with 335968 additions and 0 deletions
.gitignoreMakefile
cmd
connector
example
glide.lockglide.yamlglide_test.go
server
storage
vendor
github.com
ericchiang
golang
gorilla
gtank
inconshreveable
mitchellh
pquerna
spf13
golang.org
x
crypto
.gitattributes.gitignoreAUTHORSCONTRIBUTING.mdCONTRIBUTORSLICENSEPATENTSREADME
acme
bcrypt
blowfish
bn256
cast5
codereview.cfg
curve25519
ed25519
hkdf
md4
nacl
ocsp
openpgp
otr
pbkdf2
pkcs12
poly1305
ripemd160
salsa20
scrypt
sha3
ssh
tea
twofish
xtea
xts
net
.gitattributes.gitignoreAUTHORSCONTRIBUTING.mdCONTRIBUTORSLICENSEPATENTSREADME
bpf
codereview.cfg
context
dict
html
http2
icmp
idna
internal
ipv4
ipv6
lex
netutil
proxy
publicsuffix
route
trace
webdav
websocket
xsrftoken
oauth2
google.golang.org
appengine
.travis.ymlLICENSEREADME.md
aetest
appengine.goappengine_test.goappengine_vm.go
blobstore
capability
channel
cloudsql
cmd
datastore
delay
demos
errors.go
file
identity.go
image
internal
log
mail
memcache
module
namespace.gonamespace_test.go
remote_api
runtime
search
socket
taskqueue
timeout.go
urlfetch
user
xmpp
gopkg.in
asn1-ber.v1
ldap.v2
square
go-jose.v1
go-jose.v2
yaml.v2
version

52
vendor/google.golang.org/appengine/user/oauth.go generated vendored Normal file

@@ -0,0 +1,52 @@
// Copyright 2012 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.
package user
import (
"golang.org/x/net/context"
"google.golang.org/appengine/internal"
pb "google.golang.org/appengine/internal/user"
)
// CurrentOAuth returns the user associated with the OAuth consumer making this
// request. If the OAuth consumer did not make a valid OAuth request, or the
// scopes is non-empty and the current user does not have at least one of the
// scopes, this method will return an error.
func CurrentOAuth(c context.Context, scopes ...string) (*User, error) {
req := &pb.GetOAuthUserRequest{}
if len(scopes) != 1 || scopes[0] != "" {
// The signature for this function used to be CurrentOAuth(Context, string).
// Ignore the singular "" scope to preserve existing behavior.
req.Scopes = scopes
}
res := &pb.GetOAuthUserResponse{}
err := internal.Call(c, "user", "GetOAuthUser", req, res)
if err != nil {
return nil, err
}
return &User{
Email: *res.Email,
AuthDomain: *res.AuthDomain,
Admin: res.GetIsAdmin(),
ID: *res.UserId,
ClientID: res.GetClientId(),
}, nil
}
// OAuthConsumerKey returns the OAuth consumer key provided with the current
// request. This method will return an error if the OAuth request was invalid.
func OAuthConsumerKey(c context.Context) (string, error) {
req := &pb.CheckOAuthSignatureRequest{}
res := &pb.CheckOAuthSignatureResponse{}
err := internal.Call(c, "user", "CheckOAuthSignature", req, res)
if err != nil {
return "", err
}
return *res.OauthConsumerKey, err
}