mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-03 00:19:57 -04:00
Remove mattermost integration
Signed-off-by: Erik Michelson <erik@liltv.de>
This commit is contained in:
parent
95355b8f01
commit
c976217c12
19 changed files with 7 additions and 125 deletions
|
@ -188,7 +188,6 @@ app.locals.authProviders = {
|
|||
twitter: config.isTwitterEnable,
|
||||
github: config.isGitHubEnable,
|
||||
gitlab: config.isGitLabEnable,
|
||||
mattermost: config.isMattermostEnable,
|
||||
dropbox: config.isDropboxEnable,
|
||||
google: config.isGoogleEnable,
|
||||
ldap: config.isLDAPEnable,
|
||||
|
|
|
@ -113,11 +113,6 @@ module.exports = {
|
|||
scope: undefined,
|
||||
version: 'v4'
|
||||
},
|
||||
mattermost: {
|
||||
baseURL: undefined,
|
||||
clientID: undefined,
|
||||
clientSecret: undefined
|
||||
},
|
||||
dropbox: {
|
||||
clientID: undefined,
|
||||
clientSecret: undefined,
|
||||
|
|
|
@ -42,10 +42,6 @@ if (fs.existsSync(basePath)) {
|
|||
clientID: getSecret('gitlab_clientID'),
|
||||
clientSecret: getSecret('gitlab_clientSecret')
|
||||
},
|
||||
mattermost: {
|
||||
clientID: getSecret('mattermost_clientID'),
|
||||
clientSecret: getSecret('mattermost_clientSecret')
|
||||
},
|
||||
dropbox: {
|
||||
clientID: getSecret('dropbox_clientID'),
|
||||
clientSecret: getSecret('dropbox_clientSecret'),
|
||||
|
|
|
@ -77,11 +77,6 @@ module.exports = {
|
|||
clientSecret: process.env.CMD_GITLAB_CLIENTSECRET,
|
||||
scope: process.env.CMD_GITLAB_SCOPE
|
||||
},
|
||||
mattermost: {
|
||||
baseURL: process.env.CMD_MATTERMOST_BASEURL,
|
||||
clientID: process.env.CMD_MATTERMOST_CLIENTID,
|
||||
clientSecret: process.env.CMD_MATTERMOST_CLIENTSECRET
|
||||
},
|
||||
oauth2: {
|
||||
providerName: process.env.CMD_OAUTH2_PROVIDERNAME,
|
||||
baseURL: process.env.CMD_OAUTH2_BASEURL,
|
||||
|
|
|
@ -67,11 +67,6 @@ module.exports = {
|
|||
clientSecret: process.env.HMD_GITLAB_CLIENTSECRET,
|
||||
scope: process.env.HMD_GITLAB_SCOPE
|
||||
},
|
||||
mattermost: {
|
||||
baseURL: process.env.HMD_MATTERMOST_BASEURL,
|
||||
clientID: process.env.HMD_MATTERMOST_CLIENTID,
|
||||
clientSecret: process.env.HMD_MATTERMOST_CLIENTSECRET
|
||||
},
|
||||
oauth2: {
|
||||
baseURL: process.env.HMD_OAUTH2_BASEURL,
|
||||
userProfileURL: process.env.HMD_OAUTH2_USER_PROFILE_URL,
|
||||
|
|
|
@ -116,7 +116,6 @@ config.isEmailEnable = config.email
|
|||
config.isOpenIDEnable = config.openID
|
||||
config.isGitHubEnable = config.github.clientID && config.github.clientSecret
|
||||
config.isGitLabEnable = config.gitlab.clientID && config.gitlab.clientSecret
|
||||
config.isMattermostEnable = config.mattermost.clientID && config.mattermost.clientSecret
|
||||
config.isLDAPEnable = config.ldap.url
|
||||
config.isSAMLEnable = config.saml.idpSsoUrl
|
||||
config.isOAuth2Enable = config.oauth2.clientID && config.oauth2.clientSecret
|
||||
|
|
|
@ -117,15 +117,6 @@ module.exports = function (sequelize, DataTypes) {
|
|||
photo = generateAvatarURL(profile.username)
|
||||
}
|
||||
break
|
||||
case 'mattermost':
|
||||
photo = profile.avatarUrl
|
||||
if (photo) {
|
||||
if (bigger) photo = photo.replace(/(\?s=)\d*$/i, '$1400')
|
||||
else photo = photo.replace(/(\?s=)\d*$/i, '$196')
|
||||
} else {
|
||||
photo = generateAvatarURL(profile.username)
|
||||
}
|
||||
break
|
||||
case 'dropbox':
|
||||
photo = generateAvatarURL('', profile.emails[0].value, bigger)
|
||||
break
|
||||
|
|
|
@ -38,7 +38,6 @@ if (config.isFacebookEnable) authRouter.use(require('./facebook'))
|
|||
if (config.isTwitterEnable) authRouter.use(require('./twitter'))
|
||||
if (config.isGitHubEnable) authRouter.use(require('./github'))
|
||||
if (config.isGitLabEnable) authRouter.use(require('./gitlab'))
|
||||
if (config.isMattermostEnable) authRouter.use(require('./mattermost'))
|
||||
if (config.isDropboxEnable) authRouter.use(require('./dropbox'))
|
||||
if (config.isGoogleEnable) authRouter.use(require('./google'))
|
||||
if (config.isLDAPEnable) authRouter.use(require('./ldap'))
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const Router = require('express').Router
|
||||
const passport = require('passport')
|
||||
const Mattermost = require('mattermost')
|
||||
const OAuthStrategy = require('passport-oauth2').Strategy
|
||||
const config = require('../../../config')
|
||||
const { passportGeneralCallback } = require('../utils')
|
||||
|
||||
const mattermost = new Mattermost.Client()
|
||||
|
||||
let mattermostAuth = module.exports = Router()
|
||||
|
||||
let mattermostStrategy = new OAuthStrategy({
|
||||
authorizationURL: config.mattermost.baseURL + '/oauth/authorize',
|
||||
tokenURL: config.mattermost.baseURL + '/oauth/access_token',
|
||||
clientID: config.mattermost.clientID,
|
||||
clientSecret: config.mattermost.clientSecret,
|
||||
callbackURL: config.serverURL + '/auth/mattermost/callback'
|
||||
}, passportGeneralCallback)
|
||||
|
||||
mattermostStrategy.userProfile = (accessToken, done) => {
|
||||
mattermost.setUrl(config.mattermost.baseURL)
|
||||
mattermost.token = accessToken
|
||||
mattermost.useHeaderToken()
|
||||
mattermost.getMe(
|
||||
(data) => {
|
||||
done(null, data)
|
||||
},
|
||||
(err) => {
|
||||
done(err)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
passport.use(mattermostStrategy)
|
||||
|
||||
mattermostAuth.get('/auth/mattermost', function (req, res, next) {
|
||||
passport.authenticate('oauth2')(req, res, next)
|
||||
})
|
||||
|
||||
// mattermost auth callback
|
||||
mattermostAuth.get('/auth/mattermost/callback',
|
||||
passport.authenticate('oauth2', {
|
||||
successReturnToOrRedirect: config.serverURL + '/',
|
||||
failureRedirect: config.serverURL + '/'
|
||||
})
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue