[ISSUE#11494] Fix frequently request login api when using 2.X client with username. (#11495)
* Fix frequently request login api when using 2.X client with username. * Fix frequently request login api when using 2.X client with username.
This commit is contained in:
parent
26d045ca49
commit
a3420b733b
@ -49,8 +49,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class JwtTokenManager extends Subscriber<ServerConfigChangeEvent> implements TokenManager {
|
||||
|
||||
@Deprecated
|
||||
private static final String AUTHORITIES_KEY = "auth";
|
||||
private static final String AUTH_DISABLED_TOKEN = "AUTH_DISABLED";
|
||||
|
||||
/**
|
||||
* Token validity time(seconds).
|
||||
@ -105,7 +104,7 @@ public class JwtTokenManager extends Subscriber<ServerConfigChangeEvent> impleme
|
||||
*/
|
||||
public String createToken(String userName) {
|
||||
if (!authConfigs.isAuthEnabled()) {
|
||||
return StringUtils.EMPTY;
|
||||
return AUTH_DISABLED_TOKEN;
|
||||
}
|
||||
checkJwtParser();
|
||||
return jwtParser.jwtBuilder().setUserName(userName).setExpiredTime(this.tokenValidityInSeconds).compact();
|
||||
|
@ -110,7 +110,7 @@ public class JwtTokenManagerTest {
|
||||
public void testCreateTokenWhenDisableAuth() {
|
||||
when(authConfigs.isAuthEnabled()).thenReturn(false);
|
||||
jwtTokenManager = new JwtTokenManager(authConfigs);
|
||||
assertEquals("", jwtTokenManager.createToken("nacos"));
|
||||
assertEquals("AUTH_DISABLED", jwtTokenManager.createToken("nacos"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user