Detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <detail
  3. :on-manager="onManager"
  4. :data="Object.assign({}, data, configData)"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. :resource="resource"
  8. status-module="idp" />
  9. </template>
  10. <script>
  11. import { getEnabledTableColumn, getStatusTableColumn, getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  12. import WindowsMixin from '@/mixins/windows'
  13. import IdpSamlXml from '../components/IdpSamlXml'
  14. export default {
  15. name: 'IDPDetail',
  16. mixins: [WindowsMixin],
  17. props: {
  18. data: {
  19. type: Object,
  20. required: true,
  21. },
  22. onManager: {
  23. type: Function,
  24. required: true,
  25. },
  26. resource: String,
  27. },
  28. data () {
  29. const { isDomainMode } = this.$store.getters
  30. const driverOptions = Object.keys(this.$t('idpDrivers')).reduce((prev, current) => {
  31. prev[current.toLowerCase()] = current
  32. return prev
  33. }, {})
  34. return {
  35. configData: {},
  36. configChildrens: {
  37. cas: [
  38. {
  39. field: 'cas_server_url',
  40. title: this.$t('system.text_210'),
  41. },
  42. {
  43. title: 'Redirect URI',
  44. field: 'redirect_uri',
  45. },
  46. ],
  47. msad_one_domain: [
  48. {
  49. field: 'url',
  50. title: this.$t('system.text_217'),
  51. },
  52. {
  53. field: 'suffix',
  54. title: this.$t('system.text_219'),
  55. },
  56. {
  57. field: 'user',
  58. span: 24,
  59. title: this.$t('system.text_143'),
  60. },
  61. {
  62. field: 'user_tree_dn',
  63. span: 24,
  64. title: `${this.$t('dictionary.user')}DN`,
  65. },
  66. {
  67. field: 'group_tree_dn',
  68. title: `${this.$t('dictionary.group')}DN`,
  69. },
  70. ],
  71. msad_multi_domain: [
  72. {
  73. field: 'url',
  74. title: this.$t('system.text_217'),
  75. },
  76. {
  77. field: 'suffix',
  78. title: this.$t('system.text_219'),
  79. },
  80. {
  81. field: 'user',
  82. span: 24,
  83. title: this.$t('system.text_143'),
  84. },
  85. {
  86. field: 'domain_tree_dn',
  87. title: `${this.$t('dictionary.domain')}DN`,
  88. },
  89. ],
  90. openldap_one_domain: [
  91. {
  92. field: 'url',
  93. title: this.$t('system.text_217'),
  94. },
  95. {
  96. field: 'suffix',
  97. title: this.$t('system.text_219'),
  98. },
  99. {
  100. field: 'user',
  101. span: 24,
  102. title: this.$t('system.text_143'),
  103. },
  104. {
  105. field: 'user_tree_dn',
  106. span: 24,
  107. title: `${this.$t('dictionary.user')}DN`,
  108. },
  109. {
  110. field: 'group_tree_dn',
  111. title: `${this.$t('dictionary.group')}DN`,
  112. },
  113. {
  114. field: 'disable_user_on_import',
  115. title: this.$t('system.text_223'),
  116. slots: {
  117. default: ({ row }) => {
  118. return [
  119. <div class='text-truncate d-flex align-items-center'>
  120. <status status={ !row.disable_user_on_import } statusModule='enabled' />
  121. <help-tooltip class='ml-1' name='disable_user_on_import' />
  122. </div>,
  123. ]
  124. },
  125. },
  126. },
  127. ],
  128. oidc: [
  129. {
  130. field: 'client_id',
  131. title: 'ClientID',
  132. },
  133. {
  134. field: 'client_secret',
  135. title: 'ClientSecret',
  136. },
  137. {
  138. field: 'scopes',
  139. title: 'Scopes',
  140. },
  141. {
  142. field: 'auth_url',
  143. title: 'AuthUrl',
  144. },
  145. {
  146. field: 'token_url',
  147. title: 'TokenUrl',
  148. },
  149. {
  150. field: 'userinfo_url',
  151. title: 'UserinfoUrl',
  152. },
  153. ],
  154. github_oidc: [
  155. {
  156. field: 'client_id',
  157. title: 'ClientID',
  158. },
  159. {
  160. field: 'client_secret',
  161. title: 'ClientSecret',
  162. },
  163. ],
  164. azure_oidc: [
  165. {
  166. field: 'client_id',
  167. title: 'ClientID',
  168. },
  169. {
  170. field: 'client_secret',
  171. title: 'ClientSecret',
  172. },
  173. {
  174. field: 'tenant_id',
  175. title: 'TenantId',
  176. },
  177. {
  178. field: 'cloud_env',
  179. title: this.$t('common.region'),
  180. slots: {
  181. default: ({ row }) => {
  182. const value = (row.cloud_env || 'global').toLowerCase()
  183. if (value === 'global') {
  184. return this.$t('common_703')
  185. }
  186. if (value === 'china') {
  187. return this.$t('common_702')
  188. }
  189. },
  190. },
  191. },
  192. ],
  193. saml: [
  194. {
  195. field: 'entity_id',
  196. title: 'EntityId',
  197. },
  198. {
  199. title: 'RedirectSSOURL',
  200. field: 'redirect_sso_url',
  201. },
  202. ],
  203. azure_ad_saml: [
  204. {
  205. field: 'tenant_id',
  206. title: 'TenantId',
  207. },
  208. {
  209. field: 'cloud_env',
  210. title: this.$t('common.region'),
  211. slots: {
  212. default: ({ row }) => {
  213. const value = (row.cloud_env || 'global').toLowerCase()
  214. if (value === 'global') {
  215. return this.$t('common_703')
  216. }
  217. if (value === 'china') {
  218. return this.$t('common_702')
  219. }
  220. },
  221. },
  222. },
  223. ],
  224. feishu_oauth2: [
  225. {
  226. field: 'app_id',
  227. title: 'AppId',
  228. },
  229. {
  230. field: 'secret',
  231. title: 'Secret',
  232. },
  233. ],
  234. dingtalk_oauth2: [
  235. {
  236. field: 'app_id',
  237. title: 'AppId',
  238. },
  239. {
  240. field: 'secret',
  241. title: 'Secret',
  242. },
  243. ],
  244. qywechat_oauth2: [
  245. {
  246. field: 'corp_id',
  247. title: this.$t('system.cropid'),
  248. },
  249. {
  250. field: 'agent_id',
  251. title: 'AgentId',
  252. },
  253. {
  254. field: 'secret',
  255. title: 'Secret',
  256. },
  257. ],
  258. google_oidc: [],
  259. },
  260. baseInfo: [
  261. {
  262. field: 'project_domain',
  263. title: (isDomainMode || this.data.domain_id) ? this.$t('common_566', [this.$t('dictionary.domain')]) : this.$t('common_548'),
  264. slots: {
  265. default: ({ row }) => {
  266. if (!row.domain_id) return this.$t('system.text_15')
  267. return <side-page-trigger permission='domains_get' name='DomainSidePage' id={row.domain_id} vm={this}>{ row.project_domain }</side-page-trigger>
  268. },
  269. },
  270. },
  271. getEnabledTableColumn(),
  272. getStatusTableColumn({ title: this.$t('system.text_203'), field: 'sync_status', statusModule: 'sync' }),
  273. getEnabledTableColumn({ title: this.$t('common_501'), field: 'auto_create_user', minWidth: 130 }),
  274. getCopyWithContentTableColumn({
  275. field: 'target_domain',
  276. title: this.$t('common_556'),
  277. }),
  278. {
  279. field: 'driver',
  280. title: this.$t('system.text_204'),
  281. formatter: ({ row }) => {
  282. return driverOptions[row.driver] || row.driver
  283. },
  284. },
  285. getCopyWithContentTableColumn({
  286. field: 'template',
  287. title: this.$t('common_550'),
  288. hideField: true,
  289. message: (row) => {
  290. const v = row.template || row.driver
  291. return this.$t('idpTmplTitles')[v] ? this.$t(`idpTmplTitles.${v}`) : v || '-'
  292. },
  293. slotCallback: (row) => {
  294. const v = row.template || row.driver
  295. return this.$t('idpTmplTitles')[v] ? this.$t(`idpTmplTitles.${v}`) : v || '-'
  296. },
  297. }),
  298. {
  299. field: 'last_sync',
  300. title: this.$t('system.text_254'),
  301. formatter: ({ row }) => {
  302. return this.$moment(row.last_sync).format()
  303. },
  304. },
  305. ],
  306. extraInfo: [
  307. {
  308. title: this.$t('common_553'),
  309. slots: {
  310. default: ({ row }) => {
  311. return [
  312. <IdpSamlXml data={ row } />,
  313. ]
  314. },
  315. },
  316. hidden: () => {
  317. const show = this.data.driver === 'saml' && !this.data.template
  318. return !show
  319. },
  320. },
  321. {
  322. title: this.$t('iam.idp_config_info'),
  323. hidden: () => {
  324. return !['saml', 'oidc', 'oauth2', 'cas'].includes(this.data.driver)
  325. },
  326. items: [
  327. getCopyWithContentTableColumn({
  328. title: this.data.driver === 'saml' ? 'AssertionURI' : 'RedirectURI',
  329. field: 'redirect_uri',
  330. hideField: true,
  331. message: (row) => {
  332. return row.remoteConfig?.redirect_uri || '-'
  333. },
  334. slotCallback: (row) => {
  335. return row.remoteConfig?.redirect_uri || '-'
  336. },
  337. }),
  338. ],
  339. },
  340. {
  341. title: this.$t('system.text_173'),
  342. items: [
  343. {
  344. field: 'domain_count',
  345. title: this.$t('dictionary.domain'),
  346. },
  347. {
  348. field: 'project_count',
  349. title: this.$t('dictionary.project'),
  350. },
  351. {
  352. field: 'group_count',
  353. title: this.$t('dictionary.group'),
  354. },
  355. {
  356. field: 'user_count',
  357. title: this.$t('dictionary.user'),
  358. },
  359. {
  360. field: 'role_count',
  361. title: this.$t('dictionary.role'),
  362. },
  363. {
  364. field: 'policy_count',
  365. title: this.$t('dictionary.policy'),
  366. },
  367. ],
  368. },
  369. ],
  370. }
  371. },
  372. created () {
  373. this.fetchQueryConfig()
  374. },
  375. methods: {
  376. async fetchQueryConfig () {
  377. try {
  378. const manager = new this.$Manager('identity_providers', 'v1')
  379. const { data: { config } } = await manager.getSpecific({ id: this.data.id, spec: 'config' })
  380. const template = this.data.template || this.data.driver
  381. if (config) {
  382. if (template && this.data.driver) {
  383. const _config = config[this.data.driver]
  384. if (template === 'qywechat_oauth2') {
  385. const { app_id } = _config
  386. const [corp_id, agent_id] = app_id.split('/')
  387. _config.corp_id = corp_id
  388. _config.agent_id = agent_id
  389. delete _config.app_id
  390. }
  391. _config.remoteConfig = {}
  392. if (this.data.driver === 'saml' || this.data.driver === 'oidc' || this.data.driver === 'oauth2' || this.data.driver === 'cas') {
  393. _config.remoteConfig = await this.queryCallbackUri()
  394. }
  395. this.configData = _config
  396. this.extraInfo.unshift({
  397. title: this.$t('system.text_255'),
  398. items: this.configChildrens[template].map(item => {
  399. if (item.slots) {
  400. return item
  401. }
  402. return getCopyWithContentTableColumn({
  403. ...item,
  404. })
  405. }),
  406. })
  407. }
  408. }
  409. } catch (err) {
  410. throw err
  411. }
  412. },
  413. async queryCallbackUri () {
  414. try {
  415. const manager = new this.$Manager('auth/idp', 'v1')
  416. const { data } = await manager.getSpecific({
  417. id: this.data.id,
  418. spec: 'info',
  419. })
  420. return data
  421. } catch (err) {
  422. throw err
  423. }
  424. },
  425. },
  426. }
  427. </script>