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
aefbcb70
Commit
aefbcb70
authored
Apr 15, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1782 from williamjoy/master
#1781 try fix oauth with github enterprise - add config of api_url
parents
140f1307
4fd2622e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
conf/defaults.ini
+2
-0
conf/sample.ini
+2
-0
pkg/social/social.go
+4
-2
No files found.
conf/defaults.ini
View file @
aefbcb70
...
...
@@ -141,6 +141,7 @@ client_secret = some_secret
scopes
=
user:email
auth_url
=
https://github.com/login/oauth/authorize
token_url
=
https://github.com/login/oauth/access_token
api_url
=
https://api.github.com/user
# Uncomment bellow to only allow specific email domains
; allowed_domains = mycompany.com othercompany.com
...
...
@@ -152,6 +153,7 @@ client_secret = some_client_secret
scopes
=
https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
auth_url
=
https://accounts.google.com/o/oauth2/auth
token_url
=
https://accounts.google.com/o/oauth2/token
api_url
=
https://www.googleapis.com/oauth2/v1/userinfo
allowed_domains
=
#################################### Logging ##########################
...
...
conf/sample.ini
View file @
aefbcb70
...
...
@@ -141,6 +141,7 @@
;scopes = user:email
;auth_url = https://github.com/login/oauth/authorize
;token_url = https://github.com/login/oauth/access_token
;api_url = https://api.github.com/user
# Uncomment bellow to only allow specific email domains
; allowed_domains = mycompany.com othercompany.com
...
...
@@ -152,6 +153,7 @@
;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
;auth_url = https://accounts.google.com/o/oauth2/auth
;token_url = https://accounts.google.com/o/oauth2/token
;api_url = https://www.googleapis.com/oauth2/v1/userinfo
# Uncomment bellow to only allow specific email domains
; allowed_domains = mycompany.com othercompany.com
...
...
pkg/social/social.go
View file @
aefbcb70
...
...
@@ -49,6 +49,7 @@ func NewOAuthService() {
Scopes
:
sec
.
Key
(
"scopes"
)
.
Strings
(
" "
),
AuthUrl
:
sec
.
Key
(
"auth_url"
)
.
String
(),
TokenUrl
:
sec
.
Key
(
"token_url"
)
.
String
(),
APIUrl
:
sec
.
Key
(
"api_url"
)
.
String
(),
Enabled
:
sec
.
Key
(
"enabled"
)
.
MustBool
(),
AllowedDomains
:
sec
.
Key
(
"allowed_domains"
)
.
Strings
(
" "
),
}
...
...
@@ -72,7 +73,7 @@ func NewOAuthService() {
// GitHub.
if
name
==
"github"
{
setting
.
OAuthService
.
GitHub
=
true
SocialMap
[
"github"
]
=
&
SocialGithub
{
Config
:
&
config
,
allowedDomains
:
info
.
AllowedDomains
}
SocialMap
[
"github"
]
=
&
SocialGithub
{
Config
:
&
config
,
allowedDomains
:
info
.
AllowedDomains
,
APIUrl
:
info
.
APIUrl
}
}
// Google.
...
...
@@ -100,6 +101,7 @@ func isEmailAllowed(email string, allowedDomains []string) bool {
type
SocialGithub
struct
{
*
oauth2
.
Config
allowedDomains
[]
string
APIUrl
[]
string
}
func
(
s
*
SocialGithub
)
Type
()
int
{
...
...
@@ -119,7 +121,7 @@ func (s *SocialGithub) UserInfo(token *oauth2.Token) (*BasicUserInfo, error) {
var
err
error
client
:=
s
.
Client
(
oauth2
.
NoContext
,
token
)
r
,
err
:=
client
.
Get
(
"https://api.github.com/user"
)
r
,
err
:=
client
.
Get
(
s
.
APIUrl
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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