jerryshao commented on code in PR #3946: URL: https://github.com/apache/gravitino/pull/3946#discussion_r1667892716
########## api/src/main/java/com/datastrato/gravitino/authorization/RoleChange.java: ########## @@ -0,0 +1,155 @@ +/* + * 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 com.datastrato.gravitino.authorization; + +import com.datastrato.gravitino.annotation.Evolving; + +/** The RoleChange interface defines the public API for managing roles in an authorization. */ +@Evolving +public interface RoleChange { + /** + * Create a RoleChange for Add a securable object into a role. + * + * @param securableObject The securable object. + * @return return a RoleChange for the add securable object. + */ + static RoleChange addSecurableObject(SecurableObject securableObject) { + return new AddSecurableObject(securableObject); + } + + /** + * Create a RoleChange for remove a securable object from a role. Review Comment: "to remove a securable..." ########## api/src/main/java/com/datastrato/gravitino/authorization/RoleChange.java: ########## @@ -0,0 +1,155 @@ +/* + * 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 com.datastrato.gravitino.authorization; + +import com.datastrato.gravitino.annotation.Evolving; + +/** The RoleChange interface defines the public API for managing roles in an authorization. */ +@Evolving +public interface RoleChange { + /** + * Create a RoleChange for Add a securable object into a role. Review Comment: "to add a securable..." ########## core/src/main/java/com/datastrato/gravitino/connector/authorization/AuthorizationRoleHook.java: ########## @@ -0,0 +1,66 @@ +/* + * 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 com.datastrato.gravitino.connector.authorization; + +import com.datastrato.gravitino.authorization.Role; +import com.datastrato.gravitino.authorization.RoleChange; +import com.datastrato.gravitino.authorization.SecurableObject; +import java.util.List; + +/** Interface for authorization Role hooks operation of the underlying access control system */ +public interface AuthorizationRoleHook { + /** + * Creates a new Role into the underlying access control system. + * + * @param role The entity of the Role. + * @param securableObjects The securable objects of the Role. + * @return True if the create operation success; False if the create operation failed. + * @throws RuntimeException If creating the Role encounters storage issues. + */ + Boolean onCreateRole(Role role, List<SecurableObject> securableObjects) throws RuntimeException; Review Comment: Why do you return `Boolean` instead of `boolean`? ########## core/src/main/java/com/datastrato/gravitino/connector/authorization/AuthorizationHook.java: ########## @@ -0,0 +1,29 @@ +/* + * 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 com.datastrato.gravitino.connector.authorization; + +import java.io.Closeable; + +/** + * authorization operations hooks interfaces. Note: Because each interface function needs to perform + * multiple steps in the underlying permission system, the implementation method of these function + * interface must be idempotent. + */ +public interface AuthorizationHook Review Comment: Should we only implement this `AuthorizationHook`, or can developers directly implement `AuthorizationUserHook`? ########## core/src/main/java/com/datastrato/gravitino/connector/authorization/AuthorizationRoleHook.java: ########## @@ -0,0 +1,66 @@ +/* + * 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 com.datastrato.gravitino.connector.authorization; + +import com.datastrato.gravitino.authorization.Role; +import com.datastrato.gravitino.authorization.RoleChange; +import com.datastrato.gravitino.authorization.SecurableObject; +import java.util.List; + +/** Interface for authorization Role hooks operation of the underlying access control system */ +public interface AuthorizationRoleHook { Review Comment: I would suggest renaming to `RoleAuthorizationPlugin` and `UserGroupAuthorizationPlugin`, WDYT? ########## core/src/main/java/com/datastrato/gravitino/authorization/AuthorizationProvider.java: ########## @@ -0,0 +1,33 @@ +/* + * 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 com.datastrato.gravitino.authorization; Review Comment: I would suggest to move all the interfaces that will be used by developers to `xxx.connector.authorization`, WDYT? ########## core/src/main/java/com/datastrato/gravitino/authorization/AuthorizationProvider.java: ########## @@ -0,0 +1,33 @@ +/* + * 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 com.datastrato.gravitino.authorization; Review Comment: Also, please update the package name to `o.a.gravitino.xxx` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
