hyunw9 commented on code in PR #5046: URL: https://github.com/apache/zeppelin/pull/5046#discussion_r2300822763
########## zeppelin-server/src/main/java/org/apache/zeppelin/realm/RoleMappingLdapRealm.java: ########## @@ -0,0 +1,86 @@ +/* + * 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.zeppelin.realm; + +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.realm.ldap.DefaultLdapRealm; +import org.apache.shiro.realm.ldap.LdapContextFactory; +import org.apache.shiro.subject.PrincipalCollection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * RoleMappingLdapRealm is a simple LDAP realm that returns configured role for specific users. + * Example configurations: + * ldapRealm = org.apache.zeppelin.realm.RoleMappingLdapRealm + * ldapRealm.rolesByUsername = user1:admin,user2:user,user3:user,user4:user + * ldapRealm.defaultRole = user + */ +public class RoleMappingLdapRealm extends DefaultLdapRealm { + + private static final Logger LOGGER = LoggerFactory.getLogger(RoleMappingLdapRealm.class); + + private String defaultRole = "admin"; Review Comment: Hello, thanks for the implementation. I have a quick question about the default role. I noticed that defaultRole is initialized to "admin". If an administrator forgets to set the `ldapRealm.defaultRole property` in shiro.ini, does this mean any authenticated user not in the rolesByUsername map would get admin privileges by default? This seems like a potential security risk. I’m wondering if this behavior is intentional. -- 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: reviews-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org