loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit bec362a3158db9312bb26a614c167e9ea5379484
parent 3b7bab5940ec31194d3483a195ea5a2866ae55ba
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Wed, 18 Oct 2017 17:32:18 +0200

Merge pull request #48 from lhopki01/master

add domain to google oauth jwt
Diffstat:
Mmodel/user_info.go | 1+
Moauth2/google.go | 5++++-
Moauth2/google_test.go | 7+++++--
3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/model/user_info.go b/model/user_info.go @@ -15,6 +15,7 @@ type UserInfo struct { Origin string `json:"origin,omitempty"` Expiry int64 `json:"exp,omitempty"` Refreshes int `json:"refs,omitempty"` + Domain string `json:"domain,omitempty"` } // Valid lets us use the user info as Claim for jwt-go. diff --git a/oauth2/google.go b/oauth2/google.go @@ -3,10 +3,11 @@ package oauth2 import ( "encoding/json" "fmt" - "github.com/tarent/loginsrv/model" "io/ioutil" "net/http" "strings" + + "github.com/tarent/loginsrv/model" ) var googleAPI = "https://www.googleapis.com/plus/v1" @@ -23,6 +24,7 @@ type GoogleUser struct { Image struct { Url string } + Domain string } var providerGoogle = Provider{ @@ -66,6 +68,7 @@ var providerGoogle = Provider{ Name: gu.DisplayName, Email: gu.Emails[0].Value, Origin: "google", + Domain: gu.Domain, }, string(b), nil }, } diff --git a/oauth2/google_test.go b/oauth2/google_test.go @@ -1,10 +1,11 @@ package oauth2 import ( - . "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" + + . "github.com/stretchr/testify/assert" ) var googleTestUserResponse = `{ @@ -31,7 +32,8 @@ var googleTestUserResponse = `{ }, "isPlusUser": true, "circledByCount": 0, - "verified": false + "verified": false, + "domain": "gmail.com" }` func Test_Google_getUserInfo(t *testing.T) { @@ -49,5 +51,6 @@ func Test_Google_getUserInfo(t *testing.T) { Equal(t, "test@gmail.com", u.Sub) Equal(t, "test@gmail.com", u.Email) Equal(t, "Testy Test", u.Name) + Equal(t, "gmail.com", u.Domain) Equal(t, googleTestUserResponse, rawJSON) }