feat: gitlab auth module + storage locale namespacing fix
This commit is contained in:
@@ -21,14 +21,16 @@ module.exports = {
|
||||
...strategyInfo,
|
||||
...stg,
|
||||
config: _.sortBy(_.transform(stg.config, (res, value, key) => {
|
||||
const configData = _.get(strategyInfo.props, key, {})
|
||||
res.push({
|
||||
key,
|
||||
value: JSON.stringify({
|
||||
...configData,
|
||||
value
|
||||
const configData = _.get(strategyInfo.props, key, false)
|
||||
if (configData) {
|
||||
res.push({
|
||||
key,
|
||||
value: JSON.stringify({
|
||||
...configData,
|
||||
value
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}, []), 'key')
|
||||
}
|
||||
})
|
||||
|
@@ -22,14 +22,16 @@ module.exports = {
|
||||
syncInterval: targetInfo.syncInterval || targetInfo.schedule || 'P0D',
|
||||
syncIntervalDefault: targetInfo.schedule,
|
||||
config: _.sortBy(_.transform(tgt.config, (res, value, key) => {
|
||||
const configData = _.get(targetInfo.props, key, {})
|
||||
res.push({
|
||||
key,
|
||||
value: JSON.stringify({
|
||||
...configData,
|
||||
value
|
||||
const configData = _.get(targetInfo.props, key, false)
|
||||
if (configData) {
|
||||
res.push({
|
||||
key,
|
||||
value: JSON.stringify({
|
||||
...configData,
|
||||
value
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}, []), 'key')
|
||||
}
|
||||
})
|
||||
|
34
server/modules/authentication/gitlab/authentication.js
Normal file
34
server/modules/authentication/gitlab/authentication.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/* global WIKI */
|
||||
|
||||
// ------------------------------------
|
||||
// GitLab Account
|
||||
// ------------------------------------
|
||||
|
||||
const GitLabStrategy = require('passport-gitlab2').Strategy
|
||||
const _ = require('lodash')
|
||||
|
||||
module.exports = {
|
||||
init (passport, conf) {
|
||||
passport.use('gitlab',
|
||||
new GitLabStrategy({
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL,
|
||||
scope: ['read_user']
|
||||
}, async (accessToken, refreshToken, profile, cb) => {
|
||||
try {
|
||||
const user = await WIKI.models.users.processProfile({
|
||||
profile: {
|
||||
...profile,
|
||||
picture: _.get(profile, 'avatarUrl', '')
|
||||
},
|
||||
providerKey: 'gitlab'
|
||||
})
|
||||
cb(null, user)
|
||||
} catch (err) {
|
||||
cb(err, null)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
26
server/modules/authentication/gitlab/definition.yml
Normal file
26
server/modules/authentication/gitlab/definition.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
key: gitlab
|
||||
title: GitLab
|
||||
description: GitLab is a web-based DevOps lifecycle tool that provides a Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features.
|
||||
author: requarks.io
|
||||
logo: https://static.requarks.io/logo/gitlab.svg
|
||||
color: deep-orange
|
||||
website: https://gitlab.com
|
||||
isAvailable: true
|
||||
useForm: false
|
||||
props:
|
||||
clientId:
|
||||
type: String
|
||||
title: Client ID
|
||||
hint: Application Client ID
|
||||
order: 1
|
||||
clientSecret:
|
||||
type: String
|
||||
title: Client Secret
|
||||
hint: Application Client Secret
|
||||
order: 2
|
||||
baseUrl:
|
||||
type: String
|
||||
title: Base URL
|
||||
hint: For self-managed GitLab instances, define the base URL (e.g. https://gitlab.example.com). Leave default for GitLab.com SaaS (https://gitlab.com).
|
||||
default: https://gitlab.com
|
||||
order: 3
|
@@ -4,10 +4,36 @@ description: DigitalOcean provides developers and businesses a reliable, easy-to
|
||||
author: requarks.io
|
||||
logo: https://static.requarks.io/logo/digitalocean.svg
|
||||
website: https://www.digitalocean.com/products/spaces/
|
||||
isAvailable: false
|
||||
supportedModes:
|
||||
- push
|
||||
defaultMode: push
|
||||
schedule: false
|
||||
props:
|
||||
accessKeyId: String
|
||||
accessSecret: String
|
||||
region:
|
||||
type: String
|
||||
title: Region
|
||||
hint: The DigitalOcean datacenter region where the Space will be created.
|
||||
default: nyc3
|
||||
bucket: String
|
||||
enum:
|
||||
- ams3
|
||||
- fra1
|
||||
- nyc3
|
||||
- sfo2
|
||||
- sgp1
|
||||
order: 1
|
||||
spaceId:
|
||||
type: String
|
||||
title: Space Unique Name
|
||||
hint: The unique space name to create (e.g. wiki-johndoe)
|
||||
order: 2
|
||||
accessKeyId:
|
||||
type: String
|
||||
title: Access Key ID
|
||||
hint: The Access Key (Generated in API > Tokens/Keys > Spaces access keys).
|
||||
order: 3
|
||||
secretAccessKey :
|
||||
type: String
|
||||
title: Access Key Secret
|
||||
hint: The Access Key Secret for the Access Key ID you created above.
|
||||
order: 4
|
||||
|
@@ -59,24 +59,41 @@ module.exports = {
|
||||
},
|
||||
async created(page) {
|
||||
WIKI.logger.info(`(STORAGE/DISK) Creating file ${page.path}...`)
|
||||
const filePath = path.join(this.config.path, `${page.path}.${getFileExtension(page.contentType)}`)
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
const filePath = path.join(this.config.path, fileName)
|
||||
await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
|
||||
},
|
||||
async updated(page) {
|
||||
WIKI.logger.info(`(STORAGE/DISK) Updating file ${page.path}...`)
|
||||
const filePath = path.join(this.config.path, `${page.path}.${getFileExtension(page.contentType)}`)
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
const filePath = path.join(this.config.path, fileName)
|
||||
await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
|
||||
},
|
||||
async deleted(page) {
|
||||
WIKI.logger.info(`(STORAGE/DISK) Deleting file ${page.path}...`)
|
||||
const filePath = path.join(this.config.path, `${page.path}.${getFileExtension(page.contentType)}`)
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
const filePath = path.join(this.config.path, fileName)
|
||||
await fs.unlink(filePath)
|
||||
},
|
||||
async renamed(page) {
|
||||
WIKI.logger.info(`(STORAGE/DISK) Renaming file ${page.sourcePath} to ${page.destinationPath}...`)
|
||||
const sourceFilePath = path.join(this.config.path, `${page.sourcePath}.${getFileExtension(page.contentType)}`)
|
||||
const destinationFilePath = path.join(this.config.path, `${page.destinationPath}.${getFileExtension(page.contentType)}`)
|
||||
await fs.move(sourceFilePath, destinationFilePath, { overwrite: true })
|
||||
let sourceFilePath = `${page.sourcePath}.${getFileExtension(page.contentType)}`
|
||||
let destinationFilePath = `${page.destinationPath}.${getFileExtension(page.contentType)}`
|
||||
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
sourceFilePath = `${page.localeCode}/${sourceFilePath}`
|
||||
destinationFilePath = `${page.localeCode}/${destinationFilePath}`
|
||||
}
|
||||
await fs.move(path.join(this.config.path, sourceFilePath), path.join(this.config.path, destinationFilePath), { overwrite: true })
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -91,7 +108,10 @@ module.exports = {
|
||||
new stream.Transform({
|
||||
objectMode: true,
|
||||
transform: async (page, enc, cb) => {
|
||||
const fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
WIKI.logger.info(`(STORAGE/DISK) Dumping ${fileName}...`)
|
||||
const filePath = path.join(this.config.path, fileName)
|
||||
await fs.outputFile(filePath, pageHelper.injectPageMetadata(page), 'utf8')
|
||||
|
@@ -244,7 +244,10 @@ module.exports = {
|
||||
*/
|
||||
async created(page) {
|
||||
WIKI.logger.info(`(STORAGE/GIT) Committing new file ${page.path}...`)
|
||||
const fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
const filePath = path.join(this.repoPath, fileName)
|
||||
await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
|
||||
|
||||
@@ -260,7 +263,10 @@ module.exports = {
|
||||
*/
|
||||
async updated(page) {
|
||||
WIKI.logger.info(`(STORAGE/GIT) Committing updated file ${page.path}...`)
|
||||
const fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
const filePath = path.join(this.repoPath, fileName)
|
||||
await fs.outputFile(filePath, page.injectMetadata(), 'utf8')
|
||||
|
||||
@@ -276,7 +282,10 @@ module.exports = {
|
||||
*/
|
||||
async deleted(page) {
|
||||
WIKI.logger.info(`(STORAGE/GIT) Committing removed file ${page.path}...`)
|
||||
const fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
let fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
|
||||
await this.git.rm(`./${fileName}`)
|
||||
await this.git.commit(`docs: delete ${page.path}`, fileName, {
|
||||
@@ -290,8 +299,13 @@ module.exports = {
|
||||
*/
|
||||
async renamed(page) {
|
||||
WIKI.logger.info(`(STORAGE/GIT) Committing file move from ${page.sourcePath} to ${page.destinationPath}...`)
|
||||
const sourceFilePath = `${page.sourcePath}.${getFileExtension(page.contentType)}`
|
||||
const destinationFilePath = `${page.destinationPath}.${getFileExtension(page.contentType)}`
|
||||
let sourceFilePath = `${page.sourcePath}.${getFileExtension(page.contentType)}`
|
||||
let destinationFilePath = `${page.destinationPath}.${getFileExtension(page.contentType)}`
|
||||
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
sourceFilePath = `${page.localeCode}/${sourceFilePath}`
|
||||
destinationFilePath = `${page.localeCode}/${destinationFilePath}`
|
||||
}
|
||||
|
||||
await this.git.mv(`./${sourceFilePath}`, `./${destinationFilePath}`)
|
||||
await this.git.commit(`docs: rename ${page.sourcePath} to ${destinationFilePath}`, destinationFilePath, {
|
||||
@@ -338,6 +352,9 @@ module.exports = {
|
||||
objectMode: true,
|
||||
transform: async (page, enc, cb) => {
|
||||
const fileName = `${page.path}.${getFileExtension(page.contentType)}`
|
||||
if (WIKI.config.lang.namespacing && WIKI.config.lang.code !== page.localeCode) {
|
||||
fileName = `${page.localeCode}/${fileName}`
|
||||
}
|
||||
WIKI.logger.info(`(STORAGE/GIT) Adding ${fileName}...`)
|
||||
const filePath = path.join(this.repoPath, fileName)
|
||||
await fs.outputFile(filePath, pageHelper.injectPageMetadata(page), 'utf8')
|
||||
|
Reference in New Issue
Block a user