feat: authentication module refactor + added CAS module

This commit is contained in:
NGPixel
2018-07-08 11:16:45 -04:00
parent 9e2f1caaf7
commit fd8bf4dbff
32 changed files with 194 additions and 127 deletions

View File

@@ -7,14 +7,6 @@
const Auth0Strategy = require('passport-auth0').Strategy
module.exports = {
key: 'auth0',
title: 'Auth0',
useForm: false,
props: {
domain: String,
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('auth0',
new Auth0Strategy({

View File

@@ -0,0 +1,8 @@
key: auth0
title: Auth0
author: requarks.io
useForm: false
props:
domain: String
clientId: String
clientSecret: String

View File

@@ -7,21 +7,6 @@
const AzureAdOAuth2Strategy = require('passport-azure-ad-oauth2').Strategy
module.exports = {
key: 'azure',
title: 'Azure Active Directory',
useForm: false,
props: {
clientId: String,
clientSecret: String,
resource: {
type: String,
default: '00000002-0000-0000-c000-000000000000'
},
tenant: {
type: String,
default: 'YOUR_TENANT.onmicrosoft.com'
}
},
init (passport, conf) {
const jwt = require('jsonwebtoken')
passport.use('azure_ad_oauth2',

View File

@@ -0,0 +1,13 @@
key: azure
title: Azure Active Directory
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String
resource:
type: String,
default: '00000002-0000-0000-c000-000000000000'
tenant:
type: String,
default: YOUR_TENANT.onmicrosoft.com

View File

@@ -0,0 +1,24 @@
/* global WIKI */
// ------------------------------------
// CAS Account
// ------------------------------------
const CASStrategy = require('passport-cas').Strategy
module.exports = {
init (passport, conf) {
passport.use('cas',
new CASStrategy({
ssoBaseURL: conf.ssoBaseURL,
serverBaseURL: conf.serverBaseURL
}, (profile, cb) => {
WIKI.db.users.processProfile(profile).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
}
))
}
}

View File

@@ -0,0 +1,7 @@
key: cas
title: CAS
author: requarks.io
useForm: false
props:
ssoBaseURL: String
serverBaseURL: String

View File

@@ -7,13 +7,6 @@
const DiscordStrategy = require('passport-discord').Strategy
module.exports = {
key: 'discord',
title: 'Discord',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('discord',
new DiscordStrategy({

View File

@@ -0,0 +1,7 @@
key: discord
title: Discord
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,13 +7,6 @@
const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
module.exports = {
key: 'dropbox',
title: 'Dropbox',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('dropbox',
new DropboxStrategy({

View File

@@ -0,0 +1,7 @@
key: dropbox
title: Dropbox
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,13 +7,6 @@
const FacebookStrategy = require('passport-facebook').Strategy
module.exports = {
key: 'facebook',
title: 'Facebook',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('facebook',
new FacebookStrategy({

View File

@@ -0,0 +1,7 @@
key: facebook
title: Facebook
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,13 +7,6 @@
const GitHubStrategy = require('passport-github2').Strategy
module.exports = {
key: 'github',
title: 'GitHub',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('github',
new GitHubStrategy({

View File

@@ -0,0 +1,7 @@
key: github
title: GitHub
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,13 +7,6 @@
const GoogleStrategy = require('passport-google-oauth20').Strategy
module.exports = {
key: 'google',
title: 'Google',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('google',
new GoogleStrategy({

View File

@@ -0,0 +1,7 @@
key: google
title: Google
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -8,33 +8,6 @@ const LdapStrategy = require('passport-ldapauth').Strategy
const fs = require('fs')
module.exports = {
key: 'ldap',
title: 'LDAP / Active Directory',
useForm: true,
props: {
url: {
type: String,
default: 'ldap://serverhost:389'
},
bindDn: {
type: String,
default: `cn='root'`
},
bindCredentials: String,
searchBase: {
type: String,
default: 'o=users,o=example.com'
},
searchFilter: {
type: String,
default: '(uid={{username}})'
},
tlsEnabled: {
type: Boolean,
default: false
},
tlsCertPath: String
},
init (passport, conf) {
passport.use('ldapauth',
new LdapStrategy({

View File

@@ -0,0 +1,22 @@
key: ldap
title: LDAP / Active Directory
author: requarks.io
useForm: true
props:
url:
type: String
default: 'ldap://serverhost:389'
bindDn:
type: String
default: cn='root'
bindCredentials: String
searchBase:
type: String
default: 'o=users,o=example.com'
searchFilter:
type: String
default: '(uid={{username}})'
tlsEnabled:
type: Boolean
default: false
tlsCertPath: String

View File

@@ -7,10 +7,6 @@
const LocalStrategy = require('passport-local').Strategy
module.exports = {
key: 'local',
title: 'Local',
useForm: true,
props: {},
init (passport, conf) {
passport.use('local',
new LocalStrategy({

View File

@@ -0,0 +1,5 @@
key: local
title: Local
author: requarks.io
useForm: true
props: {}

View File

@@ -7,13 +7,6 @@
const WindowsLiveStrategy = require('passport-windowslive').Strategy
module.exports = {
key: 'microsoft',
title: 'Microsoft Account',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('microsoft',
new WindowsLiveStrategy({

View File

@@ -0,0 +1,7 @@
key: microsoft
title: Microsoft Account
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,15 +7,6 @@
const OAuth2Strategy = require('passport-oauth2').Strategy
module.exports = {
key: 'oauth2',
title: 'OAuth2',
useForm: false,
props: {
clientId: String,
clientSecret: String,
authorizationURL: String,
tokenURL: String
},
init (passport, conf) {
passport.use('oauth2',
new OAuth2Strategy({

View File

@@ -0,0 +1,9 @@
key: oauth2
title: OAuth2
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String
authorizationURL: String
tokenURL: String

View File

@@ -7,13 +7,6 @@
const SlackStrategy = require('passport-slack').Strategy
module.exports = {
key: 'slack',
title: 'Slack',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('slack',
new SlackStrategy({

View File

@@ -0,0 +1,7 @@
key: slack
title: Slack
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String

View File

@@ -7,13 +7,6 @@
const TwitchStrategy = require('passport-twitch').Strategy
module.exports = {
key: 'twitch',
title: 'Twitch',
useForm: false,
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('twitch',
new TwitchStrategy({

View File

@@ -0,0 +1,7 @@
key: twitch
title: Twitch
author: requarks.io
useForm: false
props:
clientId: String
clientSecret: String