Fix server logs leak (#18423)
# Introduction Previously the auth jwt stragegy would lod the whole user entity in the auth user context On an exception it would completely get logged on the pods ## Security layer - 0/ Updating the type system ( devxp only though ) - 1/ The jwt auth stragegy only load a specific sub set of the user entity - 2/ Sanitizing at the exception log level directly in case of a user context - 3/ Sanitizing at the console driver The last two sanitization could sound a bit redundant though they're still good fallback to keep in case new path occurs in the cb
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
UpdateWorkspaceMemberEmailJob,
|
||||
UpdateWorkspaceMemberEmailJobData,
|
||||
} from 'src/engine/core-modules/user/jobs/update-workspace-member-email.job';
|
||||
import { type AuthContextUser } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { UserEntity } from 'src/engine/core-modules/user/user.entity';
|
||||
import { UserExceptionCode } from 'src/engine/core-modules/user/user.exception';
|
||||
import { userValidator } from 'src/engine/core-modules/user/user.validate';
|
||||
@@ -58,7 +59,7 @@ export class UserService extends TypeOrmQueryService<UserEntity> {
|
||||
super(userRepository);
|
||||
}
|
||||
|
||||
async loadWorkspaceMember(user: UserEntity, workspace: WorkspaceEntity) {
|
||||
async loadWorkspaceMember(user: AuthContextUser, workspace: WorkspaceEntity) {
|
||||
if (!isWorkspaceActiveOrSuspended(workspace)) {
|
||||
return null;
|
||||
}
|
||||
@@ -365,7 +366,7 @@ export class UserService extends TypeOrmQueryService<UserEntity> {
|
||||
newEmail,
|
||||
verifyEmailRedirectPath,
|
||||
}: {
|
||||
user: UserEntity;
|
||||
user: AuthContextUser;
|
||||
workspace: WorkspaceEntity;
|
||||
newEmail: string;
|
||||
verifyEmailRedirectPath?: string;
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
WorkspaceMemberTranspiler,
|
||||
} from 'src/engine/core-modules/user/services/workspace-member-transpiler.service';
|
||||
import { UserVarsService } from 'src/engine/core-modules/user/user-vars/services/user-vars.service';
|
||||
import { type AuthContextUser } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { UserEntity } from 'src/engine/core-modules/user/user.entity';
|
||||
import { userValidator } from 'src/engine/core-modules/user/user.validate';
|
||||
import { AuthProviderEnum } from 'src/engine/core-modules/workspace/types/workspace.type';
|
||||
@@ -119,7 +120,7 @@ export class UserResolver {
|
||||
@Query(() => UserEntity)
|
||||
@UseGuards(UserAuthGuard, NoPermissionGuard)
|
||||
async currentUser(
|
||||
@AuthUser() { id: userId }: UserEntity,
|
||||
@AuthUser() { id: userId }: AuthContextUser,
|
||||
@AuthWorkspace({ allowUndefined: true }) workspace: WorkspaceEntity,
|
||||
): Promise<UserEntity> {
|
||||
const user = await this.userRepository.findOne({
|
||||
@@ -360,7 +361,7 @@ export class UserResolver {
|
||||
|
||||
@Mutation(() => UserEntity)
|
||||
@UseGuards(UserAuthGuard, NoPermissionGuard)
|
||||
async deleteUser(@AuthUser() { id: userId }: UserEntity) {
|
||||
async deleteUser(@AuthUser() { id: userId }: AuthContextUser) {
|
||||
return this.userService.deleteUser(userId);
|
||||
}
|
||||
|
||||
@@ -368,7 +369,7 @@ export class UserResolver {
|
||||
@UseGuards(UserAuthGuard, CustomPermissionGuard)
|
||||
async deleteUserFromWorkspace(
|
||||
@Args('workspaceMemberIdToDelete') workspaceMemberIdToDelete: string,
|
||||
@AuthUser() { id: userId }: UserEntity,
|
||||
@AuthUser() { id: userId }: AuthContextUser,
|
||||
@AuthUserWorkspaceId() userWorkspaceId: string,
|
||||
@AuthWorkspace()
|
||||
workspace: WorkspaceEntity,
|
||||
@@ -468,7 +469,7 @@ export class UserResolver {
|
||||
|
||||
@ResolveField(() => AvailableWorkspaces)
|
||||
async availableWorkspaces(
|
||||
@AuthUser() user: UserEntity,
|
||||
@AuthUser() user: AuthContextUser,
|
||||
@AuthProvider() authProvider: AuthProviderEnum,
|
||||
): Promise<AvailableWorkspaces> {
|
||||
return this.userWorkspaceService.setLoginTokenToAvailableWorkspacesWhenAuthProviderMatch(
|
||||
@@ -488,7 +489,7 @@ export class UserResolver {
|
||||
)
|
||||
async updateUserEmail(
|
||||
@Args() { newEmail, verifyEmailRedirectPath }: UpdateUserEmailInput,
|
||||
@AuthUser() user: UserEntity,
|
||||
@AuthUser() user: AuthContextUser,
|
||||
@AuthWorkspace() workspace: WorkspaceEntity,
|
||||
) {
|
||||
const editableFields = workspace.editableProfileFields || [];
|
||||
|
||||
Reference in New Issue
Block a user