fix: github enterprise auth compatibility
This commit is contained in:
		@@ -9,13 +9,22 @@ const _ = require('lodash')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
  init (passport, conf) {
 | 
					  init (passport, conf) {
 | 
				
			||||||
    passport.use('github',
 | 
					    let githubConfig = {
 | 
				
			||||||
      new GitHubStrategy({
 | 
					 | 
				
			||||||
      clientID: conf.clientId,
 | 
					      clientID: conf.clientId,
 | 
				
			||||||
      clientSecret: conf.clientSecret,
 | 
					      clientSecret: conf.clientSecret,
 | 
				
			||||||
      callbackURL: conf.callbackURL,
 | 
					      callbackURL: conf.callbackURL,
 | 
				
			||||||
      scope: ['user:email']
 | 
					      scope: ['user:email']
 | 
				
			||||||
      }, async (accessToken, refreshToken, profile, cb) => {
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (conf.useEnterprise) {
 | 
				
			||||||
 | 
					      githubConfig.authorizationURL = `https://${conf.enterpriseDomain}/login/oauth/authorize`
 | 
				
			||||||
 | 
					      githubConfig.tokenURL = `https://${conf.enterpriseDomain}/login/oauth/access_token`
 | 
				
			||||||
 | 
					      githubConfig.userProfileURL = conf.enterpriseUserEndpoint
 | 
				
			||||||
 | 
					      githubConfig.userEmailURL  = `${conf.enterpriseUserEndpoint}/emails`
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    passport.use('github',
 | 
				
			||||||
 | 
					      new GitHubStrategy(githubConfig, async (accessToken, refreshToken, profile, cb) => {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          const user = await WIKI.models.users.processProfile({
 | 
					          const user = await WIKI.models.users.processProfile({
 | 
				
			||||||
            profile: {
 | 
					            profile: {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,4 +18,22 @@ props:
 | 
				
			|||||||
    title: Client Secret
 | 
					    title: Client Secret
 | 
				
			||||||
    hint: Application Client Secret
 | 
					    hint: Application Client Secret
 | 
				
			||||||
    order: 2
 | 
					    order: 2
 | 
				
			||||||
 | 
					  useEnterprise:
 | 
				
			||||||
 | 
					    type: Boolean
 | 
				
			||||||
 | 
					    title: Use GitHub Enterprise
 | 
				
			||||||
 | 
					    hint: Enable if you're using the self-hosted GitHub Enterprise version
 | 
				
			||||||
 | 
					    default: false
 | 
				
			||||||
 | 
					    order: 3
 | 
				
			||||||
 | 
					  enterpriseDomain:
 | 
				
			||||||
 | 
					    type: String
 | 
				
			||||||
 | 
					    title: GitHub Enterprise Domain
 | 
				
			||||||
 | 
					    hint: GitHub Enterprise Only - Domain of your installation (e.g. github.company.com). Leave blank otherwise.
 | 
				
			||||||
 | 
					    default: ''
 | 
				
			||||||
 | 
					    order: 4
 | 
				
			||||||
 | 
					  enterpriseUserEndpoint:
 | 
				
			||||||
 | 
					    type: String
 | 
				
			||||||
 | 
					    title: GitHub Enterprise User Endpoint
 | 
				
			||||||
 | 
					    hint: GitHub Enterprise Only - Endpoint to fetch user details (e.g. https://api.github.com/user). Leave blank otherwise.
 | 
				
			||||||
 | 
					    default: 'https://api.github.com/user'
 | 
				
			||||||
 | 
					    order: 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user