Skip to content

forbid email login that is disabled #1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public enum BizError {
JWT_NOT_FIND(400, 5619),
ID_NOT_EXIST(500, 5620),
DUPLICATE_AUTH_CONFIG_ADDITION(400, 5621),
EMAIL_PROVIDER_DISABLED(403, 5622),


// asset related, code range 5700 - 5799
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@ ORG_DELETED_FOR_ENTERPRISE_MODE=Provided enterpriseOrgId workspace has been dele
DISABLE_AUTH_CONFIG_FORBIDDEN=Can not disable current administrator''s last identity provider.
USER_NOT_EXIST=User not exist.
DUPLICATE_AUTH_CONFIG_ADDITION=Provider auth type already added to organization
EMAIL_PROVIDER_DISABLED=Email provider is disabled.
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ protected Mono<AuthUser> authenticate(String authId, @Deprecated String source,
log.warn("source is deprecated and will be removed in the future, please use authId instead. {}", source);
return authenticationService.findAuthConfigBySource(context.getOrgId(), source);
})
.doOnNext(findAuthConfig -> {
.flatMap(findAuthConfig -> {
context.setAuthConfig(findAuthConfig.authConfig());
if (findAuthConfig.authConfig().getSource().equals("EMAIL")) {
if(StringUtils.isBlank(context.getOrgId())) {
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
}
if(!findAuthConfig.authConfig().getEnable()) {
return Mono.error(new BizException(EMAIL_PROVIDER_DISABLED, "EMAIL_PROVIDER_DISABLED"));
}
} else {
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
}
return Mono.just(findAuthConfig);
})
.then(authRequestFactory.build(context))
.flatMap(authRequest -> authRequest.auth(context))
Expand Down
Loading