prashantpogde commented on a change in pull request #2059: URL: https://github.com/apache/ozone/pull/2059#discussion_r617139770
########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tenant/OMTenantUserCreateRequest.java ########## @@ -0,0 +1,285 @@ +/* + * 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.hadoop.ozone.om.request.s3.tenant; + +import com.google.common.base.Optional; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.hadoop.hdds.utils.db.cache.CacheKey; +import org.apache.hadoop.hdds.utils.db.cache.CacheValue; +import org.apache.hadoop.ozone.OmUtils; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.audit.OMAction; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.OzoneManager; +import org.apache.hadoop.ozone.om.exceptions.OMException; +import org.apache.hadoop.ozone.om.helpers.S3SecretValue; +import org.apache.hadoop.ozone.om.multitenant.OzoneMultiTenantPrincipal; +import org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerDoubleBufferHelper; +import org.apache.hadoop.ozone.om.request.util.OmResponseUtil; +import org.apache.hadoop.ozone.om.request.volume.OMVolumeRequest; +import org.apache.hadoop.ozone.om.response.OMClientResponse; +import org.apache.hadoop.ozone.om.response.s3.tenant.OMTenantCreateResponse; +import org.apache.hadoop.ozone.om.response.s3.tenant.OMTenantUserCreateResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateTenantUserRequest; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateTenantUserResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.S3Secret; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UpdateGetS3SecretRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.S3_SECRET_LOCK; +import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.VOLUME_LOCK; + +/* + Ratis execution flow for OMTenantUserCreate + +- Client (UserCreateHandler , etc.) + - Check username validity: ensure no invalid characters + - Send request to server +- OMTenantUserCreateRequest + - preExecute (perform checks and init) + - Check username validity (again), check $ + - If username is invalid, throw exception to client; else continue + - Generate S3 secret for the new user + - validateAndUpdateCache (update DB) + - Permission check (checkACL need to check access key now) + - Grab VOLUME_LOCK write lock + - Check user existence + - If user doesn't exist, throw exception to client; else continue + - Check tenant existence + - If tenant doesn't exist, throw exception to client; else continue + - Grab S3_SECRET_LOCK write lock + - S3SecretTable: Flush generated S3 secret + - Key: TENANTNAME$USERNAME (equivalent to kerberosID) + - Value: <GENERATED_SECRET> + - Release S3_SECRET_LOCK write lock + - tenantUserTable: New entry + - Key: Tenant user name. e.g. finance$bob, s3v$alice + - Value: Tenant name. e.g. finance + - tenantGroupTable: Add this new user to the default tenant group. + - Key: finance$bob + - Value: finance-users + - tenantRoleTable: TBD. NoOp for prototype. + - Release VOLUME_LOCK write lock + */ + +/** + * Handles OMTenantUserCreate request. + */ +public class OMTenantUserCreateRequest extends OMVolumeRequest { Review comment: yup -- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
