feat: authentication providers resolver - filter + orderBy
This commit is contained in:
@@ -30,6 +30,8 @@
|
|||||||
<script>
|
<script>
|
||||||
/* global CONSTANTS, graphQL, siteConfig */
|
/* global CONSTANTS, graphQL, siteConfig */
|
||||||
|
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -68,13 +70,10 @@ export default {
|
|||||||
refreshStrategies () {
|
refreshStrategies () {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
graphQL.query({
|
graphQL.query({
|
||||||
query: CONSTANTS.GRAPHQL.GQL_QUERY_AUTHENTICATION,
|
query: CONSTANTS.GRAPH.AUTHENTICATION.QUERY_LOGIN_PROVIDERS
|
||||||
variables: {
|
|
||||||
mode: 'active'
|
|
||||||
}
|
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
if (resp.data.authentication) {
|
if (_.has(resp, 'data.authentication.providers')) {
|
||||||
this.strategies = resp.data.authentication
|
this.strategies = _.get(resp, 'data.authentication.providers', [])
|
||||||
} else {
|
} else {
|
||||||
throw new Error('No authentication providers available!')
|
throw new Error('No authentication providers available!')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export default {
|
|||||||
props
|
props
|
||||||
title
|
title
|
||||||
useForm
|
useForm
|
||||||
icon
|
|
||||||
config {
|
config {
|
||||||
key
|
key
|
||||||
value
|
value
|
||||||
@@ -19,6 +18,21 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
QUERY_LOGIN_PROVIDERS: gql`
|
||||||
|
query {
|
||||||
|
authentication {
|
||||||
|
providers(
|
||||||
|
filter: "isEnabled eq true",
|
||||||
|
orderBy: "title ASC"
|
||||||
|
) {
|
||||||
|
key
|
||||||
|
title
|
||||||
|
useForm
|
||||||
|
icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
GQL_QUERY_TRANSLATIONS: gql`
|
GQL_QUERY_TRANSLATIONS: gql`
|
||||||
|
|||||||
+12
-10
@@ -66,6 +66,7 @@
|
|||||||
"follow-redirects": "1.4.1",
|
"follow-redirects": "1.4.1",
|
||||||
"fs-extra": "5.0.0",
|
"fs-extra": "5.0.0",
|
||||||
"graphql": "0.13.1",
|
"graphql": "0.13.1",
|
||||||
|
"graphql-list-fields": "2.0.1",
|
||||||
"graphql-tools": "2.21.0",
|
"graphql-tools": "2.21.0",
|
||||||
"i18next": "10.5.0",
|
"i18next": "10.5.0",
|
||||||
"i18next-express-middleware": "1.1.1",
|
"i18next-express-middleware": "1.1.1",
|
||||||
@@ -82,7 +83,7 @@
|
|||||||
"markdown-it-anchor": "4.0.0",
|
"markdown-it-anchor": "4.0.0",
|
||||||
"markdown-it-attrs": "1.2.1",
|
"markdown-it-attrs": "1.2.1",
|
||||||
"markdown-it-emoji": "1.4.0",
|
"markdown-it-emoji": "1.4.0",
|
||||||
"markdown-it-expand-tabs": "1.0.12",
|
"markdown-it-expand-tabs": "1.0.13",
|
||||||
"markdown-it-external-links": "0.0.6",
|
"markdown-it-external-links": "0.0.6",
|
||||||
"markdown-it-footnote": "3.0.1",
|
"markdown-it-footnote": "3.0.1",
|
||||||
"markdown-it-imsize": "2.0.1",
|
"markdown-it-imsize": "2.0.1",
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
"markdown-it-mathjax": "2.0.0",
|
"markdown-it-mathjax": "2.0.0",
|
||||||
"markdown-it-sub": "1.0.0",
|
"markdown-it-sub": "1.0.0",
|
||||||
"markdown-it-sup": "1.0.0",
|
"markdown-it-sup": "1.0.0",
|
||||||
"markdown-it-task-lists": "2.1.0",
|
"markdown-it-task-lists": "2.1.1",
|
||||||
"mathjax-node": "2.0.1",
|
"mathjax-node": "2.0.1",
|
||||||
"mime-types": "2.1.18",
|
"mime-types": "2.1.18",
|
||||||
"moment": "2.21.0",
|
"moment": "2.21.0",
|
||||||
@@ -118,13 +119,14 @@
|
|||||||
"pg-hstore": "2.3.2",
|
"pg-hstore": "2.3.2",
|
||||||
"pg-promise": "7.5.3",
|
"pg-promise": "7.5.3",
|
||||||
"pm2": "2.10.1",
|
"pm2": "2.10.1",
|
||||||
"pug": "2.0.0-rc.4",
|
"pug": "2.0.1",
|
||||||
"qr-image": "3.2.0",
|
"qr-image": "3.2.0",
|
||||||
"raven": "2.4.2",
|
"raven": "2.4.2",
|
||||||
"read-chunk": "2.1.0",
|
"read-chunk": "2.1.0",
|
||||||
"remove-markdown": "0.2.2",
|
"remove-markdown": "0.2.2",
|
||||||
"request": "2.83.0",
|
"request": "2.83.0",
|
||||||
"request-promise": "4.2.2",
|
"request-promise": "4.2.2",
|
||||||
|
"scim-query-filter-parser": "1.1.0",
|
||||||
"semver": "5.5.0",
|
"semver": "5.5.0",
|
||||||
"sequelize": "4.35.2",
|
"sequelize": "4.35.2",
|
||||||
"serve-favicon": "2.4.5",
|
"serve-favicon": "2.4.5",
|
||||||
@@ -144,7 +146,7 @@
|
|||||||
"babel-core": "6.26.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-eslint": "8.2.2",
|
"babel-eslint": "8.2.2",
|
||||||
"babel-jest": "22.4.1",
|
"babel-jest": "22.4.1",
|
||||||
"babel-loader": "7.1.3",
|
"babel-loader": "7.1.4",
|
||||||
"babel-plugin-graphql-tag": "1.5.0",
|
"babel-plugin-graphql-tag": "1.5.0",
|
||||||
"babel-plugin-lodash": "3.3.2",
|
"babel-plugin-lodash": "3.3.2",
|
||||||
"babel-plugin-transform-imports": "1.5.0",
|
"babel-plugin-transform-imports": "1.5.0",
|
||||||
@@ -154,7 +156,7 @@
|
|||||||
"babel-preset-stage-2": "6.24.1",
|
"babel-preset-stage-2": "6.24.1",
|
||||||
"brace": "0.11.1",
|
"brace": "0.11.1",
|
||||||
"cache-loader": "1.2.2",
|
"cache-loader": "1.2.2",
|
||||||
"clean-webpack-plugin": "0.1.18",
|
"clean-webpack-plugin": "0.1.19",
|
||||||
"colors": "1.1.2",
|
"colors": "1.1.2",
|
||||||
"copy-webpack-plugin": "4.5.0",
|
"copy-webpack-plugin": "4.5.0",
|
||||||
"css-loader": "0.28.10",
|
"css-loader": "0.28.10",
|
||||||
@@ -165,7 +167,7 @@
|
|||||||
"eslint-config-standard": "11.0.0",
|
"eslint-config-standard": "11.0.0",
|
||||||
"eslint-plugin-import": "2.9.0",
|
"eslint-plugin-import": "2.9.0",
|
||||||
"eslint-plugin-node": "6.0.1",
|
"eslint-plugin-node": "6.0.1",
|
||||||
"eslint-plugin-promise": "3.6.0",
|
"eslint-plugin-promise": "3.7.0",
|
||||||
"eslint-plugin-standard": "3.0.1",
|
"eslint-plugin-standard": "3.0.1",
|
||||||
"eslint-plugin-vue": "4.3.0",
|
"eslint-plugin-vue": "4.3.0",
|
||||||
"extract-text-webpack-plugin": "3.0.2",
|
"extract-text-webpack-plugin": "3.0.2",
|
||||||
@@ -188,7 +190,7 @@
|
|||||||
"raw-loader": "0.5.1",
|
"raw-loader": "0.5.1",
|
||||||
"sass-loader": "6.0.7",
|
"sass-loader": "6.0.7",
|
||||||
"sass-resources-loader": "1.3.3",
|
"sass-resources-loader": "1.3.3",
|
||||||
"simple-progress-webpack-plugin": "1.1.1",
|
"simple-progress-webpack-plugin": "1.1.2",
|
||||||
"style-loader": "0.20.2",
|
"style-loader": "0.20.2",
|
||||||
"stylus": "0.54.5",
|
"stylus": "0.54.5",
|
||||||
"stylus-loader": "3.0.2",
|
"stylus-loader": "3.0.2",
|
||||||
@@ -201,12 +203,12 @@
|
|||||||
"vue-clipboards": "1.2.2",
|
"vue-clipboards": "1.2.2",
|
||||||
"vue-codemirror": "4.0.3",
|
"vue-codemirror": "4.0.3",
|
||||||
"vue-hot-reload-api": "2.3.0",
|
"vue-hot-reload-api": "2.3.0",
|
||||||
"vue-loader": "14.1.1",
|
"vue-loader": "14.2.1",
|
||||||
"vue-material-design-icons": "1.1.0",
|
"vue-material-design-icons": "1.2.1",
|
||||||
"vue-router": "3.0.1",
|
"vue-router": "3.0.1",
|
||||||
"vue-simple-breakpoints": "1.0.3",
|
"vue-simple-breakpoints": "1.0.3",
|
||||||
"vue-template-compiler": "2.5.13",
|
"vue-template-compiler": "2.5.13",
|
||||||
"vuetify": "1.0.4",
|
"vuetify": "1.0.5",
|
||||||
"vuex": "3.0.1",
|
"vuex": "3.0.1",
|
||||||
"vuex-persistedstate": "2.4.2",
|
"vuex-persistedstate": "2.4.2",
|
||||||
"webpack": "3.11.0",
|
"webpack": "3.11.0",
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const graphHelper = require('../../helpers/graph')
|
||||||
|
|
||||||
|
// const getFieldNames = require('graphql-list-fields')
|
||||||
|
|
||||||
/* global WIKI */
|
/* global WIKI */
|
||||||
|
|
||||||
@@ -13,16 +16,17 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
AuthenticationQuery: {
|
AuthenticationQuery: {
|
||||||
providers(obj, args, context, info) {
|
providers(obj, args, context, info) {
|
||||||
return _.chain(WIKI.auth.strategies).map(str => {
|
let prv = _.map(WIKI.auth.strategies, str => ({
|
||||||
return {
|
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
key: str.key,
|
key: str.key,
|
||||||
props: str.props,
|
props: str.props,
|
||||||
title: str.title,
|
title: str.title,
|
||||||
useForm: str.useForm,
|
useForm: str.useForm,
|
||||||
config: []
|
config: []
|
||||||
}
|
}))
|
||||||
}).sortBy(['title']).value()
|
if (args.filter) { prv = graphHelper.filter(prv, args.filter) }
|
||||||
|
if (args.orderBy) { prv = graphHelper.orderBy(prv, args.orderBy) }
|
||||||
|
return prv
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AuthenticationProvider: {
|
AuthenticationProvider: {
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ extend type Mutation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationQuery {
|
type AuthenticationQuery {
|
||||||
providers: [AuthenticationProvider]
|
providers(
|
||||||
|
filter: String
|
||||||
|
orderBy: String
|
||||||
|
): [AuthenticationProvider]
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationMutation {
|
type AuthenticationMutation {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
const _ = require('lodash')
|
||||||
|
const Filter = require('scim-query-filter-parser')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
filter (arr, filterString) {
|
||||||
|
const prvFilter = new Filter(_.toString(filterString).replace(/'/g, `"`))
|
||||||
|
return arr.filter(prvFilter.test)
|
||||||
|
},
|
||||||
|
orderBy (arr, orderString) {
|
||||||
|
let orderParams = _.zip(orderString.split(',').map(ord => _.trim(ord).split(' ').map(_.trim)))
|
||||||
|
return _.orderBy(arr, orderParams[0], orderParams[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user