Skip to content

Commit

Permalink
allow no auth type, choose default DB
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatsai committed Jan 16, 2025
1 parent 01db82a commit efcf8b1
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.apache.seatunnel.server.common.SeatunnelErrorEnum;
import org.apache.seatunnel.server.common.SeatunnelException;

import org.apache.commons.lang3.StringUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -159,11 +161,12 @@ public void disable(int id) {

@Override
public UserSimpleInfoRes login(UserLoginReq req, String authType) {
if (!strategies.containsKey(authType)) {
if (StringUtils.isNotEmpty(authType) && !strategies.containsKey(authType)) {
throw new SeatunnelException(
SeatunnelErrorEnum.INVALID_AUTHENTICATION_PROVIDER, authType);
}
IAuthenticationStrategy strategy = strategies.get(authType);
IAuthenticationStrategy strategy =
strategies.getOrDefault(authType, dbAuthenticationStrategy);
User user = strategy.authenticate(req);
UserSimpleInfoRes translate = translate(user);
final String token = jwtUtils.genToken(translate.toMap());
Expand Down

0 comments on commit efcf8b1

Please sign in to comment.