@oneuptime/common 11.0.3 → 11.0.4

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 (167) hide show
  1. package/Models/DatabaseModels/GlobalConfig.ts +19 -0
  2. package/Models/DatabaseModels/GlobalOidc.ts +351 -0
  3. package/Models/DatabaseModels/GlobalOidcProject.ts +265 -0
  4. package/Models/DatabaseModels/GlobalSso.ts +312 -0
  5. package/Models/DatabaseModels/GlobalSsoProject.ts +268 -0
  6. package/Models/DatabaseModels/Index.ts +8 -0
  7. package/Models/DatabaseModels/Project.ts +31 -0
  8. package/Models/DatabaseModels/StatusPage.ts +82 -0
  9. package/Server/API/StatusPageAPI.ts +2 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/{1781587937032-MigrationName.ts → 1781750000000-MigrationName.ts} +2 -2
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1782000000000-AddGlobalSsoAndOidc.ts +176 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1782100000000-AddStatusPageImageAltText.ts +25 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1782200000000-AddRequireSsoForLoginToGlobalProviders.ts +25 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1782300000000-MoveRequireSsoForLoginToGlobalConfig.ts +38 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1782310000000-MigrationName.ts +299 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1782400000000-RemoveIsTestedFromGlobalSsoAndOidc.ts +21 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +14 -2
  18. package/Server/Middleware/UserAuthorization.ts +113 -42
  19. package/Server/Services/GlobalConfigService.ts +50 -0
  20. package/Server/Services/GlobalOidcProjectService.ts +85 -0
  21. package/Server/Services/GlobalOidcService.ts +10 -0
  22. package/Server/Services/GlobalSsoProjectService.ts +85 -0
  23. package/Server/Services/GlobalSsoService.ts +10 -0
  24. package/Server/Services/Index.ts +8 -0
  25. package/Server/Services/ProjectService.ts +44 -1
  26. package/Server/Utils/Cookie.ts +39 -5
  27. package/Server/Utils/JsonWebToken.ts +7 -0
  28. package/Server/Utils/ValidateGlobalProviderProjectTeams.ts +119 -0
  29. package/Tests/Server/Middleware/UserAuthorization.test.ts +51 -13
  30. package/Tests/Server/Middleware/UserAuthorizationSSOProvider.test.ts +163 -0
  31. package/Tests/Server/Utils/CookieSSOToken.test.ts +130 -0
  32. package/Types/JsonWebTokenData.ts +3 -0
  33. package/Types/SSO/SsoProviderType.ts +8 -0
  34. package/UI/Components/Accordion/Accordion.tsx +5 -1
  35. package/UI/Components/CardSelect/CardSelect.tsx +6 -1
  36. package/UI/Components/CategoryCheckbox/Index.tsx +2 -1
  37. package/UI/Components/CodeEditor/CodeEditor.tsx +2 -0
  38. package/UI/Components/CollapsibleSection/CollapsibleSection.tsx +8 -1
  39. package/UI/Components/Dropdown/Dropdown.tsx +2 -0
  40. package/UI/Components/EntityDropdown/EntityDropdown.tsx +3 -0
  41. package/UI/Components/FilePicker/FilePicker.tsx +2 -0
  42. package/UI/Components/Forms/Fields/ColorPicker.tsx +2 -0
  43. package/UI/Components/Forms/Fields/FieldLabel.tsx +4 -0
  44. package/UI/Components/Forms/Fields/FormField.tsx +72 -15
  45. package/UI/Components/Forms/Fields/IconPicker.tsx +2 -0
  46. package/UI/Components/Forms/Validation.ts +107 -23
  47. package/UI/Components/Input/Input.tsx +4 -0
  48. package/UI/Components/Link/Link.tsx +23 -0
  49. package/UI/Components/Markdown.tsx/MarkdownConverters.ts +0 -0
  50. package/UI/Components/Markdown.tsx/MarkdownEditor.tsx +3 -0
  51. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +63 -2
  52. package/UI/Components/Radio/Radio.tsx +2 -0
  53. package/UI/Components/RadioButtons/GroupRadioButtons.tsx +6 -1
  54. package/UI/Components/Tabs/Tabs.tsx +63 -0
  55. package/UI/Components/TextArea/TextArea.tsx +2 -0
  56. package/UI/Components/TimePicker/TimePicker.tsx +2 -0
  57. package/UI/Components/Toggle/Toggle.tsx +2 -1
  58. package/UI/Components/Tooltip/Tooltip.tsx +6 -1
  59. package/build/dist/Models/DatabaseModels/GlobalConfig.js +20 -0
  60. package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
  61. package/build/dist/Models/DatabaseModels/GlobalOidc.js +379 -0
  62. package/build/dist/Models/DatabaseModels/GlobalOidc.js.map +1 -0
  63. package/build/dist/Models/DatabaseModels/GlobalOidcProject.js +276 -0
  64. package/build/dist/Models/DatabaseModels/GlobalOidcProject.js.map +1 -0
  65. package/build/dist/Models/DatabaseModels/GlobalSso.js +341 -0
  66. package/build/dist/Models/DatabaseModels/GlobalSso.js.map +1 -0
  67. package/build/dist/Models/DatabaseModels/GlobalSsoProject.js +279 -0
  68. package/build/dist/Models/DatabaseModels/GlobalSsoProject.js.map +1 -0
  69. package/build/dist/Models/DatabaseModels/Index.js +8 -0
  70. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  71. package/build/dist/Models/DatabaseModels/Project.js +32 -0
  72. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  73. package/build/dist/Models/DatabaseModels/StatusPage.js +84 -0
  74. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  75. package/build/dist/Server/API/StatusPageAPI.js +2 -0
  76. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  77. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/{1781587937032-MigrationName.js → 1781750000000-MigrationName.js} +3 -3
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/{1781587937032-MigrationName.js.map → 1781750000000-MigrationName.js.map} +1 -1
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782000000000-AddGlobalSsoAndOidc.js +73 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782000000000-AddGlobalSsoAndOidc.js.map +1 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782100000000-AddStatusPageImageAltText.js +14 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782100000000-AddStatusPageImageAltText.js.map +1 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782200000000-AddRequireSsoForLoginToGlobalProviders.js +14 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782200000000-AddRequireSsoForLoginToGlobalProviders.js.map +1 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782300000000-MoveRequireSsoForLoginToGlobalConfig.js +23 -0
  86. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782300000000-MoveRequireSsoForLoginToGlobalConfig.js.map +1 -0
  87. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782310000000-MigrationName.js +106 -0
  88. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782310000000-MigrationName.js.map +1 -0
  89. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782400000000-RemoveIsTestedFromGlobalSsoAndOidc.js +14 -0
  90. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1782400000000-RemoveIsTestedFromGlobalSsoAndOidc.js.map +1 -0
  91. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +14 -2
  92. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  93. package/build/dist/Server/Middleware/UserAuthorization.js +77 -34
  94. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  95. package/build/dist/Server/Services/GlobalConfigService.js +55 -0
  96. package/build/dist/Server/Services/GlobalConfigService.js.map +1 -1
  97. package/build/dist/Server/Services/GlobalOidcProjectService.js +80 -0
  98. package/build/dist/Server/Services/GlobalOidcProjectService.js.map +1 -0
  99. package/build/dist/Server/Services/GlobalOidcService.js +9 -0
  100. package/build/dist/Server/Services/GlobalOidcService.js.map +1 -0
  101. package/build/dist/Server/Services/GlobalSsoProjectService.js +80 -0
  102. package/build/dist/Server/Services/GlobalSsoProjectService.js.map +1 -0
  103. package/build/dist/Server/Services/GlobalSsoService.js +9 -0
  104. package/build/dist/Server/Services/GlobalSsoService.js.map +1 -0
  105. package/build/dist/Server/Services/Index.js +8 -0
  106. package/build/dist/Server/Services/Index.js.map +1 -1
  107. package/build/dist/Server/Services/ProjectService.js +36 -1
  108. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  109. package/build/dist/Server/Utils/Cookie.js +32 -3
  110. package/build/dist/Server/Utils/Cookie.js.map +1 -1
  111. package/build/dist/Server/Utils/JsonWebToken.js +6 -0
  112. package/build/dist/Server/Utils/JsonWebToken.js.map +1 -1
  113. package/build/dist/Server/Utils/ValidateGlobalProviderProjectTeams.js +66 -0
  114. package/build/dist/Server/Utils/ValidateGlobalProviderProjectTeams.js.map +1 -0
  115. package/build/dist/Types/SSO/SsoProviderType.js +9 -0
  116. package/build/dist/Types/SSO/SsoProviderType.js.map +1 -0
  117. package/build/dist/UI/Components/Accordion/Accordion.js +5 -3
  118. package/build/dist/UI/Components/Accordion/Accordion.js.map +1 -1
  119. package/build/dist/UI/Components/CardSelect/CardSelect.js +1 -1
  120. package/build/dist/UI/Components/CardSelect/CardSelect.js.map +1 -1
  121. package/build/dist/UI/Components/CategoryCheckbox/Index.js +1 -1
  122. package/build/dist/UI/Components/CategoryCheckbox/Index.js.map +1 -1
  123. package/build/dist/UI/Components/CodeEditor/CodeEditor.js +1 -1
  124. package/build/dist/UI/Components/CodeEditor/CodeEditor.js.map +1 -1
  125. package/build/dist/UI/Components/CollapsibleSection/CollapsibleSection.js +4 -2
  126. package/build/dist/UI/Components/CollapsibleSection/CollapsibleSection.js.map +1 -1
  127. package/build/dist/UI/Components/Dropdown/Dropdown.js +1 -1
  128. package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
  129. package/build/dist/UI/Components/EntityDropdown/EntityDropdown.js +2 -2
  130. package/build/dist/UI/Components/EntityDropdown/EntityDropdown.js.map +1 -1
  131. package/build/dist/UI/Components/FilePicker/FilePicker.js +1 -1
  132. package/build/dist/UI/Components/FilePicker/FilePicker.js.map +1 -1
  133. package/build/dist/UI/Components/Forms/Fields/ColorPicker.js +1 -1
  134. package/build/dist/UI/Components/Forms/Fields/ColorPicker.js.map +1 -1
  135. package/build/dist/UI/Components/Forms/Fields/FieldLabel.js +1 -1
  136. package/build/dist/UI/Components/Forms/Fields/FieldLabel.js.map +1 -1
  137. package/build/dist/UI/Components/Forms/Fields/FormField.js +58 -22
  138. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  139. package/build/dist/UI/Components/Forms/Fields/IconPicker.js +1 -1
  140. package/build/dist/UI/Components/Forms/Fields/IconPicker.js.map +1 -1
  141. package/build/dist/UI/Components/Forms/Validation.js +64 -15
  142. package/build/dist/UI/Components/Forms/Validation.js.map +1 -1
  143. package/build/dist/UI/Components/Input/Input.js +1 -1
  144. package/build/dist/UI/Components/Input/Input.js.map +1 -1
  145. package/build/dist/UI/Components/Link/Link.js +22 -1
  146. package/build/dist/UI/Components/Link/Link.js.map +1 -1
  147. package/build/dist/UI/Components/Markdown.tsx/MarkdownConverters.js +0 -0
  148. package/build/dist/UI/Components/Markdown.tsx/MarkdownConverters.js.map +1 -1
  149. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js +2 -2
  150. package/build/dist/UI/Components/Markdown.tsx/MarkdownEditor.js.map +1 -1
  151. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +46 -2
  152. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
  153. package/build/dist/UI/Components/Radio/Radio.js +1 -1
  154. package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
  155. package/build/dist/UI/Components/RadioButtons/GroupRadioButtons.js +1 -1
  156. package/build/dist/UI/Components/RadioButtons/GroupRadioButtons.js.map +1 -1
  157. package/build/dist/UI/Components/Tabs/Tabs.js +50 -1
  158. package/build/dist/UI/Components/Tabs/Tabs.js.map +1 -1
  159. package/build/dist/UI/Components/TextArea/TextArea.js +1 -1
  160. package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
  161. package/build/dist/UI/Components/TimePicker/TimePicker.js +1 -1
  162. package/build/dist/UI/Components/TimePicker/TimePicker.js.map +1 -1
  163. package/build/dist/UI/Components/Toggle/Toggle.js +1 -1
  164. package/build/dist/UI/Components/Toggle/Toggle.js.map +1 -1
  165. package/build/dist/UI/Components/Tooltip/Tooltip.js +6 -1
  166. package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
  167. package/package.json +1 -1
@@ -61,6 +61,25 @@ export default class GlobalConfig extends GlobalConfigModel {
61
61
  })
62
62
  public disableSignup?: boolean = undefined;
63
63
 
64
+ @ColumnAccessControl({
65
+ create: [],
66
+ read: [],
67
+ update: [],
68
+ })
69
+ @TableColumn({
70
+ type: TableColumnType.Boolean,
71
+ title: "Require SSO for Login",
72
+ description:
73
+ "When enabled, all users must sign in with SSO to access any project on this server. Master admins are exempt so they can always recover from a misconfigured SSO. A project's own SSO settings still apply on top of this.",
74
+ defaultValue: false,
75
+ })
76
+ @Column({
77
+ type: ColumnType.Boolean,
78
+ nullable: true,
79
+ default: false,
80
+ })
81
+ public requireSsoForLogin?: boolean = undefined;
82
+
64
83
  @ColumnAccessControl({
65
84
  create: [],
66
85
  read: [],
@@ -0,0 +1,351 @@
1
+ import User from "./User";
2
+ import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
3
+ import Route from "../../Types/API/Route";
4
+ import URL from "../../Types/API/URL";
5
+ import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
6
+ import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
7
+ import TableEditionAccessControl from "../../Types/Database/AccessControl/TableEditionAccessControl";
8
+ import ColumnLength from "../../Types/Database/ColumnLength";
9
+ import ColumnType from "../../Types/Database/ColumnType";
10
+ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
11
+ import TableColumn from "../../Types/Database/TableColumn";
12
+ import TableColumnType from "../../Types/Database/TableColumnType";
13
+ import TableMetadata from "../../Types/Database/TableMetadata";
14
+ import IconProp from "../../Types/Icon/IconProp";
15
+ import ObjectID from "../../Types/ObjectID";
16
+ import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
17
+
18
+ /*
19
+ * GlobalOIDC is an instance-level (non-tenant) OpenID Connect identity provider.
20
+ * Sibling of GlobalSSO for the OIDC protocol. Access is restricted to master
21
+ * admins through empty access-control arrays (master-admin/isRoot bypass).
22
+ */
23
+ @TableEditionAccessControl({
24
+ requiresEnterprise: true,
25
+ })
26
+ @TableAccessControl({
27
+ create: [],
28
+ read: [],
29
+ delete: [],
30
+ update: [],
31
+ })
32
+ @CrudApiEndpoint(new Route("/global-oidc"))
33
+ @TableMetadata({
34
+ tableName: "GlobalOIDC",
35
+ singularName: "Global OIDC",
36
+ pluralName: "Global OIDC",
37
+ icon: IconProp.Lock,
38
+ tableDescription:
39
+ "Instance-wide OpenID Connect (OIDC) SSO that can be connected to any project on this OneUptime server",
40
+ })
41
+ @Entity({
42
+ name: "GlobalOIDC",
43
+ })
44
+ export default class GlobalOIDC extends BaseModel {
45
+ @ColumnAccessControl({
46
+ create: [],
47
+ read: [],
48
+ update: [],
49
+ })
50
+ @TableColumn({
51
+ required: true,
52
+ type: TableColumnType.ShortText,
53
+ title: "Name",
54
+ description: "Any friendly name of this OIDC provider",
55
+ example: "Okta OIDC (Company-wide)",
56
+ })
57
+ @Column({
58
+ nullable: false,
59
+ type: ColumnType.ShortText,
60
+ length: ColumnLength.ShortText,
61
+ })
62
+ public name?: string = undefined;
63
+
64
+ @ColumnAccessControl({
65
+ create: [],
66
+ read: [],
67
+ update: [],
68
+ })
69
+ @TableColumn({
70
+ required: true,
71
+ type: TableColumnType.LongText,
72
+ title: "Description",
73
+ description: "Friendly description of this OIDC provider",
74
+ })
75
+ @Column({
76
+ nullable: false,
77
+ type: ColumnType.LongText,
78
+ })
79
+ public description?: string = undefined;
80
+
81
+ @ColumnAccessControl({
82
+ create: [],
83
+ read: [],
84
+ update: [],
85
+ })
86
+ @TableColumn({
87
+ required: true,
88
+ type: TableColumnType.LongURL,
89
+ title: "Discovery URL",
90
+ description:
91
+ "OIDC discovery URL (typically ends in /.well-known/openid-configuration).",
92
+ example: "https://accounts.google.com/.well-known/openid-configuration",
93
+ })
94
+ @Column({
95
+ nullable: false,
96
+ type: ColumnType.LongURL,
97
+ transformer: URL.getDatabaseTransformer(),
98
+ })
99
+ public discoveryURL?: URL = undefined;
100
+
101
+ @ColumnAccessControl({
102
+ create: [],
103
+ read: [],
104
+ update: [],
105
+ })
106
+ @TableColumn({
107
+ required: true,
108
+ type: TableColumnType.VeryLongText,
109
+ title: "Issuer URL",
110
+ description:
111
+ "Expected OIDC issuer URL. Must match the 'iss' claim in the ID token.",
112
+ example: "https://accounts.google.com",
113
+ })
114
+ @Column({
115
+ nullable: false,
116
+ type: ColumnType.VeryLongText,
117
+ })
118
+ public issuerURL?: string = undefined;
119
+
120
+ @ColumnAccessControl({
121
+ create: [],
122
+ read: [],
123
+ update: [],
124
+ })
125
+ @TableColumn({
126
+ required: true,
127
+ type: TableColumnType.ShortText,
128
+ title: "Client ID",
129
+ description: "OIDC client ID issued by the identity provider.",
130
+ example: "1234567890-abcdefgh.apps.googleusercontent.com",
131
+ })
132
+ @Column({
133
+ nullable: false,
134
+ type: ColumnType.ShortText,
135
+ length: ColumnLength.ShortText,
136
+ })
137
+ public clientId?: string = undefined;
138
+
139
+ @ColumnAccessControl({
140
+ create: [],
141
+ read: [],
142
+ update: [],
143
+ })
144
+ @TableColumn({
145
+ required: true,
146
+ type: TableColumnType.LongText,
147
+ title: "Client Secret",
148
+ description:
149
+ "OIDC client secret issued by the identity provider. Stored encrypted at rest.",
150
+ encrypted: true,
151
+ })
152
+ @Column({
153
+ nullable: false,
154
+ type: ColumnType.LongText,
155
+ })
156
+ public clientSecret?: string = undefined;
157
+
158
+ @ColumnAccessControl({
159
+ create: [],
160
+ read: [],
161
+ update: [],
162
+ })
163
+ @TableColumn({
164
+ required: true,
165
+ type: TableColumnType.ShortText,
166
+ title: "Scopes",
167
+ description:
168
+ "Space-separated list of OIDC scopes to request. Must include 'openid'.",
169
+ example: "openid email profile",
170
+ })
171
+ @Column({
172
+ nullable: false,
173
+ type: ColumnType.ShortText,
174
+ length: ColumnLength.ShortText,
175
+ })
176
+ public scopes?: string = undefined;
177
+
178
+ @ColumnAccessControl({
179
+ create: [],
180
+ read: [],
181
+ update: [],
182
+ })
183
+ @TableColumn({
184
+ required: true,
185
+ type: TableColumnType.ShortText,
186
+ title: "Email Claim Name",
187
+ description:
188
+ "Claim name in the ID token (or userinfo response) that contains the user's email address.",
189
+ example: "email",
190
+ })
191
+ @Column({
192
+ nullable: false,
193
+ type: ColumnType.ShortText,
194
+ length: ColumnLength.ShortText,
195
+ })
196
+ public emailClaimName?: string = undefined;
197
+
198
+ @ColumnAccessControl({
199
+ create: [],
200
+ read: [],
201
+ update: [],
202
+ })
203
+ @TableColumn({
204
+ required: true,
205
+ type: TableColumnType.ShortText,
206
+ title: "Name Claim Name",
207
+ description:
208
+ "Claim name in the ID token (or userinfo response) that contains the user's display name.",
209
+ example: "name",
210
+ })
211
+ @Column({
212
+ nullable: false,
213
+ type: ColumnType.ShortText,
214
+ length: ColumnLength.ShortText,
215
+ })
216
+ public nameClaimName?: string = undefined;
217
+
218
+ @ColumnAccessControl({
219
+ create: [],
220
+ read: [],
221
+ update: [],
222
+ })
223
+ @TableColumn({
224
+ isDefaultValueColumn: true,
225
+ type: TableColumnType.Boolean,
226
+ title: "Disable Sign Up with SSO",
227
+ description:
228
+ "When enabled, users must be explicitly invited to a project before they can log in with this OIDC provider. Brand new users are never created automatically.",
229
+ defaultValue: false,
230
+ example: true,
231
+ })
232
+ @Column({
233
+ type: ColumnType.Boolean,
234
+ default: false,
235
+ })
236
+ public disableSignUpWithSso?: boolean = undefined;
237
+
238
+ @ColumnAccessControl({
239
+ create: [],
240
+ read: [],
241
+ update: [],
242
+ })
243
+ @TableColumn({
244
+ isDefaultValueColumn: true,
245
+ type: TableColumnType.Boolean,
246
+ title: "Enabled",
247
+ description: "Is this OIDC provider enabled?",
248
+ defaultValue: false,
249
+ example: true,
250
+ })
251
+ @Column({
252
+ type: ColumnType.Boolean,
253
+ default: false,
254
+ })
255
+ public isEnabled?: boolean = undefined;
256
+
257
+ @ColumnAccessControl({
258
+ create: [],
259
+ read: [],
260
+ update: [],
261
+ })
262
+ @TableColumn({
263
+ manyToOneRelationColumn: "createdByUserId",
264
+ type: TableColumnType.Entity,
265
+ modelType: User,
266
+ title: "Created by User",
267
+ description:
268
+ "Relation to User who created this object (if this object was created by a User)",
269
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
270
+ })
271
+ @ManyToOne(
272
+ () => {
273
+ return User;
274
+ },
275
+ {
276
+ eager: false,
277
+ nullable: true,
278
+ onDelete: "SET NULL",
279
+ orphanedRowAction: "nullify",
280
+ },
281
+ )
282
+ @JoinColumn({ name: "createdByUserId" })
283
+ public createdByUser?: User = undefined;
284
+
285
+ @ColumnAccessControl({
286
+ create: [],
287
+ read: [],
288
+ update: [],
289
+ })
290
+ @TableColumn({
291
+ type: TableColumnType.ObjectID,
292
+ title: "Created by User ID",
293
+ description:
294
+ "User ID who created this object (if this object was created by a User)",
295
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
296
+ })
297
+ @Column({
298
+ type: ColumnType.ObjectID,
299
+ nullable: true,
300
+ transformer: ObjectID.getDatabaseTransformer(),
301
+ })
302
+ public createdByUserId?: ObjectID = undefined;
303
+
304
+ @ColumnAccessControl({
305
+ create: [],
306
+ read: [],
307
+ update: [],
308
+ })
309
+ @TableColumn({
310
+ manyToOneRelationColumn: "deletedByUserId",
311
+ type: TableColumnType.Entity,
312
+ title: "Deleted by User",
313
+ modelType: User,
314
+ description:
315
+ "Relation to User who deleted this object (if this object was deleted by a User)",
316
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
317
+ })
318
+ @ManyToOne(
319
+ () => {
320
+ return User;
321
+ },
322
+ {
323
+ cascade: false,
324
+ eager: false,
325
+ nullable: true,
326
+ onDelete: "SET NULL",
327
+ orphanedRowAction: "nullify",
328
+ },
329
+ )
330
+ @JoinColumn({ name: "deletedByUserId" })
331
+ public deletedByUser?: User = undefined;
332
+
333
+ @ColumnAccessControl({
334
+ create: [],
335
+ read: [],
336
+ update: [],
337
+ })
338
+ @TableColumn({
339
+ type: TableColumnType.ObjectID,
340
+ title: "Deleted by User ID",
341
+ description:
342
+ "User ID who deleted this object (if this object was deleted by a User)",
343
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
344
+ })
345
+ @Column({
346
+ type: ColumnType.ObjectID,
347
+ nullable: true,
348
+ transformer: ObjectID.getDatabaseTransformer(),
349
+ })
350
+ public deletedByUserId?: ObjectID = undefined;
351
+ }
@@ -0,0 +1,265 @@
1
+ import GlobalOIDC from "./GlobalOidc";
2
+ import Project from "./Project";
3
+ import Team from "./Team";
4
+ import User from "./User";
5
+ import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
6
+ import Route from "../../Types/API/Route";
7
+ import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
8
+ import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
9
+ import TableEditionAccessControl from "../../Types/Database/AccessControl/TableEditionAccessControl";
10
+ import ColumnType from "../../Types/Database/ColumnType";
11
+ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
12
+ import TableColumn from "../../Types/Database/TableColumn";
13
+ import TableColumnType from "../../Types/Database/TableColumnType";
14
+ import TableMetadata from "../../Types/Database/TableMetadata";
15
+ import IconProp from "../../Types/Icon/IconProp";
16
+ import ObjectID from "../../Types/ObjectID";
17
+ import {
18
+ Column,
19
+ Entity,
20
+ Index,
21
+ JoinColumn,
22
+ JoinTable,
23
+ ManyToMany,
24
+ ManyToOne,
25
+ } from "typeorm";
26
+
27
+ /*
28
+ * GlobalOIDCProject attaches a GlobalOIDC provider to a specific project and
29
+ * defines the default teams a federated user is provisioned into on first
30
+ * login. Sibling of GlobalSSOProject for the OIDC protocol.
31
+ */
32
+ @TableEditionAccessControl({
33
+ requiresEnterprise: true,
34
+ })
35
+ @TableAccessControl({
36
+ create: [],
37
+ read: [],
38
+ delete: [],
39
+ update: [],
40
+ })
41
+ @CrudApiEndpoint(new Route("/global-oidc-project"))
42
+ @TableMetadata({
43
+ tableName: "GlobalOIDCProject",
44
+ singularName: "Global OIDC Project",
45
+ pluralName: "Global OIDC Projects",
46
+ icon: IconProp.Lock,
47
+ tableDescription:
48
+ "Attaches an instance-wide OIDC SSO provider to a project with default teams",
49
+ })
50
+ @Entity({
51
+ name: "GlobalOIDCProject",
52
+ })
53
+ export default class GlobalOIDCProject extends BaseModel {
54
+ @ColumnAccessControl({
55
+ create: [],
56
+ read: [],
57
+ update: [],
58
+ })
59
+ @TableColumn({
60
+ manyToOneRelationColumn: "globalOidcId",
61
+ type: TableColumnType.Entity,
62
+ modelType: GlobalOIDC,
63
+ title: "Global OIDC",
64
+ description:
65
+ "Relation to the Global OIDC provider this attachment belongs to",
66
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
67
+ })
68
+ @ManyToOne(
69
+ () => {
70
+ return GlobalOIDC;
71
+ },
72
+ {
73
+ eager: false,
74
+ nullable: false,
75
+ onDelete: "CASCADE",
76
+ orphanedRowAction: "nullify",
77
+ },
78
+ )
79
+ @JoinColumn({ name: "globalOidcId" })
80
+ public globalOidc?: GlobalOIDC = undefined;
81
+
82
+ @ColumnAccessControl({
83
+ create: [],
84
+ read: [],
85
+ update: [],
86
+ })
87
+ @Index()
88
+ @TableColumn({
89
+ type: TableColumnType.ObjectID,
90
+ required: true,
91
+ canReadOnRelationQuery: true,
92
+ title: "Global OIDC ID",
93
+ description: "ID of the Global OIDC provider this attachment belongs to",
94
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
95
+ })
96
+ @Column({
97
+ type: ColumnType.ObjectID,
98
+ nullable: false,
99
+ transformer: ObjectID.getDatabaseTransformer(),
100
+ })
101
+ public globalOidcId?: ObjectID = undefined;
102
+
103
+ @ColumnAccessControl({
104
+ create: [],
105
+ read: [],
106
+ update: [],
107
+ })
108
+ @TableColumn({
109
+ manyToOneRelationColumn: "projectId",
110
+ type: TableColumnType.Entity,
111
+ modelType: Project,
112
+ title: "Project",
113
+ description: "Relation to the Project this OIDC provider is attached to",
114
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
115
+ })
116
+ @ManyToOne(
117
+ () => {
118
+ return Project;
119
+ },
120
+ {
121
+ eager: false,
122
+ nullable: false,
123
+ onDelete: "CASCADE",
124
+ orphanedRowAction: "nullify",
125
+ },
126
+ )
127
+ @JoinColumn({ name: "projectId" })
128
+ public project?: Project = undefined;
129
+
130
+ @ColumnAccessControl({
131
+ create: [],
132
+ read: [],
133
+ update: [],
134
+ })
135
+ @Index()
136
+ @TableColumn({
137
+ type: TableColumnType.ObjectID,
138
+ required: true,
139
+ canReadOnRelationQuery: true,
140
+ title: "Project ID",
141
+ description: "ID of the Project this OIDC provider is attached to",
142
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
143
+ })
144
+ @Column({
145
+ type: ColumnType.ObjectID,
146
+ nullable: false,
147
+ transformer: ObjectID.getDatabaseTransformer(),
148
+ })
149
+ public projectId?: ObjectID = undefined;
150
+
151
+ @ColumnAccessControl({
152
+ create: [],
153
+ read: [],
154
+ update: [],
155
+ })
156
+ @TableColumn({
157
+ required: false,
158
+ type: TableColumnType.EntityArray,
159
+ modelType: Team,
160
+ title: "Default Teams",
161
+ description:
162
+ "Teams in this project that a federated user is added to on first OIDC login",
163
+ example: [{ id: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e" }],
164
+ })
165
+ @ManyToMany(
166
+ () => {
167
+ return Team;
168
+ },
169
+ { eager: false },
170
+ )
171
+ @JoinTable({
172
+ name: "GlobalOIDCProjectTeam",
173
+ inverseJoinColumn: {
174
+ name: "teamId",
175
+ referencedColumnName: "_id",
176
+ },
177
+ joinColumn: {
178
+ name: "globalOidcProjectId",
179
+ referencedColumnName: "_id",
180
+ },
181
+ })
182
+ public teams?: Array<Team> = undefined;
183
+
184
+ @ColumnAccessControl({
185
+ create: [],
186
+ read: [],
187
+ update: [],
188
+ })
189
+ @TableColumn({
190
+ isDefaultValueColumn: true,
191
+ type: TableColumnType.Boolean,
192
+ title: "Enabled",
193
+ description: "Is this project attachment enabled?",
194
+ defaultValue: true,
195
+ example: true,
196
+ })
197
+ @Column({
198
+ type: ColumnType.Boolean,
199
+ default: true,
200
+ })
201
+ public isEnabled?: boolean = undefined;
202
+
203
+ @ColumnAccessControl({
204
+ create: [],
205
+ read: [],
206
+ update: [],
207
+ })
208
+ @TableColumn({
209
+ type: TableColumnType.ObjectID,
210
+ title: "Created by User ID",
211
+ description: "User ID who created this object",
212
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
213
+ })
214
+ @Column({
215
+ type: ColumnType.ObjectID,
216
+ nullable: true,
217
+ transformer: ObjectID.getDatabaseTransformer(),
218
+ })
219
+ public createdByUserId?: ObjectID = undefined;
220
+
221
+ @ColumnAccessControl({
222
+ create: [],
223
+ read: [],
224
+ update: [],
225
+ })
226
+ @TableColumn({
227
+ manyToOneRelationColumn: "createdByUserId",
228
+ type: TableColumnType.Entity,
229
+ modelType: User,
230
+ title: "Created by User",
231
+ description: "Relation to User who created this object",
232
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
233
+ })
234
+ @ManyToOne(
235
+ () => {
236
+ return User;
237
+ },
238
+ {
239
+ eager: false,
240
+ nullable: true,
241
+ onDelete: "SET NULL",
242
+ orphanedRowAction: "nullify",
243
+ },
244
+ )
245
+ @JoinColumn({ name: "createdByUserId" })
246
+ public createdByUser?: User = undefined;
247
+
248
+ @ColumnAccessControl({
249
+ create: [],
250
+ read: [],
251
+ update: [],
252
+ })
253
+ @TableColumn({
254
+ type: TableColumnType.ObjectID,
255
+ title: "Deleted by User ID",
256
+ description: "User ID who deleted this object",
257
+ example: "5f8b9c0d-e1a2-4b3c-8d5e-6f7a8b9c0d1e",
258
+ })
259
+ @Column({
260
+ type: ColumnType.ObjectID,
261
+ nullable: true,
262
+ transformer: ObjectID.getDatabaseTransformer(),
263
+ })
264
+ public deletedByUserId?: ObjectID = undefined;
265
+ }