feat: auth0 + discord + github + slack auth modules
This commit is contained in:
@@ -15,9 +15,8 @@ module.exports = {
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL
|
||||
}, async (accessToken, refreshToken, extraParams, profile, cb) => {
|
||||
console.info(accessToken, refreshToken, extraParams, profile)
|
||||
try {
|
||||
const user = WIKI.models.users.processProfile({ profile, provider: 'auth0' })
|
||||
const user = await WIKI.models.users.processProfile({ profile, providerKey: 'auth0' })
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
|
@@ -5,6 +5,7 @@
|
||||
// ------------------------------------
|
||||
|
||||
const DiscordStrategy = require('passport-discord').Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
@@ -14,12 +15,20 @@ module.exports = {
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL,
|
||||
scope: 'identify email'
|
||||
}, function (accessToken, refreshToken, profile, cb) {
|
||||
WIKI.models.users.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...profile,
|
||||
displayName: profile.username,
|
||||
picture: `https://cdn.discordapp.com/avatars/${profile.id}/${profile.avatar}.png`
|
||||
},
|
||||
providerKey: 'discord'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
@@ -5,7 +5,16 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/discord.svg
|
||||
color: indigo lighten-2
|
||||
website: https://discordapp.com/
|
||||
isAvailable: true
|
||||
useForm: false
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
@@ -5,7 +5,16 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/facebook.svg
|
||||
color: indigo
|
||||
website: https://facebook.com/
|
||||
isAvailable: false
|
||||
useForm: false
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
34
server/modules/authentication/firebase/authentication.js
Normal file
34
server/modules/authentication/firebase/authentication.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/* global WIKI */
|
||||
|
||||
// ------------------------------------
|
||||
// GitHub Account
|
||||
// ------------------------------------
|
||||
|
||||
const GitHubStrategy = require('passport-github2').Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
passport.use('github',
|
||||
new GitHubStrategy({
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL,
|
||||
scope: ['user:email']
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...profile,
|
||||
picture: _.get(profile, 'photos[0].value', '')
|
||||
},
|
||||
providerKey: 'github'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
11
server/modules/authentication/firebase/definition.yml
Normal file
11
server/modules/authentication/firebase/definition.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
key: firebase
|
||||
title: Firebase
|
||||
description: Firebase is Google's mobile platform that helps you quickly develop high-quality apps and grow your business.
|
||||
author: requarks.io
|
||||
logo: https://static.requarks.io/logo/firebase.svg
|
||||
color: yellow darken-3
|
||||
website: https://firebase.google.com/
|
||||
isAvailable: false
|
||||
useForm: false
|
||||
props: {}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
// ------------------------------------
|
||||
|
||||
const GitHubStrategy = require('passport-github2').Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
@@ -14,12 +15,19 @@ module.exports = {
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL,
|
||||
scope: ['user:email']
|
||||
}, (accessToken, refreshToken, profile, cb) => {
|
||||
WIKI.models.users.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...profile,
|
||||
picture: _.get(profile, 'photos[0].value', '')
|
||||
},
|
||||
providerKey: 'github'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
@@ -5,7 +5,17 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/github.svg
|
||||
color: grey darken-3
|
||||
website: https://github.com
|
||||
isAvailable: true
|
||||
useForm: false
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
||||
|
@@ -5,7 +5,16 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/google.svg
|
||||
color: red darken-1
|
||||
website: https://console.developers.google.com/
|
||||
isAvailable: false
|
||||
useForm: false
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
@@ -13,12 +13,20 @@ module.exports = {
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL
|
||||
}, function (accessToken, refreshToken, profile, cb) {
|
||||
WIKI.models.users.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
console.info(profile)
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...profile,
|
||||
picture: _.get(profile, 'photos[0].value', '')
|
||||
},
|
||||
providerKey: 'microsoft'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
@@ -5,7 +5,20 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/microsoft.svg
|
||||
color: blue
|
||||
website: https://apps.dev.microsoft.com/
|
||||
isAvailable: false
|
||||
useForm: false
|
||||
scopes:
|
||||
- openid
|
||||
- profile
|
||||
- email
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
@@ -4,7 +4,8 @@
|
||||
// Slack Account
|
||||
// ------------------------------------
|
||||
|
||||
const SlackStrategy = require('passport-slack').Strategy
|
||||
const SlackStrategy = require('@aoberoi/passport-slack').default.Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
@@ -12,13 +13,21 @@ module.exports = {
|
||||
new SlackStrategy({
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL
|
||||
}, (accessToken, refreshToken, profile, cb) => {
|
||||
WIKI.models.users.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
callbackURL: conf.callbackURL,
|
||||
team: conf.team
|
||||
}, async (accessToken, scopes, team, extra, { user: userProfile }, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...userProfile,
|
||||
picture: _.get(userProfile, 'image_48', '')
|
||||
},
|
||||
providerKey: 'slack'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
@@ -5,7 +5,25 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/slack.svg
|
||||
color: green
|
||||
website: https://api.slack.com/docs/oauth
|
||||
isAvailable: true
|
||||
useForm: false
|
||||
scope:
|
||||
- identity.basic
|
||||
- identity.email
|
||||
- identity.avatar
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
team:
|
||||
type: String
|
||||
title: Team / Workspace ID
|
||||
hint: Optional - Your unique team (workspace) identifier
|
||||
order: 3
|
||||
|
@@ -5,7 +5,16 @@ author: requarks.io
|
||||
logo: https://static.requarks.io/logo/twitch.svg
|
||||
color: indigo darken-2
|
||||
website: https://dev.twitch.tv/docs/authentication/
|
||||
isAvailable: false
|
||||
useForm: false
|
||||
props:
|
||||
clientId: String
|
||||
clientSecret: String
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
|
Reference in New Issue
Block a user