@things-factory/auth-ui 10.1.16 → 10.1.17
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.
- package/dist-client/components/secret-field.d.ts +35 -0
- package/dist-client/components/secret-field.js +149 -0
- package/dist-client/components/secret-field.js.map +1 -0
- package/dist-client/pages/app-binding/app-binding-list-query.test.d.ts +1 -0
- package/dist-client/pages/app-binding/app-binding-list-query.test.js +46 -0
- package/dist-client/pages/app-binding/app-binding-list-query.test.js.map +1 -0
- package/dist-client/pages/app-binding/app-binding.d.ts +1 -0
- package/dist-client/pages/app-binding/app-binding.js +8 -8
- package/dist-client/pages/app-binding/app-binding.js.map +1 -1
- package/dist-client/pages/app-binding/app-bindings.d.ts +63 -2
- package/dist-client/pages/app-binding/app-bindings.js +199 -117
- package/dist-client/pages/app-binding/app-bindings.js.map +1 -1
- package/dist-client/pages/appliance/appliance-list-query.test.d.ts +1 -0
- package/dist-client/pages/appliance/appliance-list-query.test.js +58 -0
- package/dist-client/pages/appliance/appliance-list-query.test.js.map +1 -0
- package/dist-client/pages/appliance/appliance.d.ts +1 -0
- package/dist-client/pages/appliance/appliance.js +2 -4
- package/dist-client/pages/appliance/appliance.js.map +1 -1
- package/dist-client/pages/appliance/home.d.ts +61 -2
- package/dist-client/pages/appliance/home.js +200 -122
- package/dist-client/pages/appliance/home.js.map +1 -1
- package/dist-client/pages/application/application.d.ts +1 -0
- package/dist-client/pages/application/application.js +10 -3
- package/dist-client/pages/application/application.js.map +1 -1
- package/dist-client/pages/application/applications.d.ts +61 -2
- package/dist-client/pages/application/applications.js +193 -128
- package/dist-client/pages/application/applications.js.map +1 -1
- package/dist-client/pages/application/register.js +81 -27
- package/dist-client/pages/application/register.js.map +1 -1
- package/dist-client/pages/auth-provider/auth-provider-management.d.ts +4 -2
- package/dist-client/pages/auth-provider/auth-provider-management.js +35 -6
- package/dist-client/pages/auth-provider/auth-provider-management.js.map +1 -1
- package/dist-client/pages/domain-owner/domain-owner-management.d.ts +2 -0
- package/dist-client/pages/domain-owner/domain-owner-management.js +34 -7
- package/dist-client/pages/domain-owner/domain-owner-management.js.map +1 -1
- package/dist-client/pages/secrets-are-not-printed.test.d.ts +1 -0
- package/dist-client/pages/secrets-are-not-printed.test.js +70 -0
- package/dist-client/pages/secrets-are-not-printed.test.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/application-status.d.ts +32 -0
- package/dist-client/utils/application-status.js +45 -0
- package/dist-client/utils/application-status.js.map +1 -0
- package/dist-client/utils/application-status.test.d.ts +1 -0
- package/dist-client/utils/application-status.test.js +45 -0
- package/dist-client/utils/application-status.test.js.map +1 -0
- package/dist-client/utils/form-values.d.ts +42 -0
- package/dist-client/utils/form-values.js +57 -0
- package/dist-client/utils/form-values.js.map +1 -0
- package/dist-client/utils/form-values.test.d.ts +1 -0
- package/dist-client/utils/form-values.test.js +62 -0
- package/dist-client/utils/form-values.test.js.map +1 -0
- package/dist-client/utils/list-result.d.ts +62 -0
- package/dist-client/utils/list-result.js +92 -0
- package/dist-client/utils/list-result.js.map +1 -0
- package/dist-client/utils/list-result.test.d.ts +1 -0
- package/dist-client/utils/list-result.test.js +160 -0
- package/dist-client/utils/list-result.test.js.map +1 -0
- package/dist-client/utils/secret-display.d.ts +51 -0
- package/dist-client/utils/secret-display.js +61 -0
- package/dist-client/utils/secret-display.js.map +1 -0
- package/dist-client/utils/secret-display.test.d.ts +1 -0
- package/dist-client/utils/secret-display.test.js +59 -0
- package/dist-client/utils/secret-display.test.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/translations/en.json +31 -0
- package/translations/ja.json +31 -0
- package/translations/ko.json +31 -0
- package/translations/ms.json +31 -0
- package/translations/zh.json +31 -0
|
@@ -14,10 +14,13 @@ import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato
|
|
|
14
14
|
import { isMobileDevice } from '@operato/utils';
|
|
15
15
|
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
16
16
|
import { p13n } from '@operato/p13n';
|
|
17
|
+
import { listOutcome, pageFromResponse } from '../../utils/list-result.js';
|
|
17
18
|
let AuthProviderManagementPage = class AuthProviderManagementPage extends p13n(localize(i18next)(PageView)) {
|
|
18
19
|
constructor() {
|
|
19
20
|
super(...arguments);
|
|
20
21
|
this.mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
22
|
+
/** The last fetch did not answer. Distinct from answering with nothing. */
|
|
23
|
+
this.failed = false;
|
|
21
24
|
this.authProviderTypes = [];
|
|
22
25
|
}
|
|
23
26
|
static { this.styles = [
|
|
@@ -36,6 +39,11 @@ let AuthProviderManagementPage = class AuthProviderManagementPage extends p13n(l
|
|
|
36
39
|
ox-grist { overflow-y: auto;
|
|
37
40
|
flex: 1;
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
[failed] { padding: var(--spacing-medium);
|
|
44
|
+
color: var(--md-sys-color-error);
|
|
45
|
+
font: var(--label-font, inherit);
|
|
46
|
+
}
|
|
39
47
|
`
|
|
40
48
|
]; }
|
|
41
49
|
get context() {
|
|
@@ -83,6 +91,8 @@ let AuthProviderManagementPage = class AuthProviderManagementPage extends p13n(l
|
|
|
83
91
|
|
|
84
92
|
<ox-grist-personalizer slot="setting"></ox-grist-personalizer>
|
|
85
93
|
</ox-grist>
|
|
94
|
+
|
|
95
|
+
${this.failed ? html `<div failed>${i18next.t('text.the list could not be loaded')}</div>` : ''}
|
|
86
96
|
`;
|
|
87
97
|
}
|
|
88
98
|
async pageInitialized(lifecycle) {
|
|
@@ -134,14 +144,14 @@ let AuthProviderManagementPage = class AuthProviderManagementPage extends p13n(l
|
|
|
134
144
|
},
|
|
135
145
|
width: 200
|
|
136
146
|
},
|
|
137
|
-
{ type: '
|
|
147
|
+
{ type: 'secret',
|
|
138
148
|
name: 'clientSecret',
|
|
139
149
|
header: i18next.t('field.client-secret'),
|
|
140
150
|
record: { editable: true
|
|
141
151
|
},
|
|
142
152
|
width: 200
|
|
143
153
|
},
|
|
144
|
-
{ type: '
|
|
154
|
+
{ type: 'secret',
|
|
145
155
|
name: 'privateKey',
|
|
146
156
|
header: i18next.t('field.private-key'),
|
|
147
157
|
record: { editable: true
|
|
@@ -211,10 +221,25 @@ let AuthProviderManagementPage = class AuthProviderManagementPage extends p13n(l
|
|
|
211
221
|
sortings
|
|
212
222
|
}
|
|
213
223
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
224
|
+
/*
|
|
225
|
+
This read `response.data.authProviderTypes.items` with no check at all. On a refused
|
|
226
|
+
query `data` is null, so the line threw inside the grist's fetch handler — an empty
|
|
227
|
+
grid and nothing said.
|
|
228
|
+
|
|
229
|
+
`clientSecret` and `privateKey` each carry their own
|
|
230
|
+
`@privilege(category: "security", privilege: "query", domainOwnerGranted: true)`, so a
|
|
231
|
+
viewer without that privilege gets the whole list **plus** one error per withheld
|
|
232
|
+
value. Those errors point inside the page, and `pageFromResponse` reads the path and
|
|
233
|
+
keeps the list — blacking it out would take the screen away from everyone who may see
|
|
234
|
+
the providers but not their secrets.
|
|
235
|
+
*/
|
|
236
|
+
const types = pageFromResponse(response, 'authProviderTypes');
|
|
237
|
+
if (types) {
|
|
238
|
+
this.authProviderTypes = types.items;
|
|
239
|
+
}
|
|
240
|
+
const { items, total, failed } = listOutcome(pageFromResponse(response, 'responses'));
|
|
241
|
+
this.failed = failed;
|
|
242
|
+
return { total, records: items };
|
|
218
243
|
}
|
|
219
244
|
async deleteAuthProvider() {
|
|
220
245
|
if (await OxPrompt.open({ title: i18next.t('text.are_you_sure'),
|
|
@@ -298,6 +323,10 @@ __decorate([
|
|
|
298
323
|
state(),
|
|
299
324
|
__metadata("design:type", String)
|
|
300
325
|
], AuthProviderManagementPage.prototype, "mode", void 0);
|
|
326
|
+
__decorate([
|
|
327
|
+
state(),
|
|
328
|
+
__metadata("design:type", Boolean)
|
|
329
|
+
], AuthProviderManagementPage.prototype, "failed", void 0);
|
|
301
330
|
__decorate([
|
|
302
331
|
state(),
|
|
303
332
|
__metadata("design:type", Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider-management.js","sourceRoot":"","sources":["../../../client/pages/auth-provider/auth-provider-management.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAwC,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAa,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,EAAE,cAAc,EAAS,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAG7B,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IAA1E;;QAoBI,SAAI,GAA6B,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;QACnE,sBAAiB,GAAmF,EAAE,CAAA;IAmQjH,CAAC;aAxR4F,WAAM,GAAG;QAClG,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/ox-context-page-toolbar.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { getEditor, getRenderer, ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice, sleep } from '@operato/utils'\nimport { OxPopup } from '@operato/popup'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { p13n } from '@operato/p13n'\n\n@customElement('auth-provider-management')\nexport class AuthProviderManagementPage extends p13n(localize(i18next)(PageView)) { static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host { display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist { overflow-y: auto;\n flex: 1;\n }\n `\n ]\n\n @state() gristConfig: any\n @state() mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n @state() authProviderTypes: { type: string; description?: string; help?: string; parameterSpec?: any[] }[] = []\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() { return { title: i18next.t('title.auth-provider'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n // help: 'auth/auth-provider',\n actions: [\n { title: i18next.t('button.save'),\n action: this.updateAuthProvider.bind(this),\n icon: 'save'\n },\n { title: i18next.t('button.delete'),\n action: this.deleteAuthProvider.bind(this),\n icon: 'delete',\n emphasis: { danger: true\n }\n }\n ],\n toolbar: false\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n .personalConfigProvider=${this.getPagePreferenceProvider('ox-grist')!}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"title\">${i18next.t('title.auth-provider')}</div>\n\n <ox-filters-form autofocus without-search class=\"filters\"></ox-filters-form>\n\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}> </ox-context-page-toolbar>\n </div>\n\n <ox-grist-personalizer slot=\"setting\"></ox-grist-personalizer>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle) { this.gristConfig = { list: { fields: ['entity', 'description']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'gutter',\n gutterName: 'button',\n title: i18next.t('title.auth-provider'),\n icon: 'sync',\n handlers: { click: (columns, data, column, record, rowIndex) => { if (!record.id) return\n this.synchronizeUsers(record.id)\n }\n }\n },\n { type: 'select',\n name: 'type',\n header: i18next.t('field.type'),\n record: { editable: true,\n options: () => ['', ...this.authProviderTypes.map(({ type }) => type)]\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'boolean',\n name: 'active',\n header: i18next.t('field.active'),\n record: { editable: true\n },\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'tenantId',\n header: i18next.t('field.tenant-id'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'string',\n name: 'clientId',\n header: i18next.t('field.client-id'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'string',\n name: 'clientSecret',\n header: i18next.t('field.client-secret'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'string',\n name: 'privateKey',\n header: i18next.t('field.private-key'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'parameters',\n name: 'params',\n header: i18next.t('field.params'),\n record: { editable: true,\n options: async (value, column, record, row, field) => { const { description,\n help,\n parameterSpec: spec\n } = record.type ? this.authProviderTypes[record.type] : ({} as any)\n const context = this.grist\n\n return { description, help, spec, context }\n },\n renderer: 'json5'\n },\n width: 200\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'type'\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { authProviderTypes { items { type\n description\n help\n parameterSpec { type\n label\n name\n placeholder\n property\n styles\n }\n }\n total\n }\n\n responses: authProviders(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n type\n active\n tenantId\n clientId\n clientSecret\n privateKey\n params\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n this.authProviderTypes = response.data.authProviderTypes.items\n\n return { total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n private async deleteAuthProvider() { if (\n await OxPrompt.open({ title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deleteAuthProviders(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n private async updateAuthProvider() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n if (patchField['reportTemplate'] instanceof FileList) { patchField['reportTemplate'] = patchField['reportTemplate'][0]\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [AuthProviderPatch!]!) { updateMultipleAuthProvider(patches: $patches) { id\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n private async synchronizeUsers(id: string) { if (\n await OxPrompt.open({ title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.synchronize') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) { if (id && id.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { synchronizeAuthProviderUsers(id: $id)\n }\n `,\n variables: { id\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.synchronize') })\n })\n }\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-provider-management.js","sourceRoot":"","sources":["../../../client/pages/auth-provider/auth-provider-management.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,qBAAqB,CAAA;AAC5B,OAAO,6CAA6C,CAAA;AAEpD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAwC,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAa,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,M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CAAC,eAAe,CAAC,EAAE;SACxD,CAAC,EACG,CAAC;YAAO,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAAS,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,EAAY,QAAQ,EAAE,GAAG,CAAA;;;WAGpG;oBACD,SAAS,EAAE,EAAc,EAAE;qBACnC;iBACA,CAAC,CAAA;gBAEK,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBAAW,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;oBAClD,MAAM,CAAC,EAAc,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,0BAA0B,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC;qBACjH,CAAC,CAAA;gBACF,CAAC;YACD,CAAC;QACD,CAAC;IACD,CAAC;;AA3RS;IAAR,KAAK,EAAE;;+DAAiB;AAChB;IAAR,KAAK,EAAE;;wDAAoE;AAEnE;IAAR,KAAK,EAAE;;0DAAwB;AAEvB;IAAR,KAAK,EAAE;;qEAAuG;AAEpF;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;yDAAA;AA/BjC,0BAA0B;IADtC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,0BAA0B,CAoTtC","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport '@operato/data-grist'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { getEditor, getRenderer, ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { PageView } from '@operato/shell'\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice, sleep } from '@operato/utils'\nimport { OxPopup } from '@operato/popup'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { p13n } from '@operato/p13n'\n\nimport { listOutcome, pageFromResponse } from '../../utils/list-result.js'\n\n@customElement('auth-provider-management')\nexport class AuthProviderManagementPage extends p13n(localize(i18next)(PageView)) { static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host { display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist { overflow-y: auto;\n flex: 1;\n }\n\n [failed] { padding: var(--spacing-medium);\n color: var(--md-sys-color-error);\n font: var(--label-font, inherit);\n }\n `\n ]\n\n @state() gristConfig: any\n @state() mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n /** The last fetch did not answer. Distinct from answering with nothing. */\n @state() failed: boolean = false\n\n @state() authProviderTypes: { type: string; description?: string; help?: string; parameterSpec?: any[] }[] = []\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() { return { title: i18next.t('title.auth-provider'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n // help: 'auth/auth-provider',\n actions: [\n { title: i18next.t('button.save'),\n action: this.updateAuthProvider.bind(this),\n icon: 'save'\n },\n { title: i18next.t('button.delete'),\n action: this.deleteAuthProvider.bind(this),\n icon: 'delete',\n emphasis: { danger: true\n }\n }\n ],\n toolbar: false\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n .personalConfigProvider=${this.getPagePreferenceProvider('ox-grist')!}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\" class=\"header\">\n <div class=\"title\">${i18next.t('title.auth-provider')}</div>\n\n <ox-filters-form autofocus without-search class=\"filters\"></ox-filters-form>\n\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}> </ox-context-page-toolbar>\n </div>\n\n <ox-grist-personalizer slot=\"setting\"></ox-grist-personalizer>\n </ox-grist>\n\n ${this.failed ? html`<div failed>${i18next.t('text.the list could not be loaded')}</div>` : ''}\n `\n }\n\n async pageInitialized(lifecycle) { this.gristConfig = { list: { fields: ['entity', 'description']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'gutter',\n gutterName: 'button',\n title: i18next.t('title.auth-provider'),\n icon: 'sync',\n handlers: { click: (columns, data, column, record, rowIndex) => { if (!record.id) return\n this.synchronizeUsers(record.id)\n }\n }\n },\n { type: 'select',\n name: 'type',\n header: i18next.t('field.type'),\n record: { editable: true,\n options: () => ['', ...this.authProviderTypes.map(({ type }) => type)]\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'boolean',\n name: 'active',\n header: i18next.t('field.active'),\n record: { editable: true\n },\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'tenantId',\n header: i18next.t('field.tenant-id'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'string',\n name: 'clientId',\n header: i18next.t('field.client-id'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'secret',\n name: 'clientSecret',\n header: i18next.t('field.client-secret'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'secret',\n name: 'privateKey',\n header: i18next.t('field.private-key'),\n record: { editable: true\n },\n width: 200\n },\n { type: 'parameters',\n name: 'params',\n header: i18next.t('field.params'),\n record: { editable: true,\n options: async (value, column, record, row, field) => { const { description,\n help,\n parameterSpec: spec\n } = record.type ? this.authProviderTypes[record.type] : ({} as any)\n const context = this.grist\n\n return { description, help, spec, context }\n },\n renderer: 'json5'\n },\n width: 200\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'type'\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { authProviderTypes { items { type\n description\n help\n parameterSpec { type\n label\n name\n placeholder\n property\n styles\n }\n }\n total\n }\n\n responses: authProviders(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n type\n active\n tenantId\n clientId\n clientSecret\n privateKey\n params\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n /*\n This read `response.data.authProviderTypes.items` with no check at all. On a refused\n query `data` is null, so the line threw inside the grist's fetch handler — an empty\n grid and nothing said.\n\n `clientSecret` and `privateKey` each carry their own\n `@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)`, so a\n viewer without that privilege gets the whole list **plus** one error per withheld\n value. Those errors point inside the page, and `pageFromResponse` reads the path and\n keeps the list — blacking it out would take the screen away from everyone who may see\n the providers but not their secrets.\n */\n const types = pageFromResponse(response, 'authProviderTypes')\n\n if (types) {\n this.authProviderTypes = types.items\n }\n\n const { items, total, failed } = listOutcome(pageFromResponse(response, 'responses'))\n\n this.failed = failed\n\n return { total, records: items }\n }\n\n private async deleteAuthProvider() { if (\n await OxPrompt.open({ title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deleteAuthProviders(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n private async updateAuthProvider() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n if (patchField['reportTemplate'] instanceof FileList) { patchField['reportTemplate'] = patchField['reportTemplate'][0]\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [AuthProviderPatch!]!) { updateMultipleAuthProvider(patches: $patches) { id\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n private async synchronizeUsers(id: string) { if (\n await OxPrompt.open({ title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.synchronize') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) { if (id && id.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($id: String!) { synchronizeAuthProviderUsers(id: $id)\n }\n `,\n variables: { id\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.synchronize') })\n })\n }\n }\n }\n }\n}\n"]}
|
|
@@ -23,6 +23,8 @@ export declare class DomainOwnerManagement extends DomainOwnerManagement_base {
|
|
|
23
23
|
config: any;
|
|
24
24
|
mode: 'CARD' | 'LIST' | 'GRID';
|
|
25
25
|
private isDomainOwner;
|
|
26
|
+
/** The last fetch did not answer. Distinct from answering with nothing. */
|
|
27
|
+
private failed;
|
|
26
28
|
private grist;
|
|
27
29
|
get context(): {
|
|
28
30
|
title: string;
|
|
@@ -16,6 +16,7 @@ import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
|
16
16
|
import { CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
|
|
17
17
|
import { isMobileDevice } from '@operato/utils';
|
|
18
18
|
import { p13n } from '@operato/p13n';
|
|
19
|
+
import { arrayFromResponse, listOutcome } from '../../utils/list-result.js';
|
|
19
20
|
/**
|
|
20
21
|
* Domain Owners Management Page
|
|
21
22
|
*
|
|
@@ -29,6 +30,8 @@ let DomainOwnerManagement = class DomainOwnerManagement extends p13n(localize(i1
|
|
|
29
30
|
this.active = false;
|
|
30
31
|
this.mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
31
32
|
this.isDomainOwner = false;
|
|
33
|
+
/** The last fetch did not answer. Distinct from answering with nothing. */
|
|
34
|
+
this.failed = false;
|
|
32
35
|
}
|
|
33
36
|
static { this.styles = [
|
|
34
37
|
CommonGristStyles,
|
|
@@ -44,6 +47,12 @@ let DomainOwnerManagement = class DomainOwnerManagement extends p13n(localize(i1
|
|
|
44
47
|
overflow-y: auto;
|
|
45
48
|
flex: 1;
|
|
46
49
|
}
|
|
50
|
+
|
|
51
|
+
[failed] {
|
|
52
|
+
padding: var(--spacing-medium);
|
|
53
|
+
color: var(--md-sys-color-error);
|
|
54
|
+
font: var(--label-font, inherit);
|
|
55
|
+
}
|
|
47
56
|
`
|
|
48
57
|
]; }
|
|
49
58
|
get context() {
|
|
@@ -75,6 +84,8 @@ let DomainOwnerManagement = class DomainOwnerManagement extends p13n(localize(i1
|
|
|
75
84
|
<ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
|
|
76
85
|
</div>
|
|
77
86
|
</ox-grist>
|
|
87
|
+
|
|
88
|
+
${this.failed ? html `<div failed>${i18next.t('text.the list could not be loaded')}</div>` : ''}
|
|
78
89
|
`;
|
|
79
90
|
}
|
|
80
91
|
async pageInitialized() {
|
|
@@ -171,13 +182,25 @@ let DomainOwnerManagement = class DomainOwnerManagement extends p13n(localize(i1
|
|
|
171
182
|
context: gqlContext(),
|
|
172
183
|
fetchPolicy: 'network-only'
|
|
173
184
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
/*
|
|
186
|
+
* This read `response.data?.domainOwners || []`, which turned a refused query into
|
|
187
|
+
* "this domain has no owners". That is not a harmless blank: an administrator who
|
|
188
|
+
* believes it may go and add one, and the screen gave them no reason to doubt it.
|
|
189
|
+
*
|
|
190
|
+
* `arrayFromResponse` answers nothing when the server did not, and `failed` says so on
|
|
191
|
+
* screen beside the empty grid.
|
|
192
|
+
*/
|
|
193
|
+
const { items, total, failed } = listOutcome(arrayFromResponse(response, 'domainOwners'));
|
|
194
|
+
this.failed = failed;
|
|
195
|
+
return {
|
|
196
|
+
total,
|
|
197
|
+
records: items.map((ow) => ({
|
|
198
|
+
...ow,
|
|
199
|
+
userName: ow.user?.name,
|
|
200
|
+
userEmail: ow.user?.email,
|
|
201
|
+
grantedByName: ow.grantedBy?.name || ''
|
|
202
|
+
}))
|
|
203
|
+
};
|
|
181
204
|
}
|
|
182
205
|
_onAddOwner() {
|
|
183
206
|
openPopup(html `
|
|
@@ -248,6 +271,10 @@ __decorate([
|
|
|
248
271
|
state(),
|
|
249
272
|
__metadata("design:type", Boolean)
|
|
250
273
|
], DomainOwnerManagement.prototype, "isDomainOwner", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
state(),
|
|
276
|
+
__metadata("design:type", Boolean)
|
|
277
|
+
], DomainOwnerManagement.prototype, "failed", void 0);
|
|
251
278
|
__decorate([
|
|
252
279
|
query('ox-grist'),
|
|
253
280
|
__metadata("design:type", DataGrist)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-owner-management.js","sourceRoot":"","sources":["../../../client/pages/domain-owner/domain-owner-management.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAEhD,OAAO,iCAAiC,CAAA;AACxC,OAAO,6CAA6C,CAAA;AAEpD,OAAO,4CAA4C,CAAA;AAEnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MA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7B,QAAQ,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IACrG,CAAC;;AA9M4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;qDAAwB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAoE;AAE9E;IAAhB,KAAK,EAAE;;4DAAuC;AAEpB;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;oDAAA;AAxBjC,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CAiOjC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\n\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport '../../components/add-domain-owner-popup.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { DataGrist } from '@operato/data-grist/ox-grist.js'\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\nimport { PageView, store } from '@operato/shell'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { p13n } from '@operato/p13n'\n\n/**\n * Domain Owners Management Page\n *\n * 현재 도메인의 owner 목록을 표시하고, 추가/제거를 관리한다.\n * 멀티 오너 지원 — 모든 owner는 동등한 권한을 가짐 (primary 없음).\n * Domain.owner legacy cache 필드는 대표 owner 표시용으로 유지됨.\n */\n@customElement('domain-owner-management')\nexport class DomainOwnerManagement extends p13n(localize(i18next)(PageView)) {\n static styles = [\n CommonGristStyles,\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n `\n ]\n\n @property({ type: Boolean }) active: boolean = false\n @property({ type: Object }) config: any\n @property({ type: String }) mode: 'CARD' | 'LIST' | 'GRID' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @state() private isDomainOwner: boolean = false\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('text.domain owners'),\n help: 'auth/domain-owners',\n // 서버의 @privilege 가 최종 게이트. 버튼 표시/숨김은 isDomainOwner\n // 클라이언트 플래그에 의존하지 않음 — auth profile 이 해당 플래그를\n // 제대로 세팅 안 했을 때 버튼이 사라져 조작 불가 상태가 되는 것을 방지.\n actions: [\n {\n title: i18next.t('button.add'),\n action: this._onAddOwner.bind(this),\n icon: 'person_add'\n }\n ],\n toolbar: false\n }\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${this.mode}\n .config=${this.config}\n .fetchHandler=${this._fetchHandler.bind(this)}\n .personalConfigProvider=${this.getPagePreferenceProvider('ox-grist')!}\n >\n <div slot=\"headroom\" class=\"header\">\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized() {\n this.config = {\n rows: { appendable: false, selectable: { multiple: false } },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'person_remove',\n title: i18next.t('button.remove owner'),\n handlers: {\n click: (_columns, _data, _column, record, _rowIndex) => {\n // 클라이언트 게이트 없음 — 서버의 @privilege(domainOwnerGranted:true)\n // 가 최종 authoritative. 오너 아니면 서버 에러를 프롬프트로 표시.\n if (record?.user) {\n this._onRemoveOwner(record)\n }\n }\n }\n },\n {\n type: 'string',\n name: 'userName',\n header: i18next.t('field.name'),\n record: { editable: false },\n width: 180\n },\n {\n type: 'string',\n name: 'userEmail',\n header: i18next.t('field.email'),\n record: { editable: false },\n width: 220\n },\n {\n type: 'string',\n name: 'reason',\n header: i18next.t('field.reason'),\n record: { editable: false },\n width: 220\n },\n {\n type: 'string',\n name: 'grantedByName',\n header: i18next.t('field.granted by'),\n record: { editable: false },\n width: 160\n },\n {\n type: 'datetime',\n name: 'grantedAt',\n header: i18next.t('field.granted at'),\n width: 180\n }\n ]\n }\n }\n\n async pageUpdated(_changes: any, _lifecycle: any) {\n if (this.active) {\n this._refreshPermissions()\n await this.updateComplete\n this.grist.fetch()\n }\n }\n\n private _refreshPermissions() {\n const __state__ = store.getState() as any\n const me = __state__.auth?.user || {}\n this.isDomainOwner = !!me.domainOwner || !!me.super\n }\n\n private async _fetchHandler() {\n const response = await client.query({\n query: gql`\n query {\n domainOwners {\n id\n user {\n id\n name\n email\n username\n }\n grantedBy {\n id\n name\n email\n }\n grantedAt\n reason\n }\n }\n `,\n context: gqlContext(),\n fetchPolicy: 'network-only'\n })\n\n const items = (response.data?.domainOwners || []).map((ow: any) => ({\n ...ow,\n userName: ow.user?.name,\n userEmail: ow.user?.email,\n grantedByName: ow.grantedBy?.name || ''\n }))\n\n return { total: items.length, records: items }\n }\n\n private _onAddOwner() {\n openPopup(\n html`\n <add-domain-owner-popup\n @domain-owner-added=${() => {\n this.grist.fetch()\n this._notify(i18next.t('text.domain owner added successfully'))\n }}\n ></add-domain-owner-popup>\n `,\n {\n size: 'small',\n title: i18next.t('title.add domain owner')\n }\n )\n }\n\n private async _onRemoveOwner(record: any) {\n const username = record.user?.username || record.user?.email\n const displayName = record.user?.name || username\n\n const confirmed = await OxPrompt.open({\n type: 'warning',\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.are_you_sure_to_remove_domain_owner', { x: displayName }),\n confirmButton: { text: i18next.t('button.remove owner') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation removeDomainOwner($username: String!) {\n removeDomainOwner(username: $username)\n }\n `,\n variables: { username },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this._notify(i18next.t('text.domain owner removed successfully'))\n this.grist.fetch()\n }\n } catch (err: any) {\n await OxPrompt.open({\n type: 'error',\n title: i18next.t('text.failed'),\n text: err?.message || String(err),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n }\n\n private _notify(message: string) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1500 } } }))\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"domain-owner-management.js","sourceRoot":"","sources":["../../../client/pages/domain-owner/domain-owner-management.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAEhD,OAAO,iCAAiC,CAAA;AACxC,OAAO,6CAA6C,CAAA;AAEpD,OAAO,4CAA4C,CAAA;AAEnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,O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Q,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;qDAAwB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAoE;AAE9E;IAAhB,KAAK,EAAE;;4DAAuC;AAG9B;IAAhB,KAAK,EAAE;;qDAAgC;AAEb;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;oDAAA;AAjCjC,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CAyPjC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\n\nimport '@operato/data-grist/ox-grist.js'\nimport '@operato/context/ox-context-page-toolbar.js'\n\nimport '../../components/add-domain-owner-popup.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { DataGrist } from '@operato/data-grist/ox-grist.js'\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\nimport { PageView, store } from '@operato/shell'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\nimport { CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\nimport { p13n } from '@operato/p13n'\n\nimport { arrayFromResponse, listOutcome } from '../../utils/list-result.js'\n\n/**\n * Domain Owners Management Page\n *\n * 현재 도메인의 owner 목록을 표시하고, 추가/제거를 관리한다.\n * 멀티 오너 지원 — 모든 owner는 동등한 권한을 가짐 (primary 없음).\n * Domain.owner legacy cache 필드는 대표 owner 표시용으로 유지됨.\n */\n@customElement('domain-owner-management')\nexport class DomainOwnerManagement extends p13n(localize(i18next)(PageView)) {\n static styles = [\n CommonGristStyles,\n CommonHeaderStyles,\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n [failed] {\n padding: var(--spacing-medium);\n color: var(--md-sys-color-error);\n font: var(--label-font, inherit);\n }\n `\n ]\n\n @property({ type: Boolean }) active: boolean = false\n @property({ type: Object }) config: any\n @property({ type: String }) mode: 'CARD' | 'LIST' | 'GRID' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @state() private isDomainOwner: boolean = false\n\n /** The last fetch did not answer. Distinct from answering with nothing. */\n @state() private failed: boolean = false\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('text.domain owners'),\n help: 'auth/domain-owners',\n // 서버의 @privilege 가 최종 게이트. 버튼 표시/숨김은 isDomainOwner\n // 클라이언트 플래그에 의존하지 않음 — auth profile 이 해당 플래그를\n // 제대로 세팅 안 했을 때 버튼이 사라져 조작 불가 상태가 되는 것을 방지.\n actions: [\n {\n title: i18next.t('button.add'),\n action: this._onAddOwner.bind(this),\n icon: 'person_add'\n }\n ],\n toolbar: false\n }\n }\n\n render() {\n return html`\n <ox-grist\n .mode=${this.mode}\n .config=${this.config}\n .fetchHandler=${this._fetchHandler.bind(this)}\n .personalConfigProvider=${this.getPagePreferenceProvider('ox-grist')!}\n >\n <div slot=\"headroom\" class=\"header\">\n <ox-context-page-toolbar class=\"actions\" .context=${this.context}></ox-context-page-toolbar>\n </div>\n </ox-grist>\n\n ${this.failed ? html`<div failed>${i18next.t('text.the list could not be loaded')}</div>` : ''}\n `\n }\n\n async pageInitialized() {\n this.config = {\n rows: { appendable: false, selectable: { multiple: false } },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'person_remove',\n title: i18next.t('button.remove owner'),\n handlers: {\n click: (_columns, _data, _column, record, _rowIndex) => {\n // 클라이언트 게이트 없음 — 서버의 @privilege(domainOwnerGranted:true)\n // 가 최종 authoritative. 오너 아니면 서버 에러를 프롬프트로 표시.\n if (record?.user) {\n this._onRemoveOwner(record)\n }\n }\n }\n },\n {\n type: 'string',\n name: 'userName',\n header: i18next.t('field.name'),\n record: { editable: false },\n width: 180\n },\n {\n type: 'string',\n name: 'userEmail',\n header: i18next.t('field.email'),\n record: { editable: false },\n width: 220\n },\n {\n type: 'string',\n name: 'reason',\n header: i18next.t('field.reason'),\n record: { editable: false },\n width: 220\n },\n {\n type: 'string',\n name: 'grantedByName',\n header: i18next.t('field.granted by'),\n record: { editable: false },\n width: 160\n },\n {\n type: 'datetime',\n name: 'grantedAt',\n header: i18next.t('field.granted at'),\n width: 180\n }\n ]\n }\n }\n\n async pageUpdated(_changes: any, _lifecycle: any) {\n if (this.active) {\n this._refreshPermissions()\n await this.updateComplete\n this.grist.fetch()\n }\n }\n\n private _refreshPermissions() {\n const __state__ = store.getState() as any\n const me = __state__.auth?.user || {}\n this.isDomainOwner = !!me.domainOwner || !!me.super\n }\n\n private async _fetchHandler() {\n const response = await client.query({\n query: gql`\n query {\n domainOwners {\n id\n user {\n id\n name\n email\n username\n }\n grantedBy {\n id\n name\n email\n }\n grantedAt\n reason\n }\n }\n `,\n context: gqlContext(),\n fetchPolicy: 'network-only'\n })\n\n /*\n * This read `response.data?.domainOwners || []`, which turned a refused query into\n * \"this domain has no owners\". That is not a harmless blank: an administrator who\n * believes it may go and add one, and the screen gave them no reason to doubt it.\n *\n * `arrayFromResponse` answers nothing when the server did not, and `failed` says so on\n * screen beside the empty grid.\n */\n const { items, total, failed } = listOutcome(arrayFromResponse(response, 'domainOwners'))\n\n this.failed = failed\n\n return {\n total,\n records: items.map((ow: any) => ({\n ...ow,\n userName: ow.user?.name,\n userEmail: ow.user?.email,\n grantedByName: ow.grantedBy?.name || ''\n }))\n }\n }\n\n private _onAddOwner() {\n openPopup(\n html`\n <add-domain-owner-popup\n @domain-owner-added=${() => {\n this.grist.fetch()\n this._notify(i18next.t('text.domain owner added successfully'))\n }}\n ></add-domain-owner-popup>\n `,\n {\n size: 'small',\n title: i18next.t('title.add domain owner')\n }\n )\n }\n\n private async _onRemoveOwner(record: any) {\n const username = record.user?.username || record.user?.email\n const displayName = record.user?.name || username\n\n const confirmed = await OxPrompt.open({\n type: 'warning',\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.are_you_sure_to_remove_domain_owner', { x: displayName }),\n confirmButton: { text: i18next.t('button.remove owner') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n if (!confirmed) return\n\n try {\n const response = await client.mutate({\n mutation: gql`\n mutation removeDomainOwner($username: String!) {\n removeDomainOwner(username: $username)\n }\n `,\n variables: { username },\n context: gqlContext()\n })\n\n if (!response.errors?.length) {\n this._notify(i18next.t('text.domain owner removed successfully'))\n this.grist.fetch()\n }\n } catch (err: any) {\n await OxPrompt.open({\n type: 'error',\n title: i18next.t('text.failed'),\n text: err?.message || String(err),\n confirmButton: { text: i18next.t('button.confirm') }\n })\n }\n }\n\n private _notify(message: string) {\n document.dispatchEvent(new CustomEvent('notify', { detail: { message, option: { timer: 1500 } } }))\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* No auth screen prints a credential into a plain input.
|
|
5
|
+
*
|
|
6
|
+
* Three of them did, from the moment the page loaded: the binding detail showed an access
|
|
7
|
+
* token and a refresh token, the appliance detail showed an access token, the application
|
|
8
|
+
* detail showed its client secret. `secret-field` replaced all four — masked, copyable
|
|
9
|
+
* without revealing, revealed only when the reader asks.
|
|
10
|
+
*
|
|
11
|
+
* This is worth a test rather than a habit because the wrong version is the natural one to
|
|
12
|
+
* write. A readonly input beside a copy button is what a credential looks like in every
|
|
13
|
+
* other admin console anyone has seen, it reviews cleanly, and nothing in the build objects.
|
|
14
|
+
*
|
|
15
|
+
* ⚠ Comments are stripped first — the prose here and in those screens names every field this
|
|
16
|
+
* searches for, explaining why they are absent.
|
|
17
|
+
*/
|
|
18
|
+
const SECRETS = ['appSecret', 'refreshToken', 'clientSecret', 'privateKey', 'accessToken'];
|
|
19
|
+
const PAGES = join(__dirname);
|
|
20
|
+
function tsFilesUnder(dir) {
|
|
21
|
+
return readdirSync(dir).flatMap(entry => {
|
|
22
|
+
const path = join(dir, entry);
|
|
23
|
+
if (statSync(path).isDirectory()) {
|
|
24
|
+
return tsFilesUnder(path);
|
|
25
|
+
}
|
|
26
|
+
return entry.endsWith('.ts') && !entry.endsWith('.test.ts') ? [path] : [];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function sourceOf(path) {
|
|
30
|
+
return readFileSync(path, 'utf-8')
|
|
31
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
32
|
+
.replace(/^[ \t]*\/\/.*$/gm, '')
|
|
33
|
+
.replace(/<!--[\s\S]*?-->/g, '');
|
|
34
|
+
}
|
|
35
|
+
describe('auth screens', () => {
|
|
36
|
+
it('never bind a credential into a plain input', () => {
|
|
37
|
+
const offenders = [];
|
|
38
|
+
for (const path of tsFilesUnder(PAGES)) {
|
|
39
|
+
const source = sourceOf(path);
|
|
40
|
+
for (const secret of SECRETS) {
|
|
41
|
+
/*
|
|
42
|
+
* An `<input>` whose value expression ends at the secret's name. The trailing
|
|
43
|
+
* boundary matters: `accessTokenUrl` is an endpoint, not a credential, and an
|
|
44
|
+
* earlier version of this search flagged it.
|
|
45
|
+
*/
|
|
46
|
+
const bound = new RegExp(`<input[^>]*\\.value=\\$\\{[^}]*\\b${secret}\\b(?!Url)[^}]*\\}`);
|
|
47
|
+
if (bound.test(source)) {
|
|
48
|
+
offenders.push(`${path.split('/pages/')[1]} — ${secret}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
expect(offenders).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
it('still knows what it is looking for', () => {
|
|
55
|
+
/*
|
|
56
|
+
* A search that matches nothing passes whether the screens are clean or the pattern is
|
|
57
|
+
* broken. This proves the pattern finds the shape it is meant to find, so a green run
|
|
58
|
+
* above means the screens are clean rather than the regex is dead.
|
|
59
|
+
*/
|
|
60
|
+
const sample = '<input id="x" type="text" .value=${app.appSecret} readonly />';
|
|
61
|
+
const bound = new RegExp(`<input[^>]*\\.value=\\$\\{[^}]*\\bappSecret\\b(?!Url)[^}]*\\}`);
|
|
62
|
+
expect(bound.test(sample)).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
it('does not mistake an endpoint for a credential', () => {
|
|
65
|
+
const sample = '<input id="x" type="text" .value=${app.accessTokenUrl} readonly />';
|
|
66
|
+
const bound = new RegExp(`<input[^>]*\\.value=\\$\\{[^}]*\\baccessToken\\b(?!Url)[^}]*\\}`);
|
|
67
|
+
expect(bound.test(sample)).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=secrets-are-not-printed.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets-are-not-printed.test.js","sourceRoot":"","sources":["../../client/pages/secrets-are-not-printed.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B;;;;;;;;;;;;;;GAcG;AAEH,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,CAAC,CAAA;AAE1F,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;AAE7B,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAE7B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WA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oCAAoC,EAAE,GAAG,EAAE;QAC5C;;;;WAIG;QACH,MAAM,MAAM,GAAG,+DAA+D,CAAA;QAC9E,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,+DAA+D,CAAC,CAAA;QAEzF,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,MAAM,GAAG,oEAAoE,CAAA;QACnF,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,iEAAiE,CAAC,CAAA;QAE3F,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { readdirSync, readFileSync, statSync } from 'fs'\nimport { join } from 'path'\n\n/**\n * No auth screen prints a credential into a plain input.\n *\n * Three of them did, from the moment the page loaded: the binding detail showed an access\n * token and a refresh token, the appliance detail showed an access token, the application\n * detail showed its client secret. `secret-field` replaced all four — masked, copyable\n * without revealing, revealed only when the reader asks.\n *\n * This is worth a test rather than a habit because the wrong version is the natural one to\n * write. A readonly input beside a copy button is what a credential looks like in every\n * other admin console anyone has seen, it reviews cleanly, and nothing in the build objects.\n *\n * ⚠ Comments are stripped first — the prose here and in those screens names every field this\n * searches for, explaining why they are absent.\n */\n\nconst SECRETS = ['appSecret', 'refreshToken', 'clientSecret', 'privateKey', 'accessToken']\n\nconst PAGES = join(__dirname)\n\nfunction tsFilesUnder(dir: string): string[] {\n return readdirSync(dir).flatMap(entry => {\n const path = join(dir, entry)\n\n if (statSync(path).isDirectory()) {\n return tsFilesUnder(path)\n }\n\n return entry.endsWith('.ts') && !entry.endsWith('.test.ts') ? [path] : []\n })\n}\n\nfunction sourceOf(path: string): string {\n return readFileSync(path, 'utf-8')\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/^[ \\t]*\\/\\/.*$/gm, '')\n .replace(/<!--[\\s\\S]*?-->/g, '')\n}\n\ndescribe('auth screens', () => {\n it('never bind a credential into a plain input', () => {\n const offenders: string[] = []\n\n for (const path of tsFilesUnder(PAGES)) {\n const source = sourceOf(path)\n\n for (const secret of SECRETS) {\n /*\n * An `<input>` whose value expression ends at the secret's name. The trailing\n * boundary matters: `accessTokenUrl` is an endpoint, not a credential, and an\n * earlier version of this search flagged it.\n */\n const bound = new RegExp(`<input[^>]*\\\\.value=\\\\$\\\\{[^}]*\\\\b${secret}\\\\b(?!Url)[^}]*\\\\}`)\n\n if (bound.test(source)) {\n offenders.push(`${path.split('/pages/')[1]} — ${secret}`)\n }\n }\n }\n\n expect(offenders).toEqual([])\n })\n\n it('still knows what it is looking for', () => {\n /*\n * A search that matches nothing passes whether the screens are clean or the pattern is\n * broken. This proves the pattern finds the shape it is meant to find, so a green run\n * above means the screens are clean rather than the regex is dead.\n */\n const sample = '<input id=\"x\" type=\"text\" .value=${app.appSecret} readonly />'\n const bound = new RegExp(`<input[^>]*\\\\.value=\\\\$\\\\{[^}]*\\\\bappSecret\\\\b(?!Url)[^}]*\\\\}`)\n\n expect(bound.test(sample)).toBe(true)\n })\n\n it('does not mistake an endpoint for a credential', () => {\n const sample = '<input id=\"x\" type=\"text\" .value=${app.accessTokenUrl} readonly />'\n const bound = new RegExp(`<input[^>]*\\\\.value=\\\\$\\\\{[^}]*\\\\baccessToken\\\\b(?!Url)[^}]*\\\\}`)\n\n expect(bound.test(sample)).toBe(false)\n })\n})\n"]}
|