feat: added auth0, discord, twitch auth modules
This commit is contained in:
30
server/extensions/authentication/auth0.js
Normal file
30
server/extensions/authentication/auth0.js
Normal 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
|
||||
})
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
@@ -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',
|
||||
|
30
server/extensions/authentication/discord.js
Normal file
30
server/extensions/authentication/discord.js
Normal 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
|
||||
})
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
@@ -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({
|
||||
|
@@ -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({
|
||||
|
@@ -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({
|
||||
|
@@ -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({
|
||||
|
@@ -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({
|
||||
|
30
server/extensions/authentication/twitch.js
Normal file
30
server/extensions/authentication/twitch.js
Normal 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
|
||||
})
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user