feat: auth + storage config improvements

pull/621/head
NGPixel 6 years ago
parent bb102c3356
commit 4643336e9d

@ -4,7 +4,6 @@
"dbaeumer.vscode-eslint",
"christian-kohler.path-intellisense",
"mrmlnc.vscode-puglint",
"robinbentley.sass-indented",
"octref.vetur"
]
}

@ -12,7 +12,7 @@
.body-2.grey--text.text--darken-1 Select which authentication strategies to enable:
.caption.grey--text.pb-2 Some strategies require additional configuration in their dedicated tab (when selected).
v-form
v-checkbox(
v-checkbox.my-1(
v-for='strategy in strategies'
v-model='strategy.isEnabled'
:key='strategy.key'
@ -27,14 +27,30 @@
v-form
v-subheader.pl-0 Strategy Configuration
.body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
v-text-field(
v-else
v-for='cfg in strategy.config'
:key='cfg.key'
:label='cfg.key'
v-model='cfg.value'
prepend-icon='settings_applications'
template(v-else, v-for='cfg in strategy.config')
v-select(
v-if='cfg.value.type === "string" && cfg.value.enum'
:items='cfg.value.enum'
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
prepend-icon='settings_applications'
)
v-switch(
v-else-if='cfg.value.type === "boolean"'
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
color='primary'
prepend-icon='settings_applications'
)
v-text-field(
v-else
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
prepend-icon='settings_applications'
)
v-divider
v-subheader.pl-0 Registration
.pr-3
@ -90,6 +106,9 @@ import strategiesQuery from 'gql/admin/auth/auth-query-strategies.gql'
import strategiesSaveMutation from 'gql/admin/auth/auth-mutation-save-strategies.gql'
export default {
filters: {
startCase(val) { return _.startCase(val) }
},
data() {
return {
groups: [],
@ -122,7 +141,7 @@ export default {
'selfRegistration',
'domainWhitelist',
'autoEnrollGroups'
]))
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))}))
}
})
this.$store.commit('showNotification', {
@ -137,7 +156,7 @@ export default {
strategies: {
query: strategiesQuery,
fetchPolicy: 'network-only',
update: (data) => _.cloneDeep(data.authentication.strategies),
update: (data) => _.cloneDeep(data.authentication.strategies).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
}

@ -12,7 +12,7 @@
.body-2.grey--text.text--darken-1 Select which storage targets to enable:
.caption.grey--text.pb-2 Some storage targets require additional configuration in their dedicated tab (when selected).
v-form
v-checkbox(
v-checkbox.my-1(
v-for='tgt in targets'
v-model='tgt.isEnabled'
:key='tgt.key'
@ -27,14 +27,30 @@
v-form
v-subheader.pl-0 Target Configuration
.body-1.ml-3(v-if='!tgt.config || tgt.config.length < 1') This storage target has no configuration options you can modify.
v-text-field(
v-else
v-for='cfg in tgt.config'
:key='cfg.key'
:label='cfg.key'
v-model='cfg.value'
prepend-icon='settings_applications'
template(v-else, v-for='cfg in tgt.config')
v-select(
v-if='cfg.value.type === "string" && cfg.value.enum'
:items='cfg.value.enum'
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
prepend-icon='settings_applications'
)
v-switch(
v-else-if='cfg.value.type === "boolean"'
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
color='primary'
prepend-icon='settings_applications'
)
v-text-field(
v-else
:key='cfg.key'
:label='cfg.key | startCase'
v-model='cfg.value.value'
prepend-icon='settings_applications'
)
v-divider
v-subheader.pl-0 Sync Direction
.body-1.ml-3 Choose how content synchronization is handled for this storage target.
@ -80,6 +96,9 @@ import targetsQuery from 'gql/admin/storage/storage-query-targets.gql'
import targetsSaveMutation from 'gql/admin/storage/storage-mutation-save-targets.gql'
export default {
filters: {
startCase(val) { return _.startCase(val) }
},
data() {
return {
targets: []
@ -109,7 +128,7 @@ export default {
'key',
'config',
'mode'
]))
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))}))
}
})
this.$store.commit('showNotification', {
@ -124,7 +143,7 @@ export default {
targets: {
query: targetsQuery,
fetchPolicy: 'network-only',
update: (data) => _.cloneDeep(data.storage.targets),
update: (data) => _.cloneDeep(data.storage.targets).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
watchLoading (isLoading) {
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-storage-refresh')
}

@ -17,17 +17,31 @@
v-toolbar-title
.subheading Authentication
v-subheader Flush User Sessions
v-card-text.pt-0
v-card-text.pt-0.pl-4
.body-1 This will cause all users to be logged out. You will need to log back in after the operation.
v-btn(depressed).ml-0
v-icon(left, color='grey') build
span Proceed
v-divider.my-0
v-subheader Reset Guest User
v-card-text.pt-0
v-card-text.pt-0.pl-4
.body-1 This will reset the guest user to its default parameters and permissions.
v-btn(depressed).ml-0
v-icon(left, color='grey') build
span Proceed
v-card.mt-3
v-toolbar(:color='$vuetify.dark ? "" : "grey darken-3"', dark, dense, flat)
v-toolbar-title
.subheading Modules
v-subheader Rescan Modules
v-card-text.pt-0.pl-4
.body-1 Look for new modules on disk. Existing configurations will be merged.
v-btn(depressed).ml-0
v-icon(left, color='grey') youtube_searched_for
span Authentication
v-btn(depressed).ml-0
v-icon(left, color='grey') youtube_searched_for
span Storage
v-flex(xs12, sm6)
v-card
v-toolbar(:color='$vuetify.dark ? "" : "grey darken-3"', dark, dense, flat)

@ -1,6 +1,6 @@
mutation($targets: [StorageTargetInput]) {
storage {
updateTargets(targets: $targets) {
mutation($strategies: [AuthenticationStrategyInput]) {
authentication {
updateStrategies(strategies: $strategies) {
responseResult {
succeeded
errorCode

@ -1,6 +1,6 @@
mutation($strategies: [AuthenticationStrategyInput]) {
authentication {
updateStrategies(strategies: $strategies) {
mutation($targets: [StorageTargetInput]) {
storage {
updateTargets(targets: $targets) {
responseResult {
succeeded
errorCode

@ -37,7 +37,7 @@
"node": ">=8.11"
},
"dependencies": {
"apollo-server": "2.0.0-rc.2",
"apollo-server": "2.0.0-rc.5",
"apollo-server-express": "2.0.0-rc.2",
"auto-load": "3.0.0",
"axios": "0.18.0",
@ -69,9 +69,9 @@
"getos": "3.1.0",
"graphql": "0.13.2",
"graphql-list-fields": "2.0.2",
"graphql-tools": "3.0.2",
"graphql-tools": "3.0.4",
"i18next": "11.3.3",
"i18next-express-middleware": "1.1.1",
"i18next-express-middleware": "1.2.0",
"i18next-localstorage-cache": "1.1.1",
"i18next-node-fs-backend": "1.0.0",
"image-size": "0.6.3",
@ -79,7 +79,7 @@
"js-yaml": "3.12.0",
"jsonwebtoken": "8.3.0",
"klaw": "2.1.1",
"knex": "0.14.6",
"knex": "0.15.0",
"lodash": "4.17.10",
"markdown-it": "8.4.1",
"markdown-it-abbr": "1.0.4",
@ -99,9 +99,9 @@
"mime-types": "2.1.18",
"moment": "2.22.2",
"moment-timezone": "0.5.21",
"mongodb": "3.1.0-beta4",
"mongodb": "3.1.0",
"mssql": "4.1.0",
"multer": "1.3.0",
"multer": "1.3.1",
"mysql2": "1.5.3",
"node-2fa": "1.1.2",
"oauth2orize": "1.11.0",
@ -134,12 +134,12 @@
"scim-query-filter-parser": "1.1.0",
"semver": "5.5.0",
"serve-favicon": "2.5.0",
"sqlite3": "4.0.0",
"uuid": "3.2.1",
"sqlite3": "4.0.1",
"uuid": "3.3.2",
"validator": "10.4.0",
"validator-as-promised": "1.0.2",
"winston": "3.0.0",
"yargs": "11.0.0"
"yargs": "12.0.1"
},
"devDependencies": {
"@panter/vue-i18next": "0.11.0",
@ -152,11 +152,11 @@
"apollo-link-error": "1.1.0",
"apollo-link-http": "1.5.4",
"apollo-link-persisted-queries": "0.2.1",
"autoprefixer": "8.6.3",
"autoprefixer": "8.6.4",
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"babel-eslint": "8.2.5",
"babel-jest": "23.0.1",
"babel-jest": "23.2.0",
"babel-loader": "7.1.4",
"babel-plugin-graphql-tag": "1.6.0",
"babel-plugin-lodash": "3.3.4",
@ -168,14 +168,14 @@
"cache-loader": "1.2.2",
"chart.js": "2.7.2",
"clean-webpack-plugin": "0.1.19",
"copy-webpack-plugin": "4.5.1",
"copy-webpack-plugin": "4.5.2",
"css-loader": "0.28.11",
"cssnano": "4.0.0-rc.2",
"duplicate-package-checker-webpack-plugin": "3.0.0",
"eslint": "5.0.0",
"eslint": "5.0.1",
"eslint-config-requarks": "1.0.7",
"eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-node": "6.0.1",
"eslint-plugin-promise": "3.8.0",
"eslint-plugin-standard": "3.1.0",
@ -190,20 +190,20 @@
"html-webpack-pug-plugin": "0.3.0",
"i18next-xhr-backend": "1.5.1",
"ignore-loader": "0.1.2",
"jest": "23.1.0",
"jest": "23.2.0",
"jest-junit": "5.1.0",
"js-cookie": "2.2.0",
"lodash-webpack-plugin": "0.11.5",
"mini-css-extract-plugin": "0.4.0",
"mini-css-extract-plugin": "0.4.1",
"node-sass": "4.9.0",
"offline-plugin": "5.0.5",
"optimize-css-assets-webpack-plugin": "4.0.2",
"optimize-css-assets-webpack-plugin": "4.0.3",
"postcss-cssnext": "3.1.0",
"postcss-flexbugs-fixes": "3.3.1",
"postcss-flexibility": "2.0.0",
"postcss-import": "11.1.0",
"postcss-loader": "2.1.5",
"postcss-preset-env": "5.1.0",
"postcss-preset-env": "5.2.1",
"postcss-selector-parser": "5.0.0-rc.3",
"pug-lint": "2.5.0",
"pug-loader": "2.4.0",
@ -220,7 +220,7 @@
"stylus-loader": "3.0.2",
"twemoji-awesome": "1.0.6",
"url-loader": "1.0.1",
"vee-validate": "2.1.0-beta.2",
"vee-validate": "2.1.0-beta.5",
"velocity-animate": "1.5.1",
"vue": "2.5.16",
"vue-apollo": "3.0.0-beta.19",
@ -234,10 +234,10 @@
"vue-router": "3.0.1",
"vue-simple-breakpoints": "1.0.3",
"vue-template-compiler": "2.5.16",
"vuetify": "1.0.19",
"vuetify": "1.1.1",
"vuex": "3.0.1",
"vuex-persistedstate": "2.5.4",
"webpack": "4.12.0",
"webpack": "4.14.0",
"webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.0.8",
"webpack-dev-middleware": "3.1.3",

@ -2,6 +2,7 @@ const Model = require('objection').Model
const autoload = require('auto-load')
const path = require('path')
const _ = require('lodash')
const commonHelper = require('../../helpers/common')
/* global WIKI */
@ -51,8 +52,22 @@ module.exports = class Authentication extends Model {
title: strategy.title,
isEnabled: false,
useForm: strategy.useForm,
config: _.reduce(strategy.props, (result, value, key) => {
_.set(result, value, '')
config: _.transform(strategy.props, (result, value, key) => {
if (_.isPlainObject(value)) {
let cfgValue = {
type: typeof value.type(),
value: !_.isNil(value.default) ? value.default : commonHelper.getTypeDefaultValue(value)
}
if (_.isArray(value.enum)) {
cfgValue.enum = value.enum
}
_.set(result, key, cfgValue)
} else {
_.set(result, key, {
type: typeof value(),
value: commonHelper.getTypeDefaultValue(value)
})
}
return result
}, {}),
selfRegistration: false,

@ -2,6 +2,7 @@ const Model = require('objection').Model
const autoload = require('auto-load')
const path = require('path')
const _ = require('lodash')
const commonHelper = require('../../helpers/common')
/* global WIKI */
@ -43,8 +44,22 @@ module.exports = class Storage extends Model {
title: target.title,
isEnabled: false,
mode: 'push',
config: _.reduce(target.props, (result, value, key) => {
_.set(result, value, '')
config: _.transform(target.props, (result, value, key) => {
if (_.isPlainObject(value)) {
let cfgValue = {
type: typeof value.type(),
value: !_.isNil(value.default) ? value.default : commonHelper.getTypeDefaultValue(value)
}
if (_.isArray(value.enum)) {
cfgValue.enum = value.enum
}
_.set(result, key, cfgValue)
} else {
_.set(result, key, {
type: typeof value(),
value: commonHelper.getTypeDefaultValue(value)
})
}
return result
}, {})
})

@ -19,9 +19,9 @@ module.exports = {
let strategies = await WIKI.db.authentication.getStrategies()
strategies = strategies.map(stg => ({
...stg,
config: _.transform(stg.config, (res, value, key) => {
res.push({ key, value })
}, [])
config: _.sortBy(_.transform(stg.config, (res, value, key) => {
res.push({ key, value: JSON.stringify(value) })
}, []), 'key')
}))
if (args.filter) { strategies = graphHelper.filter(strategies, args.filter) }
if (args.orderBy) { strategies = graphHelper.orderBy(strategies, args.orderBy) }
@ -57,7 +57,7 @@ module.exports = {
await WIKI.db.authentication.query().patch({
isEnabled: str.isEnabled,
config: _.reduce(str.config, (result, value, key) => {
_.set(result, value.key, value.value)
_.set(result, `${value.key}.value`, value.value)
return result
}, {}),
selfRegistration: str.selfRegistration,

@ -13,11 +13,11 @@ module.exports = {
StorageQuery: {
async targets(obj, args, context, info) {
let targets = await WIKI.db.storage.getTargets()
targets = targets.map(stg => ({
...stg,
config: _.transform(stg.config, (res, value, key) => {
res.push({ key, value })
}, [])
targets = targets.map(tgt => ({
...tgt,
config: _.sortBy(_.transform(tgt.config, (res, value, key) => {
res.push({ key, value: JSON.stringify(value) })
}, []), 'key')
}))
if (args.filter) { targets = graphHelper.filter(targets, args.filter) }
if (args.orderBy) { targets = graphHelper.orderBy(targets, args.orderBy) }
@ -32,7 +32,7 @@ module.exports = {
isEnabled: tgt.isEnabled,
mode: tgt.mode,
config: _.reduce(tgt.config, (result, value, key) => {
_.set(result, value.key, value.value)
_.set(result, `${value.key}.value`, value.value)
return result
}, {})
}).where('key', tgt.key)

@ -0,0 +1,17 @@
const _ = require('lodash')
module.exports = {
/**
* Get default value of type
*
* @param {any} Type Primitive Type
* @returns Default value
*/
getTypeDefaultValue (Type) {
if (_.isArray(Type)) {
return _.head(Type)
} else {
return new Type()
}
}
}

@ -10,7 +10,11 @@ module.exports = {
key: 'auth0',
title: 'Auth0',
useForm: false,
props: ['domain', 'clientId', 'clientSecret'],
props: {
domain: String,
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('auth0',
new Auth0Strategy({

@ -10,7 +10,18 @@ module.exports = {
key: 'azure',
title: 'Azure Active Directory',
useForm: false,
props: ['clientId', 'clientSecret', 'resource', 'tenant'],
props: {
clientId: String,
clientSecret: String,
resource: {
type: String,
default: '00000002-0000-0000-c000-000000000000'
},
tenant: {
type: String,
default: 'YOUR_TENANT.onmicrosoft.com'
}
},
init (passport, conf) {
const jwt = require('jsonwebtoken')
passport.use('azure_ad_oauth2',

@ -10,7 +10,10 @@ module.exports = {
key: 'discord',
title: 'Discord',
useForm: false,
props: ['clientId', 'clientSecret'],
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('discord',
new DiscordStrategy({

@ -10,7 +10,10 @@ module.exports = {
key: 'dropbox',
title: 'Dropbox',
useForm: false,
props: ['clientId', 'clientSecret'],
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('dropbox',
new DropboxStrategy({

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

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

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

@ -11,7 +11,30 @@ module.exports = {
key: 'ldap',
title: 'LDAP / Active Directory',
useForm: true,
props: ['url', 'bindDn', 'bindCredentials', 'searchBase', 'searchFilter', 'tlsEnabled', 'tlsCertPath'],
props: {
url: {
type: String,
default: 'ldap://serverhost:389'
},
bindDn: {
type: String,
default: `cn='root'`
},
bindCredentials: String,
searchBase: {
type: String,
default: 'o=users,o=example.com'
},
searchFilter: {
type: String,
default: '(uid={{username}})'
},
tlsEnabled: {
type: Boolean,
default: false
},
tlsCertPath: String
},
init (passport, conf) {
passport.use('ldapauth',
new LdapStrategy({

@ -10,7 +10,7 @@ module.exports = {
key: 'local',
title: 'Local',
useForm: true,
props: [],
props: {},
init (passport, conf) {
passport.use('local',
new LocalStrategy({

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

@ -10,7 +10,12 @@ module.exports = {
key: 'oauth2',
title: 'OAuth2',
useForm: false,
props: ['clientId', 'clientSecret', 'authorizationURL', 'tokenURL'],
props: {
clientId: String,
clientSecret: String,
authorizationURL: String,
tokenURL: String
},
init (passport, conf) {
passport.use('oauth2',
new OAuth2Strategy({

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

@ -10,7 +10,10 @@ module.exports = {
key: 'twitch',
title: 'Twitch',
useForm: false,
props: ['clientId', 'clientSecret'],
props: {
clientId: String,
clientSecret: String
},
init (passport, conf) {
passport.use('twitch',
new TwitchStrategy({

@ -1,7 +1,11 @@
module.exports = {
key: 'azure',
title: 'Azure Blob Storage',
props: [],
props: {
accountName: String,
accountKey: String,
container: String
},
activate() {
},

@ -1,7 +1,15 @@
module.exports = {
key: 'digitalocean',
title: 'DigialOcean Spaces',
props: ['accessKeyId', 'accessSecret', 'region', 'bucket'],
props: {
accessKeyId: String,
accessSecret: String,
region: {
type: String,
default: 'nyc3'
},
bucket: String
},
activate() {
},

@ -1,7 +1,9 @@
module.exports = {
key: 'disk',
title: 'Local FS',
props: ['path'],
props: {
path: String
},
activate() {
},

@ -1,7 +1,10 @@
module.exports = {
key: 'dropbox',
title: 'Dropbox',
props: [],
props: {
appKey: String,
appSecret: String
},
activate() {
},

@ -1,7 +1,10 @@
module.exports = {
key: 'gdrive',
title: 'Google Drive',
props: [],
props: {
clientId: String,
clientSecret: String
},
activate() {
},

@ -1,7 +1,25 @@
module.exports = {
key: 'git',
title: 'Git',
props: [],
props: {
authType: {
type: String,
default: 'ssh',
enum: ['basic', 'ssh']
},
repoUrl: String,
branch: {
type: String,
default: 'master'
},
verifySSL: {
type: Boolean,
default: true
},
sshPrivateKeyPath: String,
basicUsername: String,
basicPassword: String
},
activate() {
},

@ -1,7 +1,10 @@
module.exports = {
key: 'onedrive',
title: 'OneDrive',
props: [],
props: {
clientId: String,
clientSecret: String
},
activate() {
},

@ -1,7 +1,12 @@
module.exports = {
key: 's3',
title: 'Amazon S3',
props: [],
props: {
accessKeyId: String,
accessSecret: String,
region: String,
bucket: String
},
activate() {
},

@ -1,7 +1,19 @@
module.exports = {
key: 'scp',
title: 'SCP (SSH)',
props: [],
props: {
host: String,
port: {
type: Number,
default: 22
},
username: String,
privateKeyPath: String,
basePath: {
type: String,
default: '~'
}
},
activate() {
},

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save