Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Luc Bourdot
codimd
Commits
f871eff2
Unverified
Commit
f871eff2
authored
Nov 01, 2019
by
Yukai Huang
Committed by
GitHub
Nov 01, 2019
Browse files
Merge pull request #1327 from kamijin-fanta/github-enterprise
support to login with github enterprise
parents
7fd36b1b
9e6f980d
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/config/default.js
View file @
f871eff2
...
...
@@ -104,6 +104,7 @@ module.exports = {
consumerSecret
:
undefined
},
github
:
{
enterpriseURL
:
undefined
,
// if you use github.com, not need to specify
clientID
:
undefined
,
clientSecret
:
undefined
},
...
...
lib/config/environment.js
View file @
f871eff2
...
...
@@ -66,6 +66,7 @@ module.exports = {
consumerSecret
:
process
.
env
.
CMD_TWITTER_CONSUMERSECRET
},
github
:
{
enterpriseURL
:
process
.
env
.
CMD_GITHUB_ENTERPRISE_URL
,
clientID
:
process
.
env
.
CMD_GITHUB_CLIENTID
,
clientSecret
:
process
.
env
.
CMD_GITHUB_CLIENTSECRET
},
...
...
lib/models/user.js
View file @
f871eff2
...
...
@@ -103,7 +103,8 @@ module.exports = function (sequelize, DataTypes) {
else
photo
+=
'
?size=bigger
'
break
case
'
github
'
:
photo
=
'
https://avatars.githubusercontent.com/u/
'
+
profile
.
id
if
(
profile
.
photos
&&
profile
.
photos
[
0
])
photo
=
profile
.
photos
[
0
].
value
.
replace
(
'
?
'
,
''
)
else
photo
=
'
https://avatars.githubusercontent.com/u/
'
+
profile
.
id
if
(
bigger
)
photo
+=
'
?s=400
'
else
photo
+=
'
?s=96
'
break
...
...
lib/web/auth/github/index.js
View file @
f871eff2
...
...
@@ -6,13 +6,21 @@ const GithubStrategy = require('passport-github').Strategy
const
config
=
require
(
'
../../../config
'
)
const
response
=
require
(
'
../../../response
'
)
const
{
setReturnToFromReferer
,
passportGeneralCallback
}
=
require
(
'
../utils
'
)
const
{
URL
}
=
require
(
'
url
'
)
const
githubAuth
=
module
.
exports
=
Router
()
function
githubUrl
(
path
)
{
return
config
.
github
.
enterpriseURL
&&
new
URL
(
path
,
config
.
github
.
enterpriseURL
).
toString
()
}
passport
.
use
(
new
GithubStrategy
({
clientID
:
config
.
github
.
clientID
,
clientSecret
:
config
.
github
.
clientSecret
,
callbackURL
:
config
.
serverURL
+
'
/auth/github/callback
'
callbackURL
:
config
.
serverURL
+
'
/auth/github/callback
'
,
authorizationURL
:
githubUrl
(
'
login/oauth/authorize
'
),
tokenURL
:
githubUrl
(
'
login/oauth/access_token
'
),
userProfileURL
:
githubUrl
(
'
api/v3/user
'
)
},
passportGeneralCallback
))
githubAuth
.
get
(
'
/auth/github
'
,
function
(
req
,
res
,
next
)
{
...
...
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