feat: authentication providers resolver - filter + orderBy

pull/621/head
NGPixel 6 years ago
parent 6ff4152e1c
commit 69a0711d16

@ -30,6 +30,8 @@
<script>
/* global CONSTANTS, graphQL, siteConfig */
import _ from 'lodash'
export default {
data () {
return {
@ -68,13 +70,10 @@ export default {
refreshStrategies () {
this.isLoading = true
graphQL.query({
query: CONSTANTS.GRAPHQL.GQL_QUERY_AUTHENTICATION,
variables: {
mode: 'active'
}
query: CONSTANTS.GRAPH.AUTHENTICATION.QUERY_LOGIN_PROVIDERS
}).then(resp => {
if (resp.data.authentication) {
this.strategies = resp.data.authentication
if (_.has(resp, 'data.authentication.providers')) {
this.strategies = _.get(resp, 'data.authentication.providers', [])
} else {
throw new Error('No authentication providers available!')
}

@ -11,7 +11,6 @@ export default {
props
title
useForm
icon
config {
key
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`

@ -66,6 +66,7 @@
"follow-redirects": "1.4.1",
"fs-extra": "5.0.0",
"graphql": "0.13.1",
"graphql-list-fields": "2.0.1",
"graphql-tools": "2.21.0",
"i18next": "10.5.0",
"i18next-express-middleware": "1.1.1",
@ -82,7 +83,7 @@
"markdown-it-anchor": "4.0.0",
"markdown-it-attrs": "1.2.1",
"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-footnote": "3.0.1",
"markdown-it-imsize": "2.0.1",
@ -90,7 +91,7 @@
"markdown-it-mathjax": "2.0.0",
"markdown-it-sub": "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",
"mime-types": "2.1.18",
"moment": "2.21.0",
@ -118,13 +119,14 @@
"pg-hstore": "2.3.2",
"pg-promise": "7.5.3",
"pm2": "2.10.1",
"pug": "2.0.0-rc.4",
"pug": "2.0.1",
"qr-image": "3.2.0",
"raven": "2.4.2",
"read-chunk": "2.1.0",
"remove-markdown": "0.2.2",
"request": "2.83.0",
"request-promise": "4.2.2",
"scim-query-filter-parser": "1.1.0",
"semver": "5.5.0",
"sequelize": "4.35.2",
"serve-favicon": "2.4.5",
@ -144,7 +146,7 @@
"babel-core": "6.26.0",
"babel-eslint": "8.2.2",
"babel-jest": "22.4.1",
"babel-loader": "7.1.3",
"babel-loader": "7.1.4",
"babel-plugin-graphql-tag": "1.5.0",
"babel-plugin-lodash": "3.3.2",
"babel-plugin-transform-imports": "1.5.0",
@ -154,7 +156,7 @@
"babel-preset-stage-2": "6.24.1",
"brace": "0.11.1",
"cache-loader": "1.2.2",
"clean-webpack-plugin": "0.1.18",
"clean-webpack-plugin": "0.1.19",
"colors": "1.1.2",
"copy-webpack-plugin": "4.5.0",
"css-loader": "0.28.10",
@ -165,7 +167,7 @@
"eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.9.0",
"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-vue": "4.3.0",
"extract-text-webpack-plugin": "3.0.2",
@ -188,7 +190,7 @@
"raw-loader": "0.5.1",
"sass-loader": "6.0.7",
"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",
"stylus": "0.54.5",
"stylus-loader": "3.0.2",
@ -201,12 +203,12 @@
"vue-clipboards": "1.2.2",
"vue-codemirror": "4.0.3",
"vue-hot-reload-api": "2.3.0",
"vue-loader": "14.1.1",
"vue-material-design-icons": "1.1.0",
"vue-loader": "14.2.1",
"vue-material-design-icons": "1.2.1",
"vue-router": "3.0.1",
"vue-simple-breakpoints": "1.0.3",
"vue-template-compiler": "2.5.13",
"vuetify": "1.0.4",
"vuetify": "1.0.5",
"vuex": "3.0.1",
"vuex-persistedstate": "2.4.2",
"webpack": "3.11.0",

@ -1,6 +1,9 @@
const _ = require('lodash')
const fs = require('fs-extra')
const path = require('path')
const graphHelper = require('../../helpers/graph')
// const getFieldNames = require('graphql-list-fields')
/* global WIKI */
@ -13,16 +16,17 @@ module.exports = {
},
AuthenticationQuery: {
providers(obj, args, context, info) {
return _.chain(WIKI.auth.strategies).map(str => {
return {
isEnabled: true,
key: str.key,
props: str.props,
title: str.title,
useForm: str.useForm,
config: []
}
}).sortBy(['title']).value()
let prv = _.map(WIKI.auth.strategies, str => ({
isEnabled: true,
key: str.key,
props: str.props,
title: str.title,
useForm: str.useForm,
config: []
}))
if (args.filter) { prv = graphHelper.filter(prv, args.filter) }
if (args.orderBy) { prv = graphHelper.orderBy(prv, args.orderBy) }
return prv
}
},
AuthenticationProvider: {

@ -7,7 +7,10 @@ extend type Mutation {
}
type AuthenticationQuery {
providers: [AuthenticationProvider]
providers(
filter: String
orderBy: String
): [AuthenticationProvider]
}
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])
}
}

@ -972,9 +972,9 @@ babel-literal-to-ast@^0.1.2:
babel-types "^6.0.19"
babylon "^6.0.18"
babel-loader@7.1.3:
version "7.1.3"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.3.tgz#ff5b440da716e9153abb946251a9ab7670037b16"
babel-loader@7.1.4:
version "7.1.4"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.4.tgz#e3463938bd4e6d55d1c174c5485d406a188ed015"
dependencies:
find-cache-dir "^1.0.0"
loader-utils "^1.0.2"
@ -2180,9 +2180,9 @@ clean-css@^3.3.0:
commander "2.8.x"
source-map "0.4.x"
clean-webpack-plugin@0.1.18:
version "0.1.18"
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-0.1.18.tgz#2e2173897c76646031bff047c14b9c22c80d8c4a"
clean-webpack-plugin@0.1.19:
version "0.1.19"
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-0.1.19.tgz#ceda8bb96b00fe168e9b080272960d20fdcadd6d"
dependencies:
rimraf "^2.6.1"
@ -3454,9 +3454,9 @@ eslint-plugin-node@6.0.1:
resolve "^1.3.3"
semver "^5.4.1"
eslint-plugin-promise@3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz#54b7658c8f454813dc2a870aff8152ec4969ba75"
eslint-plugin-promise@3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.7.0.tgz#f4bde5c2c77cdd69557a8f69a24d1ad3cfc9e67e"
eslint-plugin-standard@3.0.1:
version "3.0.1"
@ -4284,6 +4284,10 @@ graphql-extensions@^0.0.x:
core-js "^2.5.1"
source-map-support "^0.5.0"
graphql-list-fields@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/graphql-list-fields/-/graphql-list-fields-2.0.1.tgz#06d921eddfbadafa66970e21ff0acdab3cf039db"
graphql-tag@^2.4.2:
version "2.5.0"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.5.0.tgz#b43bfd8b5babcd2c205ad680c03e98b238934e0f"
@ -6145,9 +6149,9 @@ markdown-it-emoji@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/markdown-it-emoji/-/markdown-it-emoji-1.4.0.tgz#9bee0e9a990a963ba96df6980c4fddb05dfb4dcc"
markdown-it-expand-tabs@1.0.12:
version "1.0.12"
resolved "https://registry.yarnpkg.com/markdown-it-expand-tabs/-/markdown-it-expand-tabs-1.0.12.tgz#f54bd2f303f858ee6798ca2bd83fe70144814ca0"
markdown-it-expand-tabs@1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/markdown-it-expand-tabs/-/markdown-it-expand-tabs-1.0.13.tgz#d5c8dc22b2cff467bceea5372b84168893aa9e8d"
dependencies:
lodash.repeat "^4.0.0"
@ -6179,9 +6183,9 @@ markdown-it-sup@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3"
markdown-it-task-lists@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/markdown-it-task-lists/-/markdown-it-task-lists-2.1.0.tgz#4594f750f70df053d1dad68024388007c1d20783"
markdown-it-task-lists@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/markdown-it-task-lists/-/markdown-it-task-lists-2.1.1.tgz#f68f4d2ac2bad5a2c373ba93081a1a6848417088"
markdown-it@8.4.1:
version "8.4.1"
@ -8114,7 +8118,7 @@ public-encrypt@^4.0.0:
parse-asn1 "^5.0.0"
randombytes "^2.0.1"
pug-attrs@^2.0.1, pug-attrs@^2.0.2:
pug-attrs@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/pug-attrs/-/pug-attrs-2.0.2.tgz#8be2b2225568ffa75d1b866982bff9f4111affcb"
dependencies:
@ -8122,16 +8126,24 @@ pug-attrs@^2.0.1, pug-attrs@^2.0.2:
js-stringify "^1.0.1"
pug-runtime "^2.0.3"
pug-code-gen@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pug-code-gen/-/pug-code-gen-2.0.0.tgz#96aea39a9e62f1ec5d2b6a5b42a29d528c70b43d"
pug-attrs@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/pug-attrs/-/pug-attrs-2.0.3.tgz#a3095f970e64151f7bdad957eef55fb5d7905d15"
dependencies:
constantinople "^3.0.1"
js-stringify "^1.0.1"
pug-runtime "^2.0.4"
pug-code-gen@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pug-code-gen/-/pug-code-gen-2.0.1.tgz#0951ec83225d74d8cfc476a7f99a259b5f7d050c"
dependencies:
constantinople "^3.0.1"
doctypes "^1.1.0"
js-stringify "^1.0.1"
pug-attrs "^2.0.2"
pug-attrs "^2.0.3"
pug-error "^1.3.2"
pug-runtime "^2.0.3"
pug-runtime "^2.0.4"
void-elements "^2.0.1"
with "^5.0.0"
@ -8139,15 +8151,15 @@ pug-error@^1.3.0, pug-error@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-1.3.2.tgz#53ae7d9d29bb03cf564493a026109f54c47f5f26"
pug-filters@^2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-2.1.5.tgz#66bf6e80d97fbef829bab0aa35eddff33fc964f3"
pug-filters@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-3.0.1.tgz#163ef73bfbb1f1544d032b2b40f45130eb52dccb"
dependencies:
clean-css "^3.3.0"
constantinople "^3.0.1"
jstransformer "1.0.0"
pug-error "^1.3.2"
pug-walk "^1.1.5"
pug-walk "^1.1.7"
resolve "^1.1.6"
uglify-js "^2.6.1"
@ -8159,20 +8171,20 @@ pug-lexer@^2.0.1:
is-expression "^3.0.0"
pug-error "^1.3.2"
pug-lexer@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-3.1.0.tgz#fd087376d4a675b4f59f8fef422883434e9581a2"
pug-lexer@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-4.0.0.tgz#210c18457ef2e1760242740c5e647bd794cec278"
dependencies:
character-parser "^2.1.1"
is-expression "^3.0.0"
pug-error "^1.3.2"
pug-linker@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/pug-linker/-/pug-linker-3.0.3.tgz#25f59eb750237f0368e59c3379764229c0189c41"
pug-linker@^3.0.5:
version "3.0.5"
resolved "https://registry.yarnpkg.com/pug-linker/-/pug-linker-3.0.5.tgz#9e9a7ae4005682d027deeb96b000f88eeb83a02f"
dependencies:
pug-error "^1.3.2"
pug-walk "^1.1.5"
pug-walk "^1.1.7"
pug-lint@2.5.0:
version "2.5.0"
@ -8192,16 +8204,16 @@ pug-lint@2.5.0:
strip-json-comments "^2.0.1"
void-elements "^2.0.1"
pug-load@^2.0.9:
version "2.0.9"
resolved "https://registry.yarnpkg.com/pug-load/-/pug-load-2.0.9.tgz#ee217c914cc1d9324d44b86c32d1df241d36de7a"
pug-load@^2.0.11:
version "2.0.11"
resolved "https://registry.yarnpkg.com/pug-load/-/pug-load-2.0.11.tgz#e648e57ed113fe2c1f45d57858ea2bad6bc01527"
dependencies:
object-assign "^4.1.0"
pug-walk "^1.1.5"
pug-walk "^1.1.7"
pug-parser@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/pug-parser/-/pug-parser-4.0.0.tgz#c9f52322e4eabe4bf5beeba64ed18373bb627801"
pug-parser@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/pug-parser/-/pug-parser-5.0.0.tgz#e394ad9b3fca93123940aff885c06e44ab7e68e4"
dependencies:
pug-error "^1.3.2"
token-stream "0.0.1"
@ -8210,28 +8222,32 @@ pug-runtime@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/pug-runtime/-/pug-runtime-2.0.3.tgz#98162607b0fce9e254d427f33987a5aee7168bda"
pug-strip-comments@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pug-strip-comments/-/pug-strip-comments-1.0.2.tgz#d313afa01bcc374980e1399e23ebf2eb9bdc8513"
pug-runtime@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pug-runtime/-/pug-runtime-2.0.4.tgz#e178e1bda68ab2e8c0acfc9bced2c54fd88ceb58"
pug-strip-comments@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/pug-strip-comments/-/pug-strip-comments-1.0.3.tgz#f1559592206edc6f85310dacf4afb48a025af59f"
dependencies:
pug-error "^1.3.2"
pug-walk@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/pug-walk/-/pug-walk-1.1.5.tgz#90e943acbcf7021e6454cf1b32245891cba6f851"
pug@2.0.0-rc.4:
version "2.0.0-rc.4"
resolved "https://registry.yarnpkg.com/pug/-/pug-2.0.0-rc.4.tgz#b7b08f6599bd5302568042b7436984fb28c80a13"
dependencies:
pug-code-gen "^2.0.0"
pug-filters "^2.1.5"
pug-lexer "^3.1.0"
pug-linker "^3.0.3"
pug-load "^2.0.9"
pug-parser "^4.0.0"
pug-runtime "^2.0.3"
pug-strip-comments "^1.0.2"
pug-walk@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/pug-walk/-/pug-walk-1.1.7.tgz#c00d5c5128bac5806bec15d2b7e7cdabe42531f3"
pug@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pug/-/pug-2.0.1.tgz#27c151612b53d729abe8e8285aac6bc89345b5d0"
dependencies:
pug-code-gen "^2.0.1"
pug-filters "^3.0.1"
pug-lexer "^4.0.0"
pug-linker "^3.0.5"
pug-load "^2.0.11"
pug-parser "^5.0.0"
pug-runtime "^2.0.4"
pug-strip-comments "^1.0.3"
pump@^1.0.0:
version "1.0.3"
@ -8917,6 +8933,10 @@ schema-utils@^0.4.2, schema-utils@^0.4.3:
ajv "^5.0.0"
ajv-keywords "^2.1.0"
scim-query-filter-parser@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/scim-query-filter-parser/-/scim-query-filter-parser-1.1.0.tgz#00ddfa0065e01d05715841eeba94d5ff364fa0d6"
scss-tokenizer@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"
@ -9112,9 +9132,9 @@ simple-lru-cache@0.0.x:
version "0.0.2"
resolved "https://registry.yarnpkg.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd"
simple-progress-webpack-plugin@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/simple-progress-webpack-plugin/-/simple-progress-webpack-plugin-1.1.1.tgz#bf0f12b064421aca53395919f9343a1849a587dc"
simple-progress-webpack-plugin@1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/simple-progress-webpack-plugin/-/simple-progress-webpack-plugin-1.1.2.tgz#eb366f6abd2e1f68cb8512762bbfcf3bce057d4b"
dependencies:
chalk "2.3.x"
figures "2.0.x"
@ -10111,9 +10131,9 @@ vue-hot-reload-api@^2.2.0:
version "2.2.4"
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.2.4.tgz#683bd1d026c0d3b3c937d5875679e9a87ec6cd8f"
vue-loader@14.1.1:
version "14.1.1"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-14.1.1.tgz#331f197fcea790d6b8662c29b850806e7eb29342"
vue-loader@14.2.1:
version "14.2.1"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-14.2.1.tgz#3ace19f98187b1fa9e0709defa963a0a2396b6b3"
dependencies:
consolidate "^0.14.0"
hash-sum "^1.0.2"
@ -10129,9 +10149,9 @@ vue-loader@14.1.1:
vue-style-loader "^4.0.1"
vue-template-es2015-compiler "^1.6.0"
vue-material-design-icons@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/vue-material-design-icons/-/vue-material-design-icons-1.1.0.tgz#1692bab1ddb2f16369bcb5f7344037fdc3a93d36"
vue-material-design-icons@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/vue-material-design-icons/-/vue-material-design-icons-1.2.1.tgz#3231ffc3c4aadbaf9de06e9c29b6994691f010aa"
vue-router@3.0.1:
version "3.0.1"
@ -10165,9 +10185,9 @@ vue@2.5.13:
version "2.5.13"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.13.tgz#95bd31e20efcf7a7f39239c9aa6787ce8cf578e1"
vuetify@1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/vuetify/-/vuetify-1.0.4.tgz#ef712e4ccd231d0d3678da31047d338d94e7f20d"
vuetify@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vuetify/-/vuetify-1.0.5.tgz#10e83123a78c82e3d9c2efe6734b7f55ba678dd4"
vuex-persistedstate@2.4.2:
version "2.4.2"

Loading…
Cancel
Save