diff --git a/iotdb-client/session/src/test/resources/iotdb-common.properties b/iotdb-client/session/src/test/resources/iotdb-common.properties index 5019b199d1e4c..965b3c010ede1 100644 --- a/iotdb-client/session/src/test/resources/iotdb-common.properties +++ b/iotdb-client/session/src/test/resources/iotdb-common.properties @@ -33,15 +33,6 @@ enable_rest_service=true # Whether to display rest service interface information through swagger. eg: http://ip:port/swagger.json # enable_swagger=false -# the expiration time of the user login information cache (in seconds) -# cache_expire_in_seconds=28800 - -# maximum number of users can be stored in the user login cache. -# cache_max_num=100 - -# init capacity of users can be stored in the user login cache. -# cache_init_num=10 - # is SSL enabled # enable_https=false diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java index 2e9f49917f030..ee8ca0705b5e0 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/rest/IoTDBRestServiceDescriptor.java @@ -109,16 +109,6 @@ private void loadProps(TrimProperties properties) { Integer.parseInt( properties.getProperty( "idle_timeout_in_seconds", Integer.toString(conf.getIdleTimeoutInSeconds())))); - conf.setCacheExpireInSeconds( - Integer.parseInt( - properties.getProperty( - "cache_expire_in_seconds", Integer.toString(conf.getCacheExpireInSeconds())))); - conf.setCacheInitNum( - Integer.parseInt( - properties.getProperty("cache_init_num", Integer.toString(conf.getCacheInitNum())))); - conf.setCacheMaxNum( - Integer.parseInt( - properties.getProperty("cache_max_num", Integer.toString(conf.getCacheMaxNum())))); } /** diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java index 53c825cb69cbb..878705ad0bc07 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/AuthorizationFilter.java @@ -47,7 +47,6 @@ @Provider public class AuthorizationFilter implements ContainerRequestFilter, ContainerResponseFilter { - private final UserCache userCache = UserCache.getInstance(); IoTDBRestServiceConfig config = IoTDBRestServiceDescriptor.getInstance().getConfig(); private static final SessionManager SESSION_MANAGER = SessionManager.getInstance(); @@ -85,15 +84,11 @@ public void filter(ContainerRequestContext containerRequestContext) throws IOExc containerRequestContext.abortWith(resp); return; } - User user = userCache.getUser(authorizationHeader); + User user = checkLogin(containerRequestContext, authorizationHeader); if (user == null) { - user = checkLogin(containerRequestContext, authorizationHeader); - if (user == null) { - return; - } else { - userCache.setUser(authorizationHeader, user); - } + return; } + String sessionid = UUID.randomUUID().toString(); if (SESSION_MANAGER.getCurrSession() == null) { RestClientSession restClientSession = new RestClientSession(sessionid); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java deleted file mode 100644 index f53273def2d05..0000000000000 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/rest/filter/UserCache.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.iotdb.db.protocol.rest.filter; - -import org.apache.iotdb.db.conf.rest.IoTDBRestServiceConfig; -import org.apache.iotdb.db.conf.rest.IoTDBRestServiceDescriptor; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; - -import java.util.concurrent.TimeUnit; - -public class UserCache { - private static final IoTDBRestServiceConfig CONFIG = - IoTDBRestServiceDescriptor.getInstance().getConfig(); - private final Cache cache; - - private UserCache() { - cache = - Caffeine.newBuilder() - .initialCapacity(CONFIG.getCacheInitNum()) - .maximumSize(CONFIG.getCacheMaxNum()) - .expireAfterWrite(CONFIG.getCacheExpireInSeconds(), TimeUnit.SECONDS) - .build(); - } - - public static UserCache getInstance() { - return UserCacheHolder.INSTANCE; - } - - public User getUser(String key) { - return cache.getIfPresent(key); - } - - public void setUser(String key, User user) { - cache.put(key, user); - } - - private static class UserCacheHolder { - private static final UserCache INSTANCE = new UserCache(); - } -} diff --git a/iotdb-core/datanode/src/test/resources/iotdb-common.properties b/iotdb-core/datanode/src/test/resources/iotdb-common.properties index fd24dc22d6695..1053eaafa2dad 100644 --- a/iotdb-core/datanode/src/test/resources/iotdb-common.properties +++ b/iotdb-core/datanode/src/test/resources/iotdb-common.properties @@ -33,15 +33,6 @@ enable_rest_service=true # the default row limit to a REST query response when the rowSize parameter is not given in request # rest_query_default_row_size_limit=10000 -# the expiration time of the user login information cache (in seconds) -# cache_expire_in_seconds=28800 - -# maximum number of users can be stored in the user login cache. -# cache_max_num=100 - -# init capacity of users can be stored in the user login cache. -# cache_init_num=10 - # is SSL enabled # enable_https=false diff --git a/iotdb-core/datanode/src/test/resources/iotdb-system.properties b/iotdb-core/datanode/src/test/resources/iotdb-system.properties index 9bf298a2cf0f5..ce0ecff34f35f 100644 --- a/iotdb-core/datanode/src/test/resources/iotdb-system.properties +++ b/iotdb-core/datanode/src/test/resources/iotdb-system.properties @@ -50,15 +50,6 @@ enable_rest_service=true # the default row limit to a REST query response when the rowSize parameter is not given in request # rest_query_default_row_size_limit=10000 -# the expiration time of the user login information cache (in seconds) -# cache_expire_in_seconds=28800 - -# maximum number of users can be stored in the user login cache. -# cache_max_num=100 - -# init capacity of users can be stored in the user login cache. -# cache_init_num=10 - # is SSL enabled # enable_https=false diff --git a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template index 126feb4123d0e..e12f3d2ddc881 100644 --- a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template +++ b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template @@ -560,21 +560,6 @@ enable_swagger=false # Datatype: int rest_query_default_row_size_limit=10000 -# the expiration time of the user login information cache (in seconds) -# effectiveMode: restart -# Datatype: int -cache_expire_in_seconds=28800 - -# maximum number of users can be stored in the user login cache. -# effectiveMode: restart -# Datatype: int -cache_max_num=100 - -# init capacity of users can be stored in the user login cache. -# effectiveMode: restart -# Datatype: int -cache_init_num=10 - # Is client authentication required # effectiveMode: restart # Datatype: boolean