admin-auth.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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='strategy.isEnabled'
  17. :key='strategy.key'
  18. :label='strategy.title'
  19. color='primary'
  20. :disabled='strategy.key === `local`'
  21. hide-details
  22. )
  23. v-tab-item(v-for='(strategy, n) in activeStrategies', :key='strategy.key', :transition='false', :reverse-transition='false')
  24. v-card.pa-3(flat, tile)
  25. v-form
  26. v-subheader.pl-0 Strategy Configuration
  27. .body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
  28. v-text-field(
  29. v-else
  30. v-for='cfg in strategy.config'
  31. :key='cfg.key'
  32. :label='cfg.key'
  33. v-model='cfg.value'
  34. prepend-icon='settings_applications'
  35. )
  36. v-divider
  37. v-subheader.pl-0 Registration
  38. .pr-3
  39. v-switch.ml-3(
  40. v-model='strategy.selfRegistration'
  41. label='Allow self-registration'
  42. color='primary'
  43. hint='Allow any user successfully authorized by the strategy to access the wiki.'
  44. persistent-hint
  45. )
  46. v-select.ml-3(
  47. label='Limit to specific email domains'
  48. v-model='strategy.domainWhitelist'
  49. prepend-icon='mail_outline'
  50. persistent-hint
  51. deletable-chips
  52. clearable
  53. multiple
  54. chips
  55. tags
  56. )
  57. v-select.ml-3(
  58. :items='groups'
  59. item-text='name'
  60. item-value='id'
  61. label='Assign to group'
  62. v-model='strategy.autoEnrollGroups'
  63. prepend-icon='people'
  64. hint='Automatically assign new users to these groups.'
  65. persistent-hint
  66. deletable-chips
  67. autocomplete
  68. clearable
  69. multiple
  70. chips
  71. )
  72. v-card-chin
  73. v-btn(color='primary', @click='save')
  74. v-icon(left) chevron_right
  75. span Save
  76. v-spacer
  77. v-btn(icon, @click='refresh')
  78. v-icon.grey--text refresh
  79. </template>
  80. <script>
  81. import _ from 'lodash'
  82. import groupsQuery from 'gql/admin/auth/auth-query-groups.gql'
  83. import strategiesQuery from 'gql/admin/auth/auth-query-strategies.gql'
  84. import strategiesSaveMutation from 'gql/admin/auth/auth-mutation-save-strategies.gql'
  85. export default {
  86. data() {
  87. return {
  88. groups: [],
  89. strategies: []
  90. }
  91. },
  92. computed: {
  93. activeStrategies() {
  94. return _.filter(this.strategies, 'isEnabled')
  95. }
  96. },
  97. methods: {
  98. async refresh() {
  99. await this.$apollo.queries.strategies.refetch()
  100. this.$store.commit('showNotification', {
  101. message: 'List of strategies has been refreshed.',
  102. style: 'success',
  103. icon: 'cached'
  104. })
  105. },
  106. async save() {
  107. this.$store.commit(`loadingStart`, 'admin-auth-savestrategies')
  108. await this.$apollo.mutate({
  109. mutation: strategiesSaveMutation,
  110. variables: {
  111. strategies: this.strategies.map(str => _.pick(str, [
  112. 'isEnabled',
  113. 'key',
  114. 'config',
  115. 'selfRegistration',
  116. 'domainWhitelist',
  117. 'autoEnrollGroups'
  118. ]))
  119. }
  120. })
  121. this.$store.commit('showNotification', {
  122. message: 'Strategies saved successfully.',
  123. style: 'success',
  124. icon: 'check'
  125. })
  126. this.$store.commit(`loadingStop`, 'admin-auth-savestrategies')
  127. }
  128. },
  129. apollo: {
  130. strategies: {
  131. query: strategiesQuery,
  132. fetchPolicy: 'network-only',
  133. update: (data) => _.cloneDeep(data.authentication.strategies),
  134. watchLoading (isLoading) {
  135. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
  136. }
  137. },
  138. groups: {
  139. query: groupsQuery,
  140. fetchPolicy: 'network-only',
  141. update: (data) => data.groups.list,
  142. watchLoading (isLoading) {
  143. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-groups-refresh')
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang='scss'>
  150. </style>