Skip to content

Commit

Permalink
Added edge case handling for weird IBM ldap issues (#9527)
Browse files Browse the repository at this point in the history
* Added edge case handling for weird IBM ldap issues

* Update api/src/exceptions/unexpected-response.ts
  • Loading branch information
aidenfoxx committed Dec 10, 2021
1 parent c777520 commit 63ade9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/auth/drivers/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ldap, {
EqualityFilter,
SearchCallbackResponse,
SearchEntry,
LDAPResult,
InappropriateAuthenticationError,
InvalidCredentialsError,
InsufficientAccessRightsError,
Expand All @@ -19,6 +20,7 @@ import {
InvalidPayloadException,
ServiceUnavailableException,
InvalidConfigException,
UnexpectedResponseException,
} from '../../exceptions';
import { AuthenticationService, UsersService } from '../../services';
import asyncHandler from '../../utils/async-handler';
Expand Down Expand Up @@ -98,6 +100,13 @@ export class LDAPAuthDriver extends AuthDriver {
}
});
});

res.on('end', (result: LDAPResult | null) => {
if (result?.status === 0) {
// Handle edge case with IBM systems where authenticated bind user could not fetch their DN
reject(new UnexpectedResponseException('Failed to find bind user record'));
}
});
});
});
}
Expand Down
1 change: 1 addition & 0 deletions api/src/exceptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './route-not-found';
export * from './service-unavailable';
export * from './unprocessable-entity';
export * from './user-suspended';
export * from './unexpected-response';
7 changes: 7 additions & 0 deletions api/src/exceptions/unexpected-response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BaseException } from '@directus/shared/exceptions';

export class UnexpectedResponseException extends BaseException {
constructor(message: string) {
super(message, 503, 'UNEXPECTED_RESPONSE');
}
}

0 comments on commit 63ade9b

Please sign in to comment.