feat: added auth0, discord, twitch auth modules

This commit is contained in:
NGPixel
2017-12-31 14:40:28 -05:00
parent a4e0e6d35c
commit a155af20f5
15 changed files with 164 additions and 24 deletions

View File

@@ -0,0 +1,30 @@
/* global wiki */
// ------------------------------------
// Auth0 Account
// ------------------------------------
const Auth0Strategy = require('passport-auth0').Strategy
module.exports = {
key: 'auth0',
title: 'Auth0',
useForm: false,
props: ['domain', 'clientId', 'clientSecret'],
init (passport, conf) {
passport.use('auth0',
new Auth0Strategy({
domain: conf.domain,
clientID: conf.clientId,
clientSecret: conf.clientSecret,
callbackURL: conf.callbackURL
}, function (accessToken, refreshToken, profile, cb) {
wiki.db.User.processProfile(profile).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
}
))
}
}

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'azure',
title: 'Azure Active Directory',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL', 'resource', 'tenant'],
props: ['clientId', 'clientSecret', 'resource', 'tenant'],
init (passport, conf) {
const jwt = require('jsonwebtoken')
passport.use('azure_ad_oauth2',

View File

@@ -0,0 +1,30 @@
/* global wiki */
// ------------------------------------
// Discord Account
// ------------------------------------
const DiscordStrategy = require('passport-discord').Strategy
module.exports = {
key: 'discord',
title: 'Discord',
useForm: false,
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('discord',
new DiscordStrategy({
clientID: conf.clientId,
clientSecret: conf.clientSecret,
callbackURL: conf.callbackURL,
scope: 'identify email'
}, function (accessToken, refreshToken, profile, cb) {
wiki.db.User.processProfile(profile).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
}
))
}
}

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'facebook',
title: 'Facebook',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL'],
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('facebook',
new FacebookStrategy({

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'github',
title: 'GitHub',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL'],
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('github',
new GitHubStrategy({

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'google',
title: 'Google ID',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL'],
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('google',
new GoogleStrategy({

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'microsoft',
title: 'Microsoft Account',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL'],
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('microsoft',
new WindowsLiveStrategy({

View File

@@ -10,7 +10,7 @@ module.exports = {
key: 'slack',
title: 'Slack',
useForm: false,
props: ['clientId', 'clientSecret', 'callbackURL'],
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('slack',
new SlackStrategy({

View File

@@ -0,0 +1,30 @@
/* global wiki */
// ------------------------------------
// Twitch Account
// ------------------------------------
const TwitchStrategy = require('passport-twitch').Strategy
module.exports = {
key: 'twitch',
title: 'Twitch',
useForm: false,
props: ['clientId', 'clientSecret'],
init (passport, conf) {
passport.use('twitch',
new TwitchStrategy({
clientID: conf.clientId,
clientSecret: conf.clientSecret,
callbackURL: conf.callbackURL,
scope: 'user_read'
}, function (accessToken, refreshToken, profile, cb) {
wiki.db.User.processProfile(profile).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
}
))
}
}