admin-auth.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template lang='pug'>
  2. v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
  3. .pa-3.pt-4
  4. .headline.primary--text Authentication
  5. .subheading.grey--text Configure the authentication settings of your wiki
  6. v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
  7. v-tab(key='settings'): v-icon settings
  8. v-tab(v-for='strategy in activeStrategies', :key='strategy.key') {{ strategy.title }}
  9. v-tab-item(key='settings', :transition='false', :reverse-transition='false')
  10. v-card.pa-3(flat, tile)
  11. .body-2.grey--text.text--darken-1 Select which authentication strategies to enable:
  12. .caption.grey--text.pb-2 Some strategies require additional configuration in their dedicated tab (when selected).
  13. v-form
  14. v-checkbox(
  15. v-for='strategy in strategies',
  16. v-model='selectedStrategies',
  17. :key='strategy.key',
  18. :label='strategy.title',
  19. :value='strategy.key',
  20. color='primary',
  21. :disabled='strategy.key === `local`'
  22. hide-details
  23. )
  24. v-tab-item(v-for='(strategy, n) in activeStrategies', :key='strategy.key', :transition='false', :reverse-transition='false')
  25. v-card.pa-3(flat, tile)
  26. v-form
  27. v-subheader.pl-0 Strategy Configuration
  28. .body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
  29. v-text-field(
  30. v-else
  31. v-for='cfg in strategy.config'
  32. :key='cfg.key'
  33. :label='cfg.key'
  34. v-model='cfg.value'
  35. prepend-icon='settings_applications'
  36. )
  37. v-divider
  38. v-subheader.pl-0 Registration
  39. v-switch.ml-3(
  40. v-model='allowSelfRegistration',
  41. label='Allow self-registration',
  42. :value='true',
  43. color='primary',
  44. hint='Allow any user successfully authorized by the strategy to access the wiki.',
  45. persistent-hint
  46. )
  47. v-text-field.ml-3(
  48. label='Limit to specific email domains'
  49. prepend-icon='mail_outline'
  50. hint='Domain(s) seperated by comma. (e.g. domain1.com, domain2.com)'
  51. persistent-hint
  52. )
  53. v-text-field.ml-3(
  54. label='Assign to group'
  55. prepend-icon='people'
  56. hint='Automatically assign new users to these groups.'
  57. persistent-hint
  58. )
  59. v-card-chin
  60. v-btn(color='primary')
  61. v-icon(left) chevron_right
  62. span Save
  63. v-spacer
  64. v-btn(icon, @click='refresh')
  65. v-icon.grey--text refresh
  66. </template>
  67. <script>
  68. import _ from 'lodash'
  69. import strategiesQuery from 'gql/admin/auth/auth-query-strategies.gql'
  70. import strategiesSaveMutation from 'gql/admin/auth/auth-mutation-save-strategies.gql'
  71. export default {
  72. data() {
  73. return {
  74. strategies: [],
  75. selectedStrategies: ['local'],
  76. selfRegistration: false,
  77. domainWhitelist: [],
  78. autoEnrollGroups: []
  79. }
  80. },
  81. computed: {
  82. activeStrategies() {
  83. return _.filter(this.strategies, prv => _.includes(this.selectedStrategies, prv.key))
  84. }
  85. },
  86. methods: {
  87. async refresh() {
  88. await this.$apollo.queries.strategies.refetch()
  89. this.$store.commit('showNotification', {
  90. message: 'List of strategies has been refreshed.',
  91. style: 'success',
  92. icon: 'cached'
  93. })
  94. },
  95. async saveProviders() {
  96. this.$store.commit(`loadingStart`, 'admin-auth-savestrategies')
  97. await this.$apollo.mutate({
  98. mutation: strategiesSaveMutation,
  99. variables: {
  100. strategies: this.auths
  101. }
  102. })
  103. this.$store.commit(`loadingStop`, 'admin-auth-savestrategies')
  104. }
  105. },
  106. apollo: {
  107. strategies: {
  108. query: strategiesQuery,
  109. fetchPolicy: 'network-only',
  110. update: (data) => data.authentication.strategies,
  111. watchLoading (isLoading) {
  112. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
  113. }
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang='scss'>
  119. </style>