plusplusjiajia commented on code in PR #9393: URL: https://github.com/apache/paimon/pull/9393#discussion_r3859587498
########## paimon-api/src/main/java/org/apache/paimon/management/PermissionAssignment.java: ########## @@ -0,0 +1,165 @@ +/* + * 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.paimon.management; + +import org.apache.paimon.annotation.Experimental; + +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonCreator; +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonGetter; +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty; + +import javax.annotation.Nullable; + +import java.beans.ConstructorProperties; +import java.time.Instant; +import java.time.format.DateTimeParseException; + +import static org.apache.paimon.utils.Preconditions.checkArgument; +import static org.apache.paimon.utils.Preconditions.checkNotNull; + +/** + * Direct permission assignment on one exact resource or explicit descendant scope. + * + * <p>A {@link ResourceType#COLUMN COLUMN} assignment carries one {@link PermissionColumns} value. + * The column range is mutable assignment content rather than identity: granting the same resource, + * access, and principal replaces the complete range. + * + * <p>{@code expireTime}, when present, is an exclusive authorization upper bound evaluated against + * the server clock. At or after that instant, the assignment must not authorize access, although an + * expired record may remain listable until cleanup. + */ +@Experimental +@JsonIgnoreProperties(ignoreUnknown = true) +public class PermissionAssignment { + + /** Maximum principal identifier length in the portable REST management contract. */ + public static final int MAX_PRINCIPAL_LENGTH = 128; + + private static final String FIELD_RESOURCE = "resource"; + private static final String FIELD_ACCESS = "access"; + private static final String FIELD_PRINCIPAL = "principal"; + private static final String FIELD_COLUMNS = "columns"; + private static final String FIELD_EXPIRE_TIME = "expireTime"; + + @JsonProperty(FIELD_RESOURCE) + private final PermissionResource resource; + + @JsonProperty(FIELD_ACCESS) + private final String access; + + @JsonProperty(FIELD_PRINCIPAL) + private final String principal; + + @Nullable + @JsonProperty(FIELD_COLUMNS) + @JsonInclude(JsonInclude.Include.NON_NULL) + private final PermissionColumns columns; + + @Nullable + @JsonProperty(FIELD_EXPIRE_TIME) + @JsonInclude(JsonInclude.Include.NON_NULL) + private final String expireTime; + + @JsonCreator Review Comment: This @JsonCreator is also the strict-validation constructor, and it deserializes ListPermissionsResponse.permissions — so anything the client doesn't recognize fails the whole page, not one row. E.g. Instant.now() is microsecond-precision on JDK 9+, so a server returning ...00.123456Z breaks every list call; such a record can't be revoked either, since RevokePermissionRequest runs the same canonicalize. Since the server decides anyway, could we keep validation on the request path and let the response path be lenient — e.g. move @JsonCreator to a package-private unvalidated constructor? -- 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]
