mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 02:05:21 -04:00
auth/index.ts: Refactor Gitlab & Dropbox middlewares
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
1353e61e87
commit
1903ba12af
2 changed files with 8 additions and 9 deletions
|
@ -1,13 +1,13 @@
|
||||||
|
import { NextFunction, Request, Response, Router } from 'express'
|
||||||
import passport from 'passport'
|
import passport from 'passport'
|
||||||
import { config } from '../../../config'
|
|
||||||
import { passportGeneralCallback } from '../utils'
|
|
||||||
import { Router, Response, NextFunction, Request } from 'express'
|
|
||||||
import * as DropboxStrategy from 'passport-dropbox-oauth2'
|
import * as DropboxStrategy from 'passport-dropbox-oauth2'
|
||||||
|
import { config } from '../../../config'
|
||||||
import { AuthMiddleware } from '../interface'
|
import { AuthMiddleware } from '../interface'
|
||||||
|
import { passportGeneralCallback } from '../utils'
|
||||||
|
|
||||||
export const dropboxAuth = Router()
|
export const dropboxAuth = Router()
|
||||||
|
|
||||||
export const EmailMiddleware: AuthMiddleware = {
|
export const DropboxMiddleware: AuthMiddleware = {
|
||||||
getMiddleware (): Router {
|
getMiddleware (): Router {
|
||||||
passport.use(new DropboxStrategy({
|
passport.use(new DropboxStrategy({
|
||||||
apiVersion: '2',
|
apiVersion: '2',
|
||||||
|
@ -27,5 +27,4 @@ export const EmailMiddleware: AuthMiddleware = {
|
||||||
)
|
)
|
||||||
return dropboxAuth
|
return dropboxAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { User } from '../../models'
|
||||||
import { FacebookMiddleware } from './facebook'
|
import { FacebookMiddleware } from './facebook'
|
||||||
import { TwitterMiddleware } from './twitter'
|
import { TwitterMiddleware } from './twitter'
|
||||||
import { GithubMiddleware } from './github'
|
import { GithubMiddleware } from './github'
|
||||||
import gitlab from './gitlab'
|
import { GitlabMiddleware } from './gitlab'
|
||||||
import dropbox from './dropbox'
|
import { DropboxMiddleware } from './dropbox'
|
||||||
import google from './google'
|
import google from './google'
|
||||||
import ldap from './ldap'
|
import ldap from './ldap'
|
||||||
import saml from './saml'
|
import saml from './saml'
|
||||||
|
@ -46,8 +46,8 @@ passport.deserializeUser(function (id: string, done) {
|
||||||
if (config.isFacebookEnable) AuthRouter.use(FacebookMiddleware.getMiddleware())
|
if (config.isFacebookEnable) AuthRouter.use(FacebookMiddleware.getMiddleware())
|
||||||
if (config.isTwitterEnable) AuthRouter.use(TwitterMiddleware.getMiddleware())
|
if (config.isTwitterEnable) AuthRouter.use(TwitterMiddleware.getMiddleware())
|
||||||
if (config.isGitHubEnable) AuthRouter.use(GithubMiddleware.getMiddleware())
|
if (config.isGitHubEnable) AuthRouter.use(GithubMiddleware.getMiddleware())
|
||||||
if (config.isGitLabEnable) AuthRouter.use(gitlab)
|
if (config.isGitLabEnable) AuthRouter.use(GitlabMiddleware.getMiddleware())
|
||||||
if (config.isDropboxEnable) AuthRouter.use(dropbox)
|
if (config.isDropboxEnable) AuthRouter.use(DropboxMiddleware.getMiddleware())
|
||||||
if (config.isGoogleEnable) AuthRouter.use(google)
|
if (config.isGoogleEnable) AuthRouter.use(google)
|
||||||
if (config.isLDAPEnable) AuthRouter.use(ldap)
|
if (config.isLDAPEnable) AuthRouter.use(ldap)
|
||||||
if (config.isSAMLEnable) AuthRouter.use(saml)
|
if (config.isSAMLEnable) AuthRouter.use(saml)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue