healchow commented on code in PR #8201: URL: https://github.com/apache/inlong/pull/8201#discussion_r1223924151
########## inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/InlongUserRoleEntityMapper.java: ########## @@ -30,6 +30,8 @@ public interface InlongUserRoleEntityMapper { InlongUserRoleEntity selectById(Integer id); + InlongUserRoleEntity selectByName(String userName); Review Comment: `userName` -> `username` At the same time, `selectByUsername` may be more accurate to prevent the meaning of `selectByName` from being unclear when adding other fields such as `role_name` and `tenant_name` in the subsequent DB. ########## inlong-manager/manager-dao/src/main/resources/mappers/TenantUserRoleEntityMapper.xml: ########## @@ -91,4 +90,13 @@ from tenant_user_role where id = #{id,jdbcType=INTEGER} </delete> + + <select id="selectByNameAndTenant" parameterType="java.lang.String" resultMap="BaseResultMap"> Review Comment: ditto ########## inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/tenant/InlongTenantServiceImpl.java: ########## @@ -45,6 +45,9 @@ public class InlongTenantServiceImpl implements InlongTenantService { @Override public InlongTenantInfo get(String name) { InlongTenantEntity entity = inlongTenantEntityMapper.selectByName(name); + if (entity == null) { + return null; Review Comment: Do we need some warn or error logs here? ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingRealm.java: ########## @@ -0,0 +1,122 @@ +/* + * 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.inlong.manager.web.auth.tenant; + +import org.apache.inlong.manager.common.util.Preconditions; +import org.apache.inlong.manager.pojo.tenant.InlongTenantInfo; +import org.apache.inlong.manager.pojo.user.InlongRoleInfo; +import org.apache.inlong.manager.pojo.user.TenantRoleInfo; +import org.apache.inlong.manager.pojo.user.UserInfo; +import org.apache.inlong.manager.service.tenant.InlongTenantService; +import org.apache.inlong.manager.service.user.InlongRoleService; +import org.apache.inlong.manager.service.user.LoginUserUtils; +import org.apache.inlong.manager.service.user.TenantRoleService; +import org.apache.inlong.manager.service.user.UserService; + +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.SimpleAuthenticationInfo; +import org.apache.shiro.realm.AuthenticatingRealm; + +import java.util.HashSet; +import java.util.Set; + +@Slf4j +public class TenantAuthenticatingRealm extends AuthenticatingRealm { Review Comment: javadocs, please. ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantAuthenticatingFilter.java: ########## @@ -0,0 +1,80 @@ +/* + * 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.inlong.manager.web.auth.tenant; + +import org.apache.inlong.manager.common.util.Preconditions; +import org.apache.inlong.manager.pojo.user.UserInfo; + +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; + +import static org.apache.inlong.common.util.BasicAuth.BASIC_AUTH_TENANT_HEADER; + +@Slf4j Review Comment: Add some javadocs, please. ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/InlongShiroImpl.java: ########## @@ -135,4 +156,17 @@ public AuthorizationAttributeSourceAdvisor getAuthorizationAttributeSourceAdviso authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); return authorizationAttributeSourceAdvisor; } + + private String genFiltersInOrder(String... filterNames) { + if (filterNames.length == 1) { + return filterNames[0]; + } + + StringBuilder sb = new StringBuilder(); Review Comment: `sb` -> `builder` ########## inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/auth/tenant/TenantToken.java: ########## @@ -0,0 +1,40 @@ +/* + * 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.inlong.manager.web.auth.tenant; + +import lombok.AllArgsConstructor; +import lombok.Data; +import org.apache.shiro.authc.AuthenticationToken; + +@Data +@AllArgsConstructor +public class TenantToken implements AuthenticationToken { Review Comment: javadocs, please. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@inlong.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org