Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
665cf55e
Commit
665cf55e
authored
May 02, 2017
by
Dan Cech
Committed by
Torkel Ödegaard
May 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make generic oauth provider flexible enough to handle bitbucket's oauth implementation (#8248)
parent
b4cfb225
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
+26
-2
pkg/social/generic_oauth.go
+26
-2
No files found.
pkg/social/generic_oauth.go
View file @
665cf55e
...
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"github.com/grafana/grafana/pkg/models"
...
...
@@ -78,7 +79,9 @@ func (s *GenericOAuth) FetchPrivateEmail(client *http.Client) (string, error) {
type
Record
struct
{
Email
string
`json:"email"`
Primary
bool
`json:"primary"`
IsPrimary
bool
`json:"is_primary"`
Verified
bool
`json:"verified"`
IsConfirmed
bool
`json:"is_confirmed"`
}
emailsUrl
:=
fmt
.
Sprintf
(
s
.
apiUrl
+
"/emails"
)
...
...
@@ -91,14 +94,30 @@ func (s *GenericOAuth) FetchPrivateEmail(client *http.Client) (string, error) {
var
records
[]
Record
if
err
=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
records
);
err
!=
nil
{
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
if
err
!=
nil
{
return
""
,
err
}
err
=
json
.
Unmarshal
(
body
,
records
)
if
err
!=
nil
{
var
data
struct
{
Values
[]
Record
`json:"values"`
}
err
=
json
.
Unmarshal
(
body
,
&
data
)
if
err
!=
nil
{
return
""
,
err
}
records
=
data
.
Values
}
var
email
=
""
for
_
,
record
:=
range
records
{
if
record
.
Primary
{
if
record
.
Primary
||
record
.
IsPrimary
{
email
=
record
.
Email
break
}
}
...
...
@@ -162,6 +181,7 @@ func (s *GenericOAuth) FetchOrganizations(client *http.Client) ([]string, error)
func
(
s
*
GenericOAuth
)
UserInfo
(
client
*
http
.
Client
)
(
*
BasicUserInfo
,
error
)
{
var
data
struct
{
Name
string
`json:"name"`
DisplayName
string
`json:"display_name"`
Login
string
`json:"login"`
Username
string
`json:"username"`
Email
string
`json:"email"`
...
...
@@ -197,6 +217,10 @@ func (s *GenericOAuth) UserInfo(client *http.Client) (*BasicUserInfo, error) {
}
}
if
userInfo
.
Name
==
""
&&
data
.
DisplayName
!=
""
{
userInfo
.
Name
=
data
.
DisplayName
}
if
userInfo
.
Login
==
""
&&
data
.
Username
!=
""
{
userInfo
.
Login
=
data
.
Username
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment