w-web-sso 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.github/workflows/ci-test.yml +24 -0
  5. package/.jsdoc +25 -0
  6. package/.vscode/launch.json +20 -0
  7. package/LICENSE +21 -0
  8. package/README.md +25 -0
  9. package/SECURITY.md +5 -0
  10. package/babel.config.js +15 -0
  11. package/dist/css/app.969ad1db.css +1 -0
  12. package/dist/index.tmp +3 -0
  13. package/dist/js/app-legacy.ff64be1c.js +2 -0
  14. package/dist/js/app-legacy.ff64be1c.js.map +1 -0
  15. package/dist/js/app.ff64be1c.js +2 -0
  16. package/dist/js/app.ff64be1c.js.map +1 -0
  17. package/dist/js/chunk-vendors-legacy.0bb7a31b.js +13 -0
  18. package/dist/js/chunk-vendors-legacy.0bb7a31b.js.map +1 -0
  19. package/dist/js/chunk-vendors.0bb7a31b.js +13 -0
  20. package/dist/js/chunk-vendors.0bb7a31b.js.map +1 -0
  21. package/dist/w-web-sso.umd.js +7 -0
  22. package/dist/w-web-sso.umd.js.map +1 -0
  23. package/docs/WWebSso.html +938 -0
  24. package/docs/WWebSso.mjs.html +721 -0
  25. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  26. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  29. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  43. package/docs/index.html +84 -0
  44. package/docs/scripts/collapse.js +39 -0
  45. package/docs/scripts/commonNav.js +28 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +99 -0
  53. package/docs/styles/jsdoc.css +776 -0
  54. package/docs/styles/prettify.css +80 -0
  55. package/g.backupDb.mjs +10 -0
  56. package/g.getSettings.mjs +17 -0
  57. package/g.initialData.mjs +94 -0
  58. package/g.initialTestData.mjs +21 -0
  59. package/g.mOrm.mjs +24 -0
  60. package/g.provideUsers.mjs +45 -0
  61. package/package.json +70 -0
  62. package/public/index.html +30 -0
  63. package/script.txt +22 -0
  64. package/server/WWebSso.mjs +649 -0
  65. package/server/hashPassword.mjs +27 -0
  66. package/server/proc.mjs +543 -0
  67. package/server/provideUsers.mjs +68 -0
  68. package/src/App.vue +123 -0
  69. package/src/components/Common/CheckYes.vue +85 -0
  70. package/src/components/Common/CheckYesNo.vue +91 -0
  71. package/src/components/Common/LabelItem.vue +106 -0
  72. package/src/components/Common/LoadingWinBar.vue +115 -0
  73. package/src/components/Layout.vue +160 -0
  74. package/src/components/LayoutContent.vue +193 -0
  75. package/src/components/LayoutContentUsers.vue +498 -0
  76. package/src/components/LayoutState.vue +91 -0
  77. package/src/components/PageLogin.vue +524 -0
  78. package/src/components/VeUser.vue +446 -0
  79. package/src/components/ruleGroup.vue +645 -0
  80. package/src/main.js +97 -0
  81. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  82. package/src/plugins/mDataSupport.mjs +23 -0
  83. package/src/plugins/mShare.mjs +229 -0
  84. package/src/plugins/mUI.mjs +229 -0
  85. package/src/schema/gi.mjs +8 -0
  86. package/src/schema/index.mjs +18 -0
  87. package/src/schema/tables/tokens.mjs +70 -0
  88. package/src/schema/tables/users.mjs +110 -0
  89. package/src/store/actions.mjs +1 -0
  90. package/src/store/getters.mjs +1 -0
  91. package/src/store/index.mjs +25 -0
  92. package/src/store/mutations.mjs +333 -0
  93. package/src/store/types.mjs +15 -0
  94. package/srv.mjs +84 -0
  95. package/tableTags-web-sso.json +1 -0
  96. package/test/all.test.mjs +10 -0
  97. package/toolg/addVersion.mjs +4 -0
  98. package/toolg/cleanFolder.mjs +4 -0
  99. package/toolg/gDistRollup.mjs +36 -0
  100. package/toolg/genEntry.mjs +23 -0
  101. package/toolg/modifyReadme.mjs +4 -0
  102. package/vue.config.js +15 -0
@@ -0,0 +1,110 @@
1
+ import map from 'lodash-es/map.js'
2
+ import keys from 'lodash-es/keys.js'
3
+ import genID from 'wsemi/src/genID.mjs'
4
+ import dtmapping from 'wsemi/src/dtmapping.mjs'
5
+ import dtpick from 'wsemi/src/dtpick.mjs'
6
+ import nowms2str from 'wsemi/src/nowms2str.mjs'
7
+ import now2strp from 'wsemi/src/now2strp.mjs'
8
+
9
+
10
+ let keyTable = 'users'
11
+ let tableNameCht = '使用者'
12
+ let tableNameEng = 'Users'
13
+
14
+
15
+ let settings = {
16
+ id: {
17
+ pk: true,
18
+ name: '主鍵',
19
+ type: 'STRING',
20
+ },
21
+ order: {
22
+ name: '順序',
23
+ type: 'INTEGER',
24
+ },
25
+ account: {
26
+ name: '帳號',
27
+ type: 'STRING',
28
+ },
29
+ password: {
30
+ name: '密碼', //須儲存加鹽雜湊處理後密碼
31
+ type: 'STRING',
32
+ },
33
+ name: {
34
+ name: '姓名',
35
+ type: 'STRING',
36
+ },
37
+ email: {
38
+ name: '電子郵件',
39
+ type: 'STRING',
40
+ },
41
+ description: {
42
+ name: '描述',
43
+ type: 'TEXT',
44
+ },
45
+ from: {
46
+ name: '來源',
47
+ type: 'STRING',
48
+ },
49
+ ruleGroupsIds: {
50
+ name: '所屬權限群組主鍵', //多主鍵用分號區隔
51
+ type: 'STRING',
52
+ },
53
+ redir: {
54
+ name: '登入後轉址',
55
+ type: 'STRING',
56
+ },
57
+ isAdmin: {
58
+ name: '是否為系統管理員',
59
+ type: 'STRING',
60
+ },
61
+ userId: {
62
+ name: '創建使用者主鍵',
63
+ type: 'STRING',
64
+ },
65
+ timeCreate: {
66
+ name: '創建時間',
67
+ type: 'STRING',
68
+ },
69
+ userIdUpdate: {
70
+ name: '最新變更使用者主鍵',
71
+ type: 'STRING',
72
+ },
73
+ timeUpdate: {
74
+ name: '更新時間',
75
+ type: 'STRING',
76
+ },
77
+ isActive: {
78
+ name: '是否有效',
79
+ type: 'STRING',
80
+ },
81
+ }
82
+
83
+ let funNew = (ndata = {}) => {
84
+ let o = dtmapping(ndata, keys(settings))
85
+ o.id = `${now2strp()}-${genID()}`
86
+ o.isAdmin = 'n'
87
+ o.userIdUpdate = o.userId
88
+ o.timeCreate = nowms2str()
89
+ o.timeUpdate = o.timeCreate
90
+ o.isActive = 'y'
91
+ return o
92
+ }
93
+
94
+ let funTest = () => {
95
+ let rs = []
96
+ return rs
97
+ }
98
+
99
+ let tab = {
100
+ keyTable,
101
+ tableNameCht,
102
+ tableNameEng,
103
+ settings,
104
+ funNew,
105
+ funTest,
106
+ }
107
+
108
+
109
+ export default tab
110
+
@@ -0,0 +1 @@
1
+ //非同步執行, 不需要
@@ -0,0 +1 @@
1
+ //不需要
@@ -0,0 +1,25 @@
1
+ import Vue from 'vue'
2
+ import Vuex from 'vuex'
3
+ import { state, mutations } from './mutations.mjs'
4
+ import * as getters from './getters.mjs'
5
+ import * as actions from './actions.mjs'
6
+ import * as types from './types.mjs'
7
+
8
+
9
+ //use
10
+ Vue.use(Vuex)
11
+
12
+ let st = new Vuex.Store({
13
+ state,
14
+ mutations,
15
+ getters,
16
+ actions,
17
+ strict: true, //嚴格模式禁止修改state
18
+ })
19
+
20
+ //save to $store
21
+ st.types = types
22
+ Vue.prototype.$store = st
23
+ // console.log('$store', st)
24
+
25
+ export default st
@@ -0,0 +1,333 @@
1
+ import each from 'lodash-es/each.js'
2
+ import set from 'lodash-es/set.js'
3
+ import * as types from './types.mjs'
4
+ import ds from '../schema/index.mjs'
5
+
6
+
7
+ //state, 全域狀態
8
+ let state = {
9
+
10
+ hostname: `${window.location.origin}`,
11
+ webInfor: {},
12
+ connState: '連線中...',
13
+ syncState: false,
14
+ viewState: 'lists',
15
+ loading: false,
16
+ settings: {
17
+ leftDrawerWidth: 200,
18
+ },
19
+
20
+ heightApp: 0,
21
+ heightAppEff: 0,
22
+ heightToolbar: 60,
23
+
24
+ menu: {}, //初始值需為物件, 否則LayoutContent會取menu.key出錯
25
+
26
+ userToken: '',
27
+ user: {
28
+ id: '', //id-for-admin
29
+ name: '', //測試者
30
+ email: '', //admin@example.com
31
+ isAdmin: 'n',
32
+ },
33
+
34
+ lang: 'cht',
35
+ keyLangs: {
36
+
37
+ systemMessage: {
38
+ eng: 'System message',
39
+ cht: '系統確認訊息',
40
+ },
41
+ ok: {
42
+ eng: 'OK',
43
+ cht: '確認',
44
+ },
45
+ no: {
46
+ eng: 'No',
47
+ cht: '取消',
48
+ },
49
+ yes: {
50
+ eng: 'Yes',
51
+ cht: '確定',
52
+ },
53
+
54
+ empty: {
55
+ eng: 'Empty',
56
+ cht: '無',
57
+ },
58
+ waitingData: {
59
+ eng: 'Waiting data...',
60
+ cht: '等待數據中...',
61
+ },
62
+
63
+ isEditabled: {
64
+ eng: 'Editable',
65
+ cht: '是否編輯',
66
+ },
67
+ saveChanges: {
68
+ eng: `Save changes`,
69
+ cht: `儲存變更`,
70
+ },
71
+ from: {
72
+ eng: `From`,
73
+ cht: `來源`,
74
+ },
75
+ save: {
76
+ eng: `Save`,
77
+ cht: `儲存`,
78
+ },
79
+ close: {
80
+ eng: `Close`,
81
+ cht: `關閉`,
82
+ },
83
+ cancel: {
84
+ eng: `Cancel`,
85
+ cht: `取消`,
86
+ },
87
+ processing: {
88
+ eng: `Processing...`,
89
+ cht: `處理中請稍後...`,
90
+ },
91
+ anUnexpectedErrorOccurred: {
92
+ eng: `An unexpected error occurred, please contact the administrator`,
93
+ cht: `發生非預期錯誤,請洽管理員`,
94
+ },
95
+ unknow: {
96
+ eng: `Unknow`,
97
+ cht: `未知`,
98
+ },
99
+
100
+ account: {
101
+ eng: `Account`,
102
+ cht: `帳號`,
103
+ },
104
+ password: {
105
+ eng: `Password`,
106
+ cht: `密碼`,
107
+ },
108
+ username: {
109
+ eng: `Username`,
110
+ cht: `使用者姓名`,
111
+ },
112
+ email: {
113
+ eng: `Email`,
114
+ cht: `電子郵件`,
115
+ },
116
+ name: {
117
+ eng: `Name`,
118
+ cht: `名稱`,
119
+ },
120
+ description: {
121
+ eng: `Description`,
122
+ cht: `說明`,
123
+ },
124
+ noDescription: {
125
+ eng: `No description`,
126
+ cht: `無說明`,
127
+ },
128
+
129
+ login: {
130
+ eng: `Login`,
131
+ cht: `登入`,
132
+ },
133
+ logout: {
134
+ eng: `Logout`,
135
+ cht: `登出`,
136
+ },
137
+
138
+ failedLoginForNoWebKey: {
139
+ eng: `Can not get the web key`,
140
+ cht: `無有效站台唯一識別資訊`,
141
+ },
142
+ failedLoginForNoToken: {
143
+ eng: `Can not get the token`,
144
+ cht: `無有效金鑰`,
145
+ },
146
+ failedLoginForNoRedir: {
147
+ eng: `Can not get the url for redirection`,
148
+ cht: `無有效轉址`,
149
+ },
150
+ failedLoginForCatch: {
151
+ eng: `User account or password is incorrect`,
152
+ cht: `使用者帳密錯誤無法登入`,
153
+ },
154
+
155
+ userList: {
156
+ eng: `User list`,
157
+ cht: `使用者分類清單`,
158
+ },
159
+ addUser: {
160
+ eng: `Add user`,
161
+ cht: `新增使用者`,
162
+ },
163
+
164
+ editUser: {
165
+ eng: `Edit user`,
166
+ cht: `編修使用者`,
167
+ },
168
+ isAManager: {
169
+ eng: `Is a manager`,
170
+ cht: `是否為管理者`,
171
+ },
172
+ isActive: {
173
+ eng: 'Is active',
174
+ cht: '是否有效',
175
+ },
176
+ remark: {
177
+ eng: `Remark`,
178
+ cht: `備註`,
179
+ },
180
+ dayCreate: {
181
+ eng: 'Create day',
182
+ cht: '創建日期',
183
+ },
184
+ newUser: {
185
+ eng: `New user`,
186
+ cht: `新使用者`,
187
+ },
188
+ failedToAddUser: {
189
+ eng: `Failed to add the user`,
190
+ cht: `新增使用者失敗`,
191
+ },
192
+ successfulToAddUser: {
193
+ eng: `Add the user successfully`,
194
+ cht: `新增使用者成功`,
195
+ },
196
+ confirmToDeleteUser: {
197
+ eng: `Do you want to delete the user[{name}]?`,
198
+ cht: `確認是否刪除使用者`,
199
+ },
200
+ failedToDeleteUser: {
201
+ eng: `Failed to delete the user`,
202
+ cht: `刪除使用者失敗`,
203
+ },
204
+ successfulToDeleteUser: {
205
+ eng: `Delete the user successfully`,
206
+ cht: `刪除使用者成功`,
207
+ },
208
+ cannotShowUserDetailsInViewMode: {
209
+ eng: `Can not show the user details in the view mode`,
210
+ cht: `非編輯模式無法查閱使用者詳細資訊`,
211
+ },
212
+
213
+ allDefaults: {
214
+ eng: `All defaults`,
215
+ cht: `全部項目預設值`,
216
+ },
217
+ show: {
218
+ eng: `Show`,
219
+ cht: `顯示`,
220
+ },
221
+ active: {
222
+ eng: `Active`,
223
+ cht: `啟用`,
224
+ },
225
+ showChildren: {
226
+ eng: `Show children`,
227
+ cht: `所屬顯示`,
228
+ },
229
+ hideChildren: {
230
+ eng: `Hide children`,
231
+ cht: `所屬不顯示`,
232
+ },
233
+ activateChildren: {
234
+ eng: `Activate children`,
235
+ cht: `所屬啟用`,
236
+ },
237
+ deactivateChildren: {
238
+ eng: `Deactivate children`,
239
+ cht: `所屬不啟用`,
240
+ },
241
+ isUsernameEmpty: {
242
+ eng: `Username is empty`,
243
+ cht: `使用者名稱不得為空`,
244
+ },
245
+ failedToSaveUser: {
246
+ eng: `Failed to save the user`,
247
+ cht: `變更使用者失敗`,
248
+ },
249
+ successfulToSaveUser: {
250
+ eng: `Save the user successfully`,
251
+ cht: `變更使用者成功`,
252
+ },
253
+
254
+ },
255
+ kpText: {},
256
+
257
+ }
258
+
259
+ //添加各資料表
260
+ each(ds, (v, k) => {
261
+ state[k] = null //初始化null
262
+ })
263
+
264
+ //儲存至state
265
+ export { state }
266
+
267
+ //mutations, 同步執行
268
+ export let mutations = {
269
+
270
+ [types.UpdateWebInfor] (state, webInfor) {
271
+ state.webInfor = webInfor
272
+ },
273
+
274
+ [types.UpdateLang] (state, lang) {
275
+ state.lang = lang
276
+ },
277
+
278
+ [types.UpdateKpText] (state, kpText) {
279
+ state.kpText = kpText
280
+ },
281
+
282
+ [types.UpdateConnState] (state, connState) {
283
+ state.connState = connState
284
+ },
285
+
286
+ [types.UpdateSyncState] (state, syncState) {
287
+ state.syncState = syncState
288
+ },
289
+
290
+ [types.UpdateLoading] (state, loading) {
291
+ state.loading = loading
292
+ },
293
+
294
+ [types.UpdateViewState] (state, viewState) {
295
+ state.viewState = viewState
296
+ },
297
+
298
+ [types.UpdateTableData] (state, msg) {
299
+ state[msg.tableName] = msg.data
300
+ },
301
+
302
+ [types.UpdateData] (state, msg) {
303
+ //msg.path內為存取路徑, 需使用set處理
304
+ // console.log('UpdateData msg', msg)
305
+ set(state, msg.path, msg.data)
306
+ },
307
+
308
+ [types.UpdateHeightApp] (state, heightApp) {
309
+ state.heightApp = heightApp
310
+ },
311
+
312
+ [types.UpdateHeightAppEff] (state, heightAppEff) {
313
+ state.heightAppEff = heightAppEff
314
+ },
315
+
316
+ [types.UpdateHeightToolbar] (state, heightToolbar) {
317
+ state.heightToolbar = heightToolbar
318
+ },
319
+
320
+ [types.UpdateMenu] (state, menu) {
321
+ state.menu = menu
322
+ },
323
+
324
+ [types.UpdateUserToken] (state, userToken) {
325
+ state.userToken = userToken
326
+ },
327
+
328
+ [types.UpdateUserSelf] (state, userSelf) {
329
+ state.userSelf = userSelf
330
+ },
331
+
332
+ }
333
+
@@ -0,0 +1,15 @@
1
+ export const UpdateWebInfor = 'UpdateWebInfor'
2
+ export const UpdateLang = 'UpdateLang'
3
+ export const UpdateKpText = 'UpdateKpText'
4
+ export const UpdateConnState = 'UpdateConnState'
5
+ export const UpdateSyncState = 'UpdateSyncState'
6
+ export const UpdateLoading = 'UpdateLoading'
7
+ export const UpdateViewState = 'UpdateViewState'
8
+ export const UpdateTableData = 'UpdateTableData'
9
+ export const UpdateData = 'UpdateData'
10
+ export const UpdateHeightApp = 'UpdateHeightApp'
11
+ export const UpdateHeightAppEff = 'UpdateHeightAppEff'
12
+ export const UpdateHeightToolbar = 'UpdateHeightToolbar'
13
+ export const UpdateMenu = 'UpdateMenu'
14
+ export const UpdateUserToken = 'UpdateUserToken'
15
+ export const UpdateUserSelf = 'UpdateUserSelf'
package/srv.mjs ADDED
@@ -0,0 +1,84 @@
1
+ import WOrm from 'w-orm-mongodb/src/WOrmMongodb.mjs' //自行選擇引用ORM, 使用Mongodb測試
2
+ import WWebSso from './server/WWebSso.mjs'
3
+ import getSettings from './g.getSettings.mjs'
4
+
5
+
6
+ //st
7
+ let st = getSettings()
8
+
9
+ let url = `mongodb://${st.dbUsername}:${st.dbPassword}@${st.dbIP}:${st.dbPort}` //使用Mongodb測試
10
+ let db = st.dbName
11
+ let opt = {
12
+
13
+ bCheckUser: false,
14
+ getUserById: null,
15
+ bExcludeWhenNotAdmin: false,
16
+
17
+ serverPort: 11007,
18
+ subfolder: '', //msso
19
+ urlRedirect: 'https://www.google.com/', //本機測試時得先編譯, 再瀏覽: http://localhost:11007/
20
+
21
+ webName: {
22
+ 'eng': 'Single Sign-On System',
23
+ 'cht': '使用者單一登入系統',
24
+ },
25
+ webDescription: {
26
+ 'eng': 'A web service package for Single Sign-On.',
27
+ 'cht': 'A web service package for Single Sign-On.',
28
+ },
29
+ webLogo: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaWQ9Ikljb25zIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDp1cmwoI2xpbmVhci1ncmFkaWVudCk7fS5jbHMtMntmaWxsOnVybCgjbGluZWFyLWdyYWRpZW50LTIpO30uY2xzLTN7ZmlsbDojM2QzYzQ0O30uY2xzLTR7ZmlsbDp1cmwoI2xpbmVhci1ncmFkaWVudC0zKTt9PC9zdHlsZT48bGluZWFyR3JhZGllbnQgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIGlkPSJsaW5lYXItZ3JhZGllbnQiIHgxPSIxMiIgeDI9IjEyIiB5MT0iMC4xOTEiIHkyPSI4Ljk4NCI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjNWQ1YzY2Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjNDg0NzRmIi8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIGlkPSJsaW5lYXItZ3JhZGllbnQtMiIgeDE9IjEyIiB4Mj0iMTIiIHkxPSI5LjA4NSIgeTI9IjIzLjAwMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZmNjUwIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZhYjE3Ii8+PC9saW5lYXJHcmFkaWVudD48bGluZWFyR3JhZGllbnQgaWQ9ImxpbmVhci1ncmFkaWVudC0zIiB4Mj0iMTIiIHhsaW5rOmhyZWY9IiNsaW5lYXItZ3JhZGllbnQiIHkxPSIxMi45MTUiIHkyPSIxNy4wOTYiLz48L2RlZnM+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTcsMTBhMSwxLDAsMCwxLTEtMVY2QTQsNCwwLDAsMCw4LDZWOUExLDEsMCwwLDEsNiw5VjZBNiw2LDAsMCwxLDE4LDZWOUExLDEsMCwwLDEsMTcsMTBaIi8+PHJlY3QgY2xhc3M9ImNscy0yIiBoZWlnaHQ9IjE0IiByeD0iMyIgd2lkdGg9IjE4IiB4PSIzIiB5PSI5Ii8+PHBhdGggY2xhc3M9ImNscy0zIiBkPSJNMTIsMjBhMSwxLDAsMCwxLTEtMVYxNmExLDEsMCwwLDEsMiwwdjNBMSwxLDAsMCwxLDEyLDIwWiIvPjxjaXJjbGUgY2xhc3M9ImNscy00IiBjeD0iMTIiIGN5PSIxNSIgcj0iMiIvPjwvc3ZnPg==',
30
+ webBackgoundGradientColors: ['#FFE0B2', '#FFCC80', '#FFF59D', 'rgba(255, 224, 178, 0.5)', 'rgba(240, 220, 190, 0.7)'],
31
+ webKey: 'ksso',
32
+
33
+ salt: '{salt}',
34
+
35
+ timeExpired: 30, //min
36
+
37
+ }
38
+
39
+ let getUserByToken = async (token) => {
40
+ // return {} //測試無法登入
41
+ if (token === '{token-for-application}') { //提供外部應用系統作為存取使用者
42
+ return {
43
+ id: 'id-for-application',
44
+ name: 'application',
45
+ email: 'application@example.com',
46
+ isAdmin: 'y',
47
+ }
48
+ }
49
+ if (token === 'sys') { //開發階段w-ui-loginout自動給予browser使用者(且位於localhost)的token為sys
50
+ return {
51
+ id: 'id-for-admin',
52
+ name: 'tester',
53
+ email: 'admin@example.com', //mappingBy為email, 開發階段時會使用email找到所建置之使用者資料
54
+ isAdmin: 'y',
55
+ }
56
+ }
57
+ console.log('invalid token', token)
58
+ console.log('於生產環境時得加入SSO等驗證token機制')
59
+ return {}
60
+ }
61
+
62
+ let verifyBrowserUser = (user, caller) => {
63
+ console.log('verifyBrowserUser/user', user)
64
+ // return false //測試無法登入
65
+ console.log('於生產環境時得加入限制瀏覽器使用者身份機制')
66
+ return user.isAdmin === 'y' //測試僅系統管理者使用
67
+ }
68
+
69
+ let verifyAppUser = (user, caller) => {
70
+ console.log('verifyAppUser/user', user)
71
+ // return false //測試無法登入
72
+ console.log('於生產環境時得加入限制應用程式使用者身份機制')
73
+ return user.isAdmin === 'y' //測試僅系統管理者使用
74
+ }
75
+
76
+ //WWebSso
77
+ let instWWebSso = WWebSso(WOrm, url, db, getUserByToken, verifyBrowserUser, verifyAppUser, opt)
78
+
79
+ instWWebSso.on('error', (err) => {
80
+ console.log(err)
81
+ })
82
+
83
+
84
+ //node --experimental-modules srv.mjs
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,10 @@
1
+ import assert from 'assert'
2
+
3
+
4
+ describe('all', function() {
5
+
6
+ it('test in localhost', function() {
7
+ assert.strict.deepEqual(1, 1)
8
+ })
9
+
10
+ })
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,4 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('docs')
@@ -0,0 +1,36 @@
1
+ // import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
2
+ import rollupFile from 'w-package-tools/src/rollupFile.mjs' //因只有1檔案且不需刪除dsit故改用rollupFile
3
+
4
+
5
+ let fdSrc = './server' //'./src'
6
+ let fdTar = './dist'
7
+
8
+
9
+ rollupFile({
10
+ // fns: ['WWebSso.mjs'],
11
+ fn: 'WWebSso.mjs',
12
+ fdSrc,
13
+ fdTar,
14
+ nameDistType: 'kebabCase',
15
+ globals: {
16
+ '@hapi/hapi': '@hapi/hapi',
17
+ '@hapi/inert': '@hapi/inert',
18
+ 'path': 'path',
19
+ 'fs': 'fs',
20
+ 'events': 'events',
21
+ 'stream': 'stream',
22
+ // 'form-data': 'FormData',
23
+ 'crypto': 'crypto', //因crypto-js修改使用內建crypto方式, 會偵測nodejs並使用require內建的crypto, 故需剔除
24
+ },
25
+ external: [
26
+ '@hapi/hapi',
27
+ '@hapi/inert',
28
+ 'path',
29
+ 'fs',
30
+ 'events',
31
+ 'stream',
32
+ // 'form-data',
33
+ 'crypto',
34
+ ],
35
+ })
36
+
@@ -0,0 +1,23 @@
1
+ import path from 'path'
2
+ import fs from 'fs'
3
+ // import _ from 'lodash-es'
4
+ import w from 'wsemi'
5
+
6
+
7
+ let fdTar = './dist'
8
+ let fnEntryIn = 'index.html'
9
+ let fnEntryOut = 'index.tmp'
10
+ let fpEntryIn = path.resolve(fdTar, fnEntryIn)
11
+ let fpEntryOut = path.resolve(fdTar, fnEntryOut)
12
+
13
+ //readFileSync
14
+ let c = fs.readFileSync(fpEntryIn, 'utf8')
15
+
16
+ //replace
17
+ c = w.replace(c, '/msso/', '{sfd}/')
18
+
19
+ //writeFileSync
20
+ fs.writeFileSync(fpEntryOut, c, 'utf8')
21
+
22
+ //unlinkSync
23
+ fs.unlinkSync(fpEntryIn)
@@ -0,0 +1,4 @@
1
+ import modifyReadme from 'w-package-tools/src/modifyReadme.mjs'
2
+
3
+
4
+ modifyReadme()
package/vue.config.js ADDED
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ lintOnSave: false, //禁止eslint-loader於編譯時檢查語法
3
+ devServer: {
4
+ proxy: {
5
+ '/api': {
6
+ target: 'http://localhost:11007',
7
+ pathRewrite: {
8
+ '^/api': '/api'
9
+ },
10
+ },
11
+ }
12
+ },
13
+ // transpileDependencies: [''],
14
+ publicPath: process.env.NODE_ENV === 'production' ? '/msso/' : '/', //預先編譯至msso子目錄下, 待轉成模板, 並於伺服器啟動後依照設定檔取代
15
+ }