@solidxai/core 0.1.9-beta.7 → 0.1.9
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/LICENSE +89 -0
- package/README.md +3 -1
- package/dist/constants/chatter-message.constants.d.ts +6 -0
- package/dist/constants/chatter-message.constants.d.ts.map +1 -1
- package/dist/constants/chatter-message.constants.js +7 -1
- package/dist/constants/chatter-message.constants.js.map +1 -1
- package/dist/controllers/authentication.controller.d.ts +12 -0
- package/dist/controllers/authentication.controller.d.ts.map +1 -1
- package/dist/controllers/authentication.controller.js +13 -0
- package/dist/controllers/authentication.controller.js.map +1 -1
- package/dist/controllers/chatter-message.controller.d.ts +1 -0
- package/dist/controllers/chatter-message.controller.d.ts.map +1 -1
- package/dist/controllers/chatter-message.controller.js +12 -0
- package/dist/controllers/chatter-message.controller.js.map +1 -1
- package/dist/controllers/facebook-authentication.controller.d.ts +27 -0
- package/dist/controllers/facebook-authentication.controller.d.ts.map +1 -0
- package/dist/controllers/facebook-authentication.controller.js +117 -0
- package/dist/controllers/facebook-authentication.controller.js.map +1 -0
- package/dist/controllers/menu-item-metadata.controller.d.ts +1 -0
- package/dist/controllers/menu-item-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/menu-item-metadata.controller.js +15 -0
- package/dist/controllers/menu-item-metadata.controller.js.map +1 -1
- package/dist/controllers/microsoft-authentication.controller.d.ts +27 -0
- package/dist/controllers/microsoft-authentication.controller.d.ts.map +1 -0
- package/dist/controllers/microsoft-authentication.controller.js +118 -0
- package/dist/controllers/microsoft-authentication.controller.js.map +1 -0
- package/dist/controllers/setting.controller.d.ts +2 -2
- package/dist/controllers/setting.controller.js +2 -2
- package/dist/decorators/auth.decorator.d.ts.map +1 -1
- package/dist/decorators/computed-field-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/dashboard-question-data-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/dashboard-selection-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/disallow-in-production.decorator.d.ts.map +1 -1
- package/dist/decorators/error-codes-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/extension-user-creation-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/is-not-in-enum.decorator.d.ts.map +1 -1
- package/dist/decorators/mail-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/roles.decorator.d.ts.map +1 -1
- package/dist/decorators/scheduled-job-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/security-rule-config-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/selection-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/sms-provider.decorator.d.ts.map +1 -1
- package/dist/decorators/solid-database-module.decorator.d.ts.map +1 -1
- package/dist/decorators/whatsapp-provider.decorator.d.ts.map +1 -1
- package/dist/dtos/create-chatter-message.dto.d.ts +1 -0
- package/dist/dtos/create-chatter-message.dto.d.ts.map +1 -1
- package/dist/dtos/create-chatter-message.dto.js +7 -1
- package/dist/dtos/create-chatter-message.dto.js.map +1 -1
- package/dist/dtos/post-chatter-message.dto.d.ts +1 -0
- package/dist/dtos/post-chatter-message.dto.d.ts.map +1 -1
- package/dist/dtos/post-chatter-message.dto.js +6 -1
- package/dist/dtos/post-chatter-message.dto.js.map +1 -1
- package/dist/dtos/update-chatter-message.dto.d.ts +1 -0
- package/dist/dtos/update-chatter-message.dto.d.ts.map +1 -1
- package/dist/dtos/update-chatter-message.dto.js +7 -1
- package/dist/dtos/update-chatter-message.dto.js.map +1 -1
- package/dist/entities/chatter-message.entity.d.ts +1 -0
- package/dist/entities/chatter-message.entity.d.ts.map +1 -1
- package/dist/entities/chatter-message.entity.js +5 -1
- package/dist/entities/chatter-message.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts +8 -0
- package/dist/entities/user.entity.d.ts.map +1 -1
- package/dist/entities/user.entity.js +33 -1
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/helpers/cors.helper.js +1 -1
- package/dist/helpers/cors.helper.js.map +1 -1
- package/dist/helpers/facebook-oauth.helper.d.ts +8 -0
- package/dist/helpers/facebook-oauth.helper.d.ts.map +1 -0
- package/dist/helpers/facebook-oauth.helper.js +11 -0
- package/dist/helpers/facebook-oauth.helper.js.map +1 -0
- package/dist/helpers/microsoft-oauth.helper.d.ts +9 -0
- package/dist/helpers/microsoft-oauth.helper.d.ts.map +1 -0
- package/dist/helpers/microsoft-oauth.helper.js +12 -0
- package/dist/helpers/microsoft-oauth.helper.js.map +1 -0
- package/dist/helpers/security.helper.d.ts.map +1 -1
- package/dist/helpers/string.helper.d.ts.map +1 -1
- package/dist/helpers/user-helper.d.ts.map +1 -1
- package/dist/helpers/user-helper.js +4 -0
- package/dist/helpers/user-helper.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +19 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/passport-strategies/facebook-oauth.strategy.d.ts +16 -0
- package/dist/passport-strategies/facebook-oauth.strategy.d.ts.map +1 -0
- package/dist/passport-strategies/facebook-oauth.strategy.js +96 -0
- package/dist/passport-strategies/facebook-oauth.strategy.js.map +1 -0
- package/dist/passport-strategies/microsoft-oauth.strategy.d.ts +14 -0
- package/dist/passport-strategies/microsoft-oauth.strategy.d.ts.map +1 -0
- package/dist/passport-strategies/microsoft-oauth.strategy.js +77 -0
- package/dist/passport-strategies/microsoft-oauth.strategy.js.map +1 -0
- package/dist/seeders/seed-data/solid-core-metadata.json +27 -58
- package/dist/services/api-key.service.d.ts +17 -1
- package/dist/services/api-key.service.d.ts.map +1 -1
- package/dist/services/api-key.service.js +38 -2
- package/dist/services/api-key.service.js.map +1 -1
- package/dist/services/authentication.service.d.ts +61 -27
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +356 -164
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/chatter-message.service.d.ts +1 -0
- package/dist/services/chatter-message.service.d.ts.map +1 -1
- package/dist/services/chatter-message.service.js +24 -7
- package/dist/services/chatter-message.service.js.map +1 -1
- package/dist/services/crud-helper.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +1 -1
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/setting.service.d.ts +5 -2
- package/dist/services/setting.service.d.ts.map +1 -1
- package/dist/services/setting.service.js +51 -6
- package/dist/services/setting.service.js.map +1 -1
- package/dist/services/settings/default-settings-provider.service.d.ts +846 -0
- package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
- package/dist/services/settings/default-settings-provider.service.js +1096 -117
- package/dist/services/settings/default-settings-provider.service.js.map +1 -1
- package/dist/services/user.service.d.ts +12 -8
- package/dist/services/user.service.d.ts.map +1 -1
- package/dist/services/user.service.js +143 -32
- package/dist/services/user.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +11 -3
- package/dist/solid-core.module.js.map +1 -1
- package/dist/transformers/array-transformer.d.ts.map +1 -1
- package/dist/transformers/boolean-transformer.d.ts.map +1 -1
- package/dist/transformers/datetime-transformer.d.ts.map +1 -1
- package/dist/transformers/integer-transformer.d.ts.map +1 -1
- package/dist/validators/is-parsable-int.d.ts.map +1 -1
- package/nest +0 -0
- package/package.json +8 -2
- package/src/constants/chatter-message.constants.ts +7 -0
- package/src/controllers/authentication.controller.ts +8 -1
- package/src/controllers/chatter-message.controller.ts +6 -0
- package/src/controllers/facebook-authentication.controller.ts +113 -0
- package/src/controllers/menu-item-metadata.controller.ts +21 -15
- package/src/controllers/microsoft-authentication.controller.ts +116 -0
- package/src/dtos/create-chatter-message.dto.ts +11 -0
- package/src/dtos/post-chatter-message.dto.ts +4 -0
- package/src/dtos/update-chatter-message.dto.ts +13 -1
- package/src/entities/chatter-message.entity.ts +4 -1
- package/src/entities/user.entity.ts +32 -0
- package/src/helpers/cors.helper.ts +1 -1
- package/src/helpers/facebook-oauth.helper.ts +17 -0
- package/src/helpers/microsoft-oauth.helper.ts +19 -0
- package/src/helpers/user-helper.ts +4 -0
- package/src/index.ts +2 -0
- package/src/interfaces.ts +32 -1
- package/src/passport-strategies/facebook-oauth.strategy.ts +115 -0
- package/src/passport-strategies/microsoft-oauth.strategy.ts +70 -0
- package/src/seeders/seed-data/solid-core-metadata.json +27 -58
- package/src/services/api-key.service.ts +77 -35
- package/src/services/authentication.service.ts +1947 -1432
- package/src/services/chatter-message.service.ts +23 -3
- package/src/services/model-metadata.service.ts +1 -1
- package/src/services/setting.service.ts +64 -8
- package/src/services/settings/default-settings-provider.service.ts +1168 -156
- package/src/services/user.service.ts +220 -61
- package/src/solid-core.module.ts +25 -8
- package/dev-grooming-docs/ozzy-prompts.txt +0 -70
- package/docs/grouping-enhancements.md +0 -89
- package/docs/seed-changes.md +0 -65
- package/docs/test-data-workflow.md +0 -200
- package/docs/type-declaration-import-issue.md +0 -24
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
Inject,
|
|
5
|
+
InternalServerErrorException,
|
|
6
|
+
Query,
|
|
7
|
+
Req,
|
|
8
|
+
Res,
|
|
9
|
+
UseGuards,
|
|
10
|
+
} from "@nestjs/common";
|
|
11
|
+
import { ApiQuery, ApiTags } from "@nestjs/swagger";
|
|
12
|
+
import { Request, Response } from "express";
|
|
13
|
+
import {
|
|
14
|
+
FacebookAuthConfiguration,
|
|
15
|
+
isFacebookOAuthConfigured,
|
|
16
|
+
} from "../helpers/facebook-oauth.helper";
|
|
17
|
+
import { AuthenticationService } from "../services/authentication.service";
|
|
18
|
+
import { SettingService } from "../services/setting.service";
|
|
19
|
+
import { Public } from "src/decorators/public.decorator";
|
|
20
|
+
import { Auth } from "../decorators/auth.decorator";
|
|
21
|
+
import { AuthType } from "../enums/auth-type.enum";
|
|
22
|
+
import { FacebookOauthGuard } from "../passport-strategies/facebook-oauth.strategy";
|
|
23
|
+
import { UserService } from "../services/user.service";
|
|
24
|
+
import type { SolidCoreSetting } from "../services/settings/default-settings-provider.service";
|
|
25
|
+
|
|
26
|
+
@Auth(AuthType.None)
|
|
27
|
+
@ApiTags("Iam")
|
|
28
|
+
@Controller("iam/facebook")
|
|
29
|
+
export class FacebookAuthenticationController {
|
|
30
|
+
constructor(
|
|
31
|
+
private readonly userService: UserService,
|
|
32
|
+
private readonly authService: AuthenticationService,
|
|
33
|
+
private readonly settingService: SettingService,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
private async getConfiguration(): Promise<FacebookAuthConfiguration> {
|
|
37
|
+
return {
|
|
38
|
+
clientID:
|
|
39
|
+
await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
40
|
+
"FACEBOOK_CLIENT_ID",
|
|
41
|
+
),
|
|
42
|
+
clientSecret: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
43
|
+
"FACEBOOK_CLIENT_SECRET",
|
|
44
|
+
),
|
|
45
|
+
callbackURL: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
46
|
+
"FACEBOOK_CALLBACK_URL",
|
|
47
|
+
),
|
|
48
|
+
redirectURL: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
49
|
+
"FACEBOOK_REDIRECT_URL",
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private async validateConfiguration() {
|
|
55
|
+
const config = await this.getConfiguration();
|
|
56
|
+
if (!isFacebookOAuthConfigured(config)) {
|
|
57
|
+
throw new InternalServerErrorException(
|
|
58
|
+
"Facebook OAuth is not configured",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Public()
|
|
65
|
+
@UseGuards(FacebookOauthGuard)
|
|
66
|
+
@Get("connect")
|
|
67
|
+
async connect() {
|
|
68
|
+
await this.validateConfiguration();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Public()
|
|
72
|
+
@Get("connect/callback")
|
|
73
|
+
@UseGuards(FacebookOauthGuard)
|
|
74
|
+
async facebookAuthCallback(@Req() req: Request, @Res() res: Response) {
|
|
75
|
+
const config = await this.validateConfiguration();
|
|
76
|
+
const user = req.user;
|
|
77
|
+
return res.redirect(`${config.redirectURL}?accessCode=${user['accessCode']}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* This is just a dummy endpoint where we are passing in the accessCode, this will be configured in the .env as an environment variable and
|
|
82
|
+
* will be passed the accessCode, using the accessCode the UI code on this page will mostly invoke the /iam/facebook/auth endpoint which will finally generate the JWT token.
|
|
83
|
+
*
|
|
84
|
+
* @param accessCode
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
@Public()
|
|
88
|
+
@Get('dummy-redirect')
|
|
89
|
+
async dummyFacebookAuthRedirect(@Query('accessCode') accessCode) {
|
|
90
|
+
await this.validateConfiguration();
|
|
91
|
+
const user = await this.userService.findOneByAccessCode(accessCode);
|
|
92
|
+
|
|
93
|
+
if (user) {
|
|
94
|
+
delete user['password'];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return user;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Use this endpoint to authenticate using an accessCode with Facebook.
|
|
102
|
+
*
|
|
103
|
+
* @param accessCode
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
@Public()
|
|
107
|
+
@Get("authenticate")
|
|
108
|
+
@ApiQuery({ name: "accessCode", required: true, type: String })
|
|
109
|
+
async facebookAuth(@Query("accessCode") accessCode: string) {
|
|
110
|
+
await this.validateConfiguration();
|
|
111
|
+
return this.authService.signInUsingFacebook(accessCode);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete } from '@nestjs/common';
|
|
1
|
+
import { Controller, Post, Body, Param, UploadedFiles, UseInterceptors, Put, Get, Query, Delete, Patch } from '@nestjs/common';
|
|
2
2
|
import { AnyFilesInterceptor } from "@nestjs/platform-express";
|
|
3
3
|
import { ApiBearerAuth, ApiForbiddenResponse, ApiQuery, ApiTags } from '@nestjs/swagger';
|
|
4
4
|
import { MenuItemMetadataService } from '../services/menu-item-metadata.service';
|
|
@@ -17,23 +17,23 @@ export class MenuItemMetadataController {
|
|
|
17
17
|
@ApiBearerAuth("jwt")
|
|
18
18
|
@Post()
|
|
19
19
|
@UseInterceptors(AnyFilesInterceptor())
|
|
20
|
-
create(@Body() createDto: CreateMenuItemMetadataDto, @UploadedFiles() files: Array<Express.Multer.File
|
|
21
|
-
return this.service.create(createDto, files,solidRequestContext);
|
|
20
|
+
create(@Body() createDto: CreateMenuItemMetadataDto, @UploadedFiles() files: Array<Express.Multer.File>, @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
21
|
+
return this.service.create(createDto, files, solidRequestContext);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
@ApiBearerAuth("jwt")
|
|
25
25
|
@Post('/bulk')
|
|
26
26
|
@UseInterceptors(AnyFilesInterceptor())
|
|
27
|
-
insertMany(@Body() createDtos: CreateMenuItemMetadataDto[], @UploadedFiles() filesArray: Express.Multer.File[][] = []
|
|
28
|
-
return this.service.insertMany(createDtos, filesArray,solidRequestContext);
|
|
27
|
+
insertMany(@Body() createDtos: CreateMenuItemMetadataDto[], @UploadedFiles() filesArray: Express.Multer.File[][] = [], @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
28
|
+
return this.service.insertMany(createDtos, filesArray, solidRequestContext);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
@ApiBearerAuth("jwt")
|
|
33
33
|
@Put(':id')
|
|
34
34
|
@UseInterceptors(AnyFilesInterceptor())
|
|
35
|
-
update(@Param('id') id: number, @Body() updateDto: UpdateMenuItemMetadataDto, @UploadedFiles() files: Array<Express.Multer.File
|
|
36
|
-
return this.service.update(id, updateDto, files,false,solidRequestContext);
|
|
35
|
+
update(@Param('id') id: number, @Body() updateDto: UpdateMenuItemMetadataDto, @UploadedFiles() files: Array<Express.Multer.File>, @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
36
|
+
return this.service.update(id, updateDto, files, false, solidRequestContext);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
@ApiBearerAuth("jwt")
|
|
@@ -48,8 +48,8 @@ export class MenuItemMetadataController {
|
|
|
48
48
|
@ApiQuery({ name: 'populateMedia', required: false, type: Array })
|
|
49
49
|
@ApiQuery({ name: 'filters', required: false, type: Array })
|
|
50
50
|
@Get()
|
|
51
|
-
async findMany(@Query() query: any
|
|
52
|
-
return this.service.find(query,solidRequestContext);
|
|
51
|
+
async findMany(@Query() query: any, @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
52
|
+
return this.service.find(query, solidRequestContext);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// /api/solid-menu-item/me
|
|
@@ -63,19 +63,25 @@ export class MenuItemMetadataController {
|
|
|
63
63
|
|
|
64
64
|
@ApiBearerAuth("jwt")
|
|
65
65
|
@Get(':id')
|
|
66
|
-
async findOne(@Param('id') id: string, @Query() query: any
|
|
67
|
-
return this.service.findOne(+id, query,solidRequestContext);
|
|
66
|
+
async findOne(@Param('id') id: string, @Query() query: any, @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
67
|
+
return this.service.findOne(+id, query, solidRequestContext);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
@Delete('/bulk')
|
|
71
|
-
async deleteMany(@Body() ids: number[]
|
|
72
|
-
return this.service.deleteMany(ids,solidRequestContext);
|
|
71
|
+
async deleteMany(@Body() ids: number[], @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
72
|
+
return this.service.deleteMany(ids, solidRequestContext);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
@ApiBearerAuth("jwt")
|
|
76
76
|
@Delete(':id')
|
|
77
|
-
async delete(@Param('id') id: number
|
|
78
|
-
return this.service.delete(id,solidRequestContext);
|
|
77
|
+
async delete(@Param('id') id: number, @SolidRequestContextDecorator() solidRequestContext: SolidRequestContextDto) {
|
|
78
|
+
return this.service.delete(id, solidRequestContext);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
@ApiBearerAuth('jwt')
|
|
82
|
+
@Patch(':id')
|
|
83
|
+
@UseInterceptors(AnyFilesInterceptor())
|
|
84
|
+
partialUpdate(@Param('id') id: number, @Body() updateDto: UpdateMenuItemMetadataDto, @UploadedFiles() files: Array<Express.Multer.File>) {
|
|
85
|
+
return this.service.update(id, updateDto, files, true);
|
|
86
|
+
}
|
|
81
87
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
Inject,
|
|
5
|
+
InternalServerErrorException,
|
|
6
|
+
Query,
|
|
7
|
+
Req,
|
|
8
|
+
Res,
|
|
9
|
+
UseGuards,
|
|
10
|
+
} from "@nestjs/common";
|
|
11
|
+
import { ApiQuery, ApiTags } from "@nestjs/swagger";
|
|
12
|
+
import { Request, Response } from "express";
|
|
13
|
+
import {
|
|
14
|
+
MicrosoftAuthConfiguration,
|
|
15
|
+
isMicrosoftOAuthConfigured,
|
|
16
|
+
} from "../helpers/microsoft-oauth.helper";
|
|
17
|
+
import { AuthenticationService } from "../services/authentication.service";
|
|
18
|
+
import { SettingService } from "../services/setting.service";
|
|
19
|
+
import { Public } from "src/decorators/public.decorator";
|
|
20
|
+
import { Auth } from "../decorators/auth.decorator";
|
|
21
|
+
import { AuthType } from "../enums/auth-type.enum";
|
|
22
|
+
import { MicrosoftOauthGuard } from "../passport-strategies/microsoft-oauth.strategy";
|
|
23
|
+
import { UserService } from "../services/user.service";
|
|
24
|
+
import type { SolidCoreSetting } from "../services/settings/default-settings-provider.service";
|
|
25
|
+
|
|
26
|
+
@Auth(AuthType.None)
|
|
27
|
+
@ApiTags("Iam")
|
|
28
|
+
@Controller("iam/microsoft")
|
|
29
|
+
export class MicrosoftAuthenticationController {
|
|
30
|
+
constructor(
|
|
31
|
+
private readonly userService: UserService,
|
|
32
|
+
private readonly authService: AuthenticationService,
|
|
33
|
+
private readonly settingService: SettingService,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
private async getConfiguration(): Promise<MicrosoftAuthConfiguration> {
|
|
37
|
+
return {
|
|
38
|
+
clientID:
|
|
39
|
+
await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
40
|
+
"MICROSOFT_CLIENT_ID" as any,
|
|
41
|
+
),
|
|
42
|
+
clientSecret: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
43
|
+
"MICROSOFT_CLIENT_SECRET" as any,
|
|
44
|
+
),
|
|
45
|
+
tenant: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
46
|
+
"MICROSOFT_TENANT_ID" as any,
|
|
47
|
+
),
|
|
48
|
+
callbackURL: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
49
|
+
"MICROSOFT_CALLBACK_URL" as any,
|
|
50
|
+
),
|
|
51
|
+
redirectURL: await this.settingService.getConfigValue<SolidCoreSetting>(
|
|
52
|
+
"MICROSOFT_REDIRECT_URL" as any,
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private async validateConfiguration() {
|
|
58
|
+
const config = await this.getConfiguration();
|
|
59
|
+
if (!isMicrosoftOAuthConfigured(config)) {
|
|
60
|
+
throw new InternalServerErrorException(
|
|
61
|
+
"Microsoft OAuth is not configured",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return config;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Public()
|
|
68
|
+
@UseGuards(MicrosoftOauthGuard)
|
|
69
|
+
@Get("connect")
|
|
70
|
+
async connect() {
|
|
71
|
+
await this.validateConfiguration();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Public()
|
|
75
|
+
@Get("connect/callback")
|
|
76
|
+
@UseGuards(MicrosoftOauthGuard)
|
|
77
|
+
async microsoftAuthCallback(@Req() req: Request, @Res() res: Response) {
|
|
78
|
+
const config = await this.validateConfiguration();
|
|
79
|
+
const user = req.user;
|
|
80
|
+
return res.redirect(`${config.redirectURL}?accessCode=${user['accessCode']}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* This is just a dummy endpoint where we are passing in the accessCode, this will be configured in the .env as an environment variable and
|
|
85
|
+
* will be passed the accessCode, using the accessCode the UI code on this page will mostly invoke the /iam/microsoft/auth endpoint which will finally generate the JWT token.
|
|
86
|
+
*
|
|
87
|
+
* @param accessCode
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
@Public()
|
|
91
|
+
@Get('dummy-redirect')
|
|
92
|
+
async dummyMicrosoftAuthRedirect(@Query('accessCode') accessCode) {
|
|
93
|
+
await this.validateConfiguration();
|
|
94
|
+
const user = await this.userService.findOneByAccessCode(accessCode);
|
|
95
|
+
|
|
96
|
+
if (user) {
|
|
97
|
+
delete user['password'];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return user;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Use this endpoint to authenticate using an accessCode with Microsoft.
|
|
105
|
+
*
|
|
106
|
+
* @param accessCode
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
@Public()
|
|
110
|
+
@Get("authenticate")
|
|
111
|
+
@ApiQuery({ name: "accessCode", required: true, type: String })
|
|
112
|
+
async microsoftAuth(@Query("accessCode") accessCode: string) {
|
|
113
|
+
await this.validateConfiguration();
|
|
114
|
+
return this.authService.signInUsingMicrosoft(accessCode);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -7,28 +7,39 @@ export class CreateChatterMessageDto {
|
|
|
7
7
|
@IsString()
|
|
8
8
|
@ApiProperty()
|
|
9
9
|
messageType: string;
|
|
10
|
+
|
|
10
11
|
@IsNotEmpty()
|
|
11
12
|
@IsString()
|
|
12
13
|
@ApiProperty()
|
|
13
14
|
messageSubType: string;
|
|
15
|
+
|
|
14
16
|
@IsOptional()
|
|
15
17
|
@IsString()
|
|
16
18
|
@ApiProperty()
|
|
17
19
|
messageBody: string;
|
|
20
|
+
|
|
18
21
|
@IsNotEmpty()
|
|
19
22
|
@IsInt()
|
|
20
23
|
@ApiProperty()
|
|
21
24
|
coModelEntityId: number;
|
|
25
|
+
|
|
22
26
|
@IsNotEmpty()
|
|
23
27
|
@IsString()
|
|
24
28
|
@ApiProperty()
|
|
25
29
|
coModelName: string;
|
|
30
|
+
|
|
26
31
|
@IsOptional()
|
|
27
32
|
@IsInt()
|
|
28
33
|
@ApiProperty()
|
|
29
34
|
userId: number;
|
|
35
|
+
|
|
30
36
|
@IsString()
|
|
31
37
|
@IsOptional()
|
|
32
38
|
@ApiProperty()
|
|
33
39
|
userUserKey: string;
|
|
40
|
+
|
|
41
|
+
@IsString()
|
|
42
|
+
@IsOptional()
|
|
43
|
+
@ApiProperty()
|
|
44
|
+
status: string;
|
|
34
45
|
}
|
|
@@ -1,41 +1,53 @@
|
|
|
1
|
-
import { IsInt,IsOptional, IsString, IsNotEmpty } from 'class-validator';
|
|
1
|
+
import { IsInt, IsOptional, IsString, IsNotEmpty } from 'class-validator';
|
|
2
2
|
import { ApiProperty } from '@nestjs/swagger';
|
|
3
3
|
|
|
4
4
|
export class UpdateChatterMessageDto {
|
|
5
5
|
@IsOptional()
|
|
6
6
|
@IsInt()
|
|
7
7
|
id: number;
|
|
8
|
+
|
|
8
9
|
@IsNotEmpty()
|
|
9
10
|
@IsOptional()
|
|
10
11
|
@IsString()
|
|
11
12
|
@ApiProperty()
|
|
12
13
|
messageType: string;
|
|
14
|
+
|
|
13
15
|
@IsNotEmpty()
|
|
14
16
|
@IsOptional()
|
|
15
17
|
@IsString()
|
|
16
18
|
@ApiProperty()
|
|
17
19
|
messageSubType: string;
|
|
20
|
+
|
|
18
21
|
@IsNotEmpty()
|
|
19
22
|
@IsOptional()
|
|
20
23
|
@IsString()
|
|
21
24
|
@ApiProperty()
|
|
22
25
|
messageBody: string;
|
|
26
|
+
|
|
23
27
|
@IsNotEmpty()
|
|
24
28
|
@IsOptional()
|
|
25
29
|
@IsInt()
|
|
26
30
|
@ApiProperty()
|
|
27
31
|
coModelEntityId: number;
|
|
32
|
+
|
|
28
33
|
@IsNotEmpty()
|
|
29
34
|
@IsOptional()
|
|
30
35
|
@IsString()
|
|
31
36
|
@ApiProperty()
|
|
32
37
|
coModelName: string;
|
|
38
|
+
|
|
33
39
|
@IsOptional()
|
|
34
40
|
@IsInt()
|
|
35
41
|
@ApiProperty()
|
|
36
42
|
userId: number;
|
|
43
|
+
|
|
37
44
|
@IsString()
|
|
38
45
|
@IsOptional()
|
|
39
46
|
@ApiProperty()
|
|
40
47
|
userUserKey: string;
|
|
48
|
+
|
|
49
|
+
@IsOptional()
|
|
50
|
+
@IsString()
|
|
51
|
+
@ApiProperty()
|
|
52
|
+
status: string;
|
|
41
53
|
}
|
|
@@ -12,7 +12,7 @@ export class ChatterMessage extends CommonEntity {
|
|
|
12
12
|
messageType: string; // audit | custom
|
|
13
13
|
|
|
14
14
|
@Column({ type: "varchar" })
|
|
15
|
-
messageSubType: string; // audit_update | audit_insert | audit_delete | custom
|
|
15
|
+
messageSubType: string; // audit_update | audit_insert | audit_delete | custom | note | task
|
|
16
16
|
|
|
17
17
|
@Column({ nullable: true, ...getColumnType('longText') })
|
|
18
18
|
messageBody: string;
|
|
@@ -38,4 +38,7 @@ export class ChatterMessage extends CommonEntity {
|
|
|
38
38
|
|
|
39
39
|
@Column({ nullable: true })
|
|
40
40
|
modelUserKey: string;
|
|
41
|
+
|
|
42
|
+
@Column({ default: 'pending' })
|
|
43
|
+
status: string; // pending | completed
|
|
41
44
|
}
|
|
@@ -56,6 +56,38 @@ export class User extends CommonEntity {
|
|
|
56
56
|
// don't send to client
|
|
57
57
|
googleProfilePicture: string;
|
|
58
58
|
|
|
59
|
+
@Column({ type: "varchar", nullable: true })
|
|
60
|
+
// don't send to client
|
|
61
|
+
facebookId: string;
|
|
62
|
+
|
|
63
|
+
@Column({ type: "varchar", nullable: true })
|
|
64
|
+
// don't send to client
|
|
65
|
+
facebookAccessToken: string;
|
|
66
|
+
|
|
67
|
+
@Column({ type: "varchar", nullable: true })
|
|
68
|
+
// don't send to client
|
|
69
|
+
facebookProfilePicture: string;
|
|
70
|
+
|
|
71
|
+
@Column({ type: "varchar", nullable: true })
|
|
72
|
+
// don't send to client
|
|
73
|
+
appleId: string;
|
|
74
|
+
|
|
75
|
+
@Column({ type: "varchar", nullable: true })
|
|
76
|
+
// don't send to client
|
|
77
|
+
appleAccessToken: string;
|
|
78
|
+
|
|
79
|
+
@Column({ type: "varchar", nullable: true })
|
|
80
|
+
// don't send to client
|
|
81
|
+
microsoftId: string;
|
|
82
|
+
|
|
83
|
+
@Column({ type: "varchar", nullable: true })
|
|
84
|
+
// don't send to client
|
|
85
|
+
microsoftAccessToken: string;
|
|
86
|
+
|
|
87
|
+
@Column({ type: "varchar", nullable: true })
|
|
88
|
+
// don't send to client
|
|
89
|
+
microsoftProfilePicture: string;
|
|
90
|
+
|
|
59
91
|
@Column({ default: true })
|
|
60
92
|
@Expose()
|
|
61
93
|
active: boolean = true;
|
|
@@ -42,7 +42,7 @@ export function buildDefaultCorsOptions(): CorsOptions {
|
|
|
42
42
|
return cb(new Error(`Origin ${origin} not allowed by CORS. Allowed origins: ${allowed.join(', ')}`), false);
|
|
43
43
|
},
|
|
44
44
|
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
|
|
45
|
-
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
45
|
+
allowedHeaders: ['Content-Type', 'Authorization','solidx-api-key'],
|
|
46
46
|
credentials: true,
|
|
47
47
|
};
|
|
48
48
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type FacebookAuthConfiguration = {
|
|
2
|
+
clientID: string;
|
|
3
|
+
clientSecret: string;
|
|
4
|
+
callbackURL: string;
|
|
5
|
+
redirectURL: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const isFacebookOAuthConfigured = (
|
|
9
|
+
config: FacebookAuthConfiguration,
|
|
10
|
+
): boolean => {
|
|
11
|
+
return !!(
|
|
12
|
+
config.clientID &&
|
|
13
|
+
config.clientSecret &&
|
|
14
|
+
config.callbackURL &&
|
|
15
|
+
config.redirectURL
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type MicrosoftAuthConfiguration = {
|
|
2
|
+
clientID: string;
|
|
3
|
+
clientSecret: string;
|
|
4
|
+
tenant: string;
|
|
5
|
+
callbackURL: string;
|
|
6
|
+
redirectURL: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const isMicrosoftOAuthConfigured = (
|
|
10
|
+
config: MicrosoftAuthConfiguration,
|
|
11
|
+
): boolean => {
|
|
12
|
+
return !!(
|
|
13
|
+
config.clientID &&
|
|
14
|
+
config.clientSecret &&
|
|
15
|
+
config.tenant &&
|
|
16
|
+
config.callbackURL &&
|
|
17
|
+
config.redirectURL
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -11,6 +11,10 @@ export function getUserExcludedFields(): string[] {
|
|
|
11
11
|
"forcePasswordChange",
|
|
12
12
|
"lastLoginProvider",
|
|
13
13
|
"googleProfilePicture",
|
|
14
|
+
"facebookAccessToken",
|
|
15
|
+
"facebookId",
|
|
16
|
+
"microsoftAccessToken",
|
|
17
|
+
"microsoftId",
|
|
14
18
|
"forgotPasswordConfirmedAt",
|
|
15
19
|
"verificationTokenOnForgotPassword",
|
|
16
20
|
"verificationTokenOnForgotPasswordExpiresAt",
|
package/src/index.ts
CHANGED
|
@@ -261,6 +261,8 @@ export * from './jobs/redis/twilio-sms-subscriber-redis.service'
|
|
|
261
261
|
export * from './listeners/user-registration.listener'
|
|
262
262
|
|
|
263
263
|
export * from './passport-strategies/google-oauth.strategy'
|
|
264
|
+
export * from './passport-strategies/facebook-oauth.strategy'
|
|
265
|
+
export * from './passport-strategies/microsoft-oauth.strategy'
|
|
264
266
|
|
|
265
267
|
export * from './services/selection-providers/list-of-values-selection-providers.service'
|
|
266
268
|
|
package/src/interfaces.ts
CHANGED
|
@@ -68,12 +68,44 @@ export enum SettingLevel {
|
|
|
68
68
|
InternalUser = "internal-user"
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
export type SettingControlType =
|
|
72
|
+
| 'shortText'
|
|
73
|
+
| 'longText'
|
|
74
|
+
| 'numeric'
|
|
75
|
+
| 'boolean'
|
|
76
|
+
| 'date'
|
|
77
|
+
| 'datetime'
|
|
78
|
+
| 'mediaSingle'
|
|
79
|
+
| 'selectionStatic'
|
|
80
|
+
| 'custom';
|
|
81
|
+
|
|
82
|
+
export interface SettingOption {
|
|
83
|
+
label: string;
|
|
84
|
+
value: string | number | boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
71
87
|
export interface SettingDefinition<T = any> {
|
|
72
88
|
moduleName: string;
|
|
73
89
|
key: string;
|
|
74
90
|
value: T;
|
|
75
91
|
level: SettingLevel;
|
|
76
92
|
encrypted?: boolean;
|
|
93
|
+
label?: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
placeholder?: string;
|
|
96
|
+
group?: string;
|
|
97
|
+
sortOrder?: number;
|
|
98
|
+
controlType?: SettingControlType;
|
|
99
|
+
options?: SettingOption[];
|
|
100
|
+
settingsWidget?: string; // for custom controlType, specify the frontend widget to use
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface AdminSettingDefinition<T = any> extends SettingDefinition<T> {
|
|
104
|
+
editable: boolean;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface AdminSettingsResponse<T = any> {
|
|
108
|
+
data: AdminSettingDefinition<T>[];
|
|
77
109
|
}
|
|
78
110
|
|
|
79
111
|
// solid-core/settings/settings-provider.interface.ts
|
|
@@ -419,4 +451,3 @@ export interface AuditQueuePayload {
|
|
|
419
451
|
userId?: number | null;
|
|
420
452
|
}
|
|
421
453
|
|
|
422
|
-
|