Skip to content

Commit 4643336

Browse files
committed
feat: auth + storage config improvements
1 parent bb102c3 commit 4643336

35 files changed

+818
-354
lines changed

.vscode/extensions.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"dbaeumer.vscode-eslint",
55
"christian-kohler.path-intellisense",
66
"mrmlnc.vscode-puglint",
7-
"robinbentley.sass-indented",
87
"octref.vetur"
98
]
109
}

client/components/admin/admin-auth.vue

+29-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
.body-2.grey--text.text--darken-1 Select which authentication strategies to enable:
1313
.caption.grey--text.pb-2 Some strategies require additional configuration in their dedicated tab (when selected).
1414
v-form
15-
v-checkbox(
15+
v-checkbox.my-1(
1616
v-for='strategy in strategies'
1717
v-model='strategy.isEnabled'
1818
:key='strategy.key'
@@ -27,14 +27,30 @@
2727
v-form
2828
v-subheader.pl-0 Strategy Configuration
2929
.body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
30-
v-text-field(
31-
v-else
32-
v-for='cfg in strategy.config'
33-
:key='cfg.key'
34-
:label='cfg.key'
35-
v-model='cfg.value'
36-
prepend-icon='settings_applications'
30+
template(v-else, v-for='cfg in strategy.config')
31+
v-select(
32+
v-if='cfg.value.type === "string" && cfg.value.enum'
33+
:items='cfg.value.enum'
34+
:key='cfg.key'
35+
:label='cfg.key | startCase'
36+
v-model='cfg.value.value'
37+
prepend-icon='settings_applications'
3738
)
39+
v-switch(
40+
v-else-if='cfg.value.type === "boolean"'
41+
:key='cfg.key'
42+
:label='cfg.key | startCase'
43+
v-model='cfg.value.value'
44+
color='primary'
45+
prepend-icon='settings_applications'
46+
)
47+
v-text-field(
48+
v-else
49+
:key='cfg.key'
50+
:label='cfg.key | startCase'
51+
v-model='cfg.value.value'
52+
prepend-icon='settings_applications'
53+
)
3854
v-divider
3955
v-subheader.pl-0 Registration
4056
.pr-3
@@ -90,6 +106,9 @@ import strategiesQuery from 'gql/admin/auth/auth-query-strategies.gql'
90106
import strategiesSaveMutation from 'gql/admin/auth/auth-mutation-save-strategies.gql'
91107
92108
export default {
109+
filters: {
110+
startCase(val) { return _.startCase(val) }
111+
},
93112
data() {
94113
return {
95114
groups: [],
@@ -122,7 +141,7 @@ export default {
122141
'selfRegistration',
123142
'domainWhitelist',
124143
'autoEnrollGroups'
125-
]))
144+
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))}))
126145
}
127146
})
128147
this.$store.commit('showNotification', {
@@ -137,7 +156,7 @@ export default {
137156
strategies: {
138157
query: strategiesQuery,
139158
fetchPolicy: 'network-only',
140-
update: (data) => _.cloneDeep(data.authentication.strategies),
159+
update: (data) => _.cloneDeep(data.authentication.strategies).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
141160
watchLoading (isLoading) {
142161
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
143162
}

client/components/admin/admin-storage.vue

+29-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
.body-2.grey--text.text--darken-1 Select which storage targets to enable:
1313
.caption.grey--text.pb-2 Some storage targets require additional configuration in their dedicated tab (when selected).
1414
v-form
15-
v-checkbox(
15+
v-checkbox.my-1(
1616
v-for='tgt in targets'
1717
v-model='tgt.isEnabled'
1818
:key='tgt.key'
@@ -27,14 +27,30 @@
2727
v-form
2828
v-subheader.pl-0 Target Configuration
2929
.body-1.ml-3(v-if='!tgt.config || tgt.config.length < 1') This storage target has no configuration options you can modify.
30-
v-text-field(
31-
v-else
32-
v-for='cfg in tgt.config'
33-
:key='cfg.key'
34-
:label='cfg.key'
35-
v-model='cfg.value'
36-
prepend-icon='settings_applications'
30+
template(v-else, v-for='cfg in tgt.config')
31+
v-select(
32+
v-if='cfg.value.type === "string" && cfg.value.enum'
33+
:items='cfg.value.enum'
34+
:key='cfg.key'
35+
:label='cfg.key | startCase'
36+
v-model='cfg.value.value'
37+
prepend-icon='settings_applications'
3738
)
39+
v-switch(
40+
v-else-if='cfg.value.type === "boolean"'
41+
:key='cfg.key'
42+
:label='cfg.key | startCase'
43+
v-model='cfg.value.value'
44+
color='primary'
45+
prepend-icon='settings_applications'
46+
)
47+
v-text-field(
48+
v-else
49+
:key='cfg.key'
50+
:label='cfg.key | startCase'
51+
v-model='cfg.value.value'
52+
prepend-icon='settings_applications'
53+
)
3854
v-divider
3955
v-subheader.pl-0 Sync Direction
4056
.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'
8096
import targetsSaveMutation from 'gql/admin/storage/storage-mutation-save-targets.gql'
8197
8298
export default {
99+
filters: {
100+
startCase(val) { return _.startCase(val) }
101+
},
83102
data() {
84103
return {
85104
targets: []
@@ -109,7 +128,7 @@ export default {
109128
'key',
110129
'config',
111130
'mode'
112-
]))
131+
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))}))
113132
}
114133
})
115134
this.$store.commit('showNotification', {
@@ -124,7 +143,7 @@ export default {
124143
targets: {
125144
query: targetsQuery,
126145
fetchPolicy: 'network-only',
127-
update: (data) => _.cloneDeep(data.storage.targets),
146+
update: (data) => _.cloneDeep(data.storage.targets).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
128147
watchLoading (isLoading) {
129148
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-storage-refresh')
130149
}

client/components/admin/admin-utilities.vue

+16-2
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,31 @@
1717
v-toolbar-title
1818
.subheading Authentication
1919
v-subheader Flush User Sessions
20-
v-card-text.pt-0
20+
v-card-text.pt-0.pl-4
2121
.body-1 This will cause all users to be logged out. You will need to log back in after the operation.
2222
v-btn(depressed).ml-0
2323
v-icon(left, color='grey') build
2424
span Proceed
25+
v-divider.my-0
2526
v-subheader Reset Guest User
26-
v-card-text.pt-0
27+
v-card-text.pt-0.pl-4
2728
.body-1 This will reset the guest user to its default parameters and permissions.
2829
v-btn(depressed).ml-0
2930
v-icon(left, color='grey') build
3031
span Proceed
32+
v-card.mt-3
33+
v-toolbar(:color='$vuetify.dark ? "" : "grey darken-3"', dark, dense, flat)
34+
v-toolbar-title
35+
.subheading Modules
36+
v-subheader Rescan Modules
37+
v-card-text.pt-0.pl-4
38+
.body-1 Look for new modules on disk. Existing configurations will be merged.
39+
v-btn(depressed).ml-0
40+
v-icon(left, color='grey') youtube_searched_for
41+
span Authentication
42+
v-btn(depressed).ml-0
43+
v-icon(left, color='grey') youtube_searched_for
44+
span Storage
3145
v-flex(xs12, sm6)
3246
v-card
3347
v-toolbar(:color='$vuetify.dark ? "" : "grey darken-3"', dark, dense, flat)

client/graph/admin/auth/auth-mutation-save-strategies.gql

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
mutation($targets: [StorageTargetInput]) {
2-
storage {
3-
updateTargets(targets: $targets) {
1+
mutation($strategies: [AuthenticationStrategyInput]) {
2+
authentication {
3+
updateStrategies(strategies: $strategies) {
44
responseResult {
55
succeeded
66
errorCode

client/graph/admin/storage/storage-mutation-save-targets.gql

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
mutation($strategies: [AuthenticationStrategyInput]) {
2-
authentication {
3-
updateStrategies(strategies: $strategies) {
1+
mutation($targets: [StorageTargetInput]) {
2+
storage {
3+
updateTargets(targets: $targets) {
44
responseResult {
55
succeeded
66
errorCode

package.json

+21-21
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"node": ">=8.11"
3838
},
3939
"dependencies": {
40-
"apollo-server": "2.0.0-rc.2",
40+
"apollo-server": "2.0.0-rc.5",
4141
"apollo-server-express": "2.0.0-rc.2",
4242
"auto-load": "3.0.0",
4343
"axios": "0.18.0",
@@ -69,17 +69,17 @@
6969
"getos": "3.1.0",
7070
"graphql": "0.13.2",
7171
"graphql-list-fields": "2.0.2",
72-
"graphql-tools": "3.0.2",
72+
"graphql-tools": "3.0.4",
7373
"i18next": "11.3.3",
74-
"i18next-express-middleware": "1.1.1",
74+
"i18next-express-middleware": "1.2.0",
7575
"i18next-localstorage-cache": "1.1.1",
7676
"i18next-node-fs-backend": "1.0.0",
7777
"image-size": "0.6.3",
7878
"ioredis": "3.2.2",
7979
"js-yaml": "3.12.0",
8080
"jsonwebtoken": "8.3.0",
8181
"klaw": "2.1.1",
82-
"knex": "0.14.6",
82+
"knex": "0.15.0",
8383
"lodash": "4.17.10",
8484
"markdown-it": "8.4.1",
8585
"markdown-it-abbr": "1.0.4",
@@ -99,9 +99,9 @@
9999
"mime-types": "2.1.18",
100100
"moment": "2.22.2",
101101
"moment-timezone": "0.5.21",
102-
"mongodb": "3.1.0-beta4",
102+
"mongodb": "3.1.0",
103103
"mssql": "4.1.0",
104-
"multer": "1.3.0",
104+
"multer": "1.3.1",
105105
"mysql2": "1.5.3",
106106
"node-2fa": "1.1.2",
107107
"oauth2orize": "1.11.0",
@@ -134,12 +134,12 @@
134134
"scim-query-filter-parser": "1.1.0",
135135
"semver": "5.5.0",
136136
"serve-favicon": "2.5.0",
137-
"sqlite3": "4.0.0",
138-
"uuid": "3.2.1",
137+
"sqlite3": "4.0.1",
138+
"uuid": "3.3.2",
139139
"validator": "10.4.0",
140140
"validator-as-promised": "1.0.2",
141141
"winston": "3.0.0",
142-
"yargs": "11.0.0"
142+
"yargs": "12.0.1"
143143
},
144144
"devDependencies": {
145145
"@panter/vue-i18next": "0.11.0",
@@ -152,11 +152,11 @@
152152
"apollo-link-error": "1.1.0",
153153
"apollo-link-http": "1.5.4",
154154
"apollo-link-persisted-queries": "0.2.1",
155-
"autoprefixer": "8.6.3",
155+
"autoprefixer": "8.6.4",
156156
"babel-cli": "6.26.0",
157157
"babel-core": "6.26.3",
158158
"babel-eslint": "8.2.5",
159-
"babel-jest": "23.0.1",
159+
"babel-jest": "23.2.0",
160160
"babel-loader": "7.1.4",
161161
"babel-plugin-graphql-tag": "1.6.0",
162162
"babel-plugin-lodash": "3.3.4",
@@ -168,14 +168,14 @@
168168
"cache-loader": "1.2.2",
169169
"chart.js": "2.7.2",
170170
"clean-webpack-plugin": "0.1.19",
171-
"copy-webpack-plugin": "4.5.1",
171+
"copy-webpack-plugin": "4.5.2",
172172
"css-loader": "0.28.11",
173173
"cssnano": "4.0.0-rc.2",
174174
"duplicate-package-checker-webpack-plugin": "3.0.0",
175-
"eslint": "5.0.0",
175+
"eslint": "5.0.1",
176176
"eslint-config-requarks": "1.0.7",
177177
"eslint-config-standard": "11.0.0",
178-
"eslint-plugin-import": "2.12.0",
178+
"eslint-plugin-import": "2.13.0",
179179
"eslint-plugin-node": "6.0.1",
180180
"eslint-plugin-promise": "3.8.0",
181181
"eslint-plugin-standard": "3.1.0",
@@ -190,20 +190,20 @@
190190
"html-webpack-pug-plugin": "0.3.0",
191191
"i18next-xhr-backend": "1.5.1",
192192
"ignore-loader": "0.1.2",
193-
"jest": "23.1.0",
193+
"jest": "23.2.0",
194194
"jest-junit": "5.1.0",
195195
"js-cookie": "2.2.0",
196196
"lodash-webpack-plugin": "0.11.5",
197-
"mini-css-extract-plugin": "0.4.0",
197+
"mini-css-extract-plugin": "0.4.1",
198198
"node-sass": "4.9.0",
199199
"offline-plugin": "5.0.5",
200-
"optimize-css-assets-webpack-plugin": "4.0.2",
200+
"optimize-css-assets-webpack-plugin": "4.0.3",
201201
"postcss-cssnext": "3.1.0",
202202
"postcss-flexbugs-fixes": "3.3.1",
203203
"postcss-flexibility": "2.0.0",
204204
"postcss-import": "11.1.0",
205205
"postcss-loader": "2.1.5",
206-
"postcss-preset-env": "5.1.0",
206+
"postcss-preset-env": "5.2.1",
207207
"postcss-selector-parser": "5.0.0-rc.3",
208208
"pug-lint": "2.5.0",
209209
"pug-loader": "2.4.0",
@@ -220,7 +220,7 @@
220220
"stylus-loader": "3.0.2",
221221
"twemoji-awesome": "1.0.6",
222222
"url-loader": "1.0.1",
223-
"vee-validate": "2.1.0-beta.2",
223+
"vee-validate": "2.1.0-beta.5",
224224
"velocity-animate": "1.5.1",
225225
"vue": "2.5.16",
226226
"vue-apollo": "3.0.0-beta.19",
@@ -234,10 +234,10 @@
234234
"vue-router": "3.0.1",
235235
"vue-simple-breakpoints": "1.0.3",
236236
"vue-template-compiler": "2.5.16",
237-
"vuetify": "1.0.19",
237+
"vuetify": "1.1.1",
238238
"vuex": "3.0.1",
239239
"vuex-persistedstate": "2.5.4",
240-
"webpack": "4.12.0",
240+
"webpack": "4.14.0",
241241
"webpack-bundle-analyzer": "2.13.1",
242242
"webpack-cli": "3.0.8",
243243
"webpack-dev-middleware": "3.1.3",

server/db/models/authentication.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Model = require('objection').Model
22
const autoload = require('auto-load')
33
const path = require('path')
44
const _ = require('lodash')
5+
const commonHelper = require('../../helpers/common')
56

67
/* global WIKI */
78

@@ -51,8 +52,22 @@ module.exports = class Authentication extends Model {
5152
title: strategy.title,
5253
isEnabled: false,
5354
useForm: strategy.useForm,
54-
config: _.reduce(strategy.props, (result, value, key) => {
55-
_.set(result, value, '')
55+
config: _.transform(strategy.props, (result, value, key) => {
56+
if (_.isPlainObject(value)) {
57+
let cfgValue = {
58+
type: typeof value.type(),
59+
value: !_.isNil(value.default) ? value.default : commonHelper.getTypeDefaultValue(value)
60+
}
61+
if (_.isArray(value.enum)) {
62+
cfgValue.enum = value.enum
63+
}
64+
_.set(result, key, cfgValue)
65+
} else {
66+
_.set(result, key, {
67+
type: typeof value(),
68+
value: commonHelper.getTypeDefaultValue(value)
69+
})
70+
}
5671
return result
5772
}, {}),
5873
selfRegistration: false,

0 commit comments

Comments
 (0)