feat: gitlab auth module + storage locale namespacing fix
This commit is contained in:
@@ -267,7 +267,7 @@ export default {
|
||||
if (this.$store.get('editor/mode') === 'create') {
|
||||
window.location.assign(`/`)
|
||||
} else {
|
||||
window.location.assign(`/${this.$store.get('page/path')}`)
|
||||
window.location.assign(`/${this.$store.get('page/locale')}/${this.$store.get('page/path')}`)
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
1
client/static/svg/auth-icon-gitlab.svg
Normal file
1
client/static/svg/auth-icon-gitlab.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 2500 2305" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><path d="M1250.72,2305.57l-1209.86,-879.014c-33.288,-24.189 -47.306,-67.341 -34.589,-106.475l139.78,-430.219l-0.005,-0.005l0.01,-0.01l-0.005,0.015l1104.67,1415.7l-0.006,-0.017l-1104.65,-1415.68l-0.007,0l0.002,-0.007l-0.002,-0.003l0.003,0l277.047,-852.676c14.249,-43.867 76.319,-43.877 90.577,0l277.037,852.676l0.004,0l0.003,0.01l920.003,0l0.003,-0.01l0.004,0l277.047,-852.676c14.258,-43.877 76.328,-43.867 90.576,0l277.048,852.676l0.003,0l-0.002,0.003l0.002,0.007l-0.007,0l-1104.66,1415.68l-0.013,0.038l1104.68,-1415.72l0,-0.01l139.785,430.234c12.715,39.136 -1.308,82.289 -34.599,106.475l-1209.86,879.023l-0.009,0l-0.003,-0.009Z" style="fill:#fff;fill-rule:nonzero;"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -123,6 +123,7 @@
|
||||
"passport-dropbox-oauth2": "1.1.0",
|
||||
"passport-facebook": "3.0.0",
|
||||
"passport-github2": "0.1.11",
|
||||
"passport-gitlab2": "5.0.0",
|
||||
"passport-google-oauth20": "2.0.0",
|
||||
"passport-jwt": "4.0.0",
|
||||
"passport-ldapauth": "2.1.3",
|
||||
|
||||
@@ -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