ซิงค์ระบบข้อมูลประจําตัวที่แตกต่างกัน

การควบคุมการเข้าถึงใน Google Cloud Search จะอิงตามบัญชี Google ของผู้ใช้ เมื่อจัดทำดัชนีเนื้อหา ACL ของรายการทั้งหมดต้องเปลี่ยนเป็นรหัสผู้ใช้หรือกลุ่ม Google ที่ถูกต้อง (อีเมล)

ในหลายกรณี ที่เก็บไม่มีความรู้โดยตรงเกี่ยวกับบัญชี Google แต่บัญชีในเครื่องจะแสดงถึงผู้ใช้ หรือผู้ใช้จะใช้การลงชื่อเข้าใช้แบบรวมกับผู้ให้บริการข้อมูลประจำตัว การระบุตัวตนนี้ซึ่งไม่ใช่ที่อยู่อีเมลเรียกว่ารหัสภายนอก

แหล่งที่มาของข้อมูลประจำตัวที่สร้างขึ้นโดยใช้คอนโซลผู้ดูแลระบบจะช่วยเชื่อมช่องว่างระหว่างระบบข้อมูลประจำตัวโดยทำสิ่งต่อไปนี้

ใช้แหล่งที่มาของข้อมูลประจำตัวในกรณีต่อไปนี้

  • ที่เก็บไม่ทราบอีเมลหลักของผู้ใช้ใน Google Workspace หรือ Google Cloud Directory
  • ที่เก็บจะกำหนดกลุ่มควบคุมการเข้าถึงที่ไม่ได้สอดคล้องกับกลุ่มที่อิงตามอีเมลใน Google Workspace

แหล่งที่มาของข้อมูลประจำตัวช่วยเพิ่มประสิทธิภาพด้วยการแยกการจัดทำดัชนีจากการแมปข้อมูลประจำตัว ซึ่งช่วยให้คุณเลื่อนการค้นหาผู้ใช้เมื่อสร้าง ACL และจัดทำดัชนีรายการได้

ตัวอย่างการติดตั้งใช้งาน

รูปที่ 1 แสดงองค์กรที่ใช้ทั้งที่เก็บข้อมูลในองค์กรและที่เก็บข้อมูลบนคลาวด์ โดยแต่ละรายการจะใช้รหัสภายนอกประเภทต่างๆ

ตัวอย่างการติดตั้งใช้งานระดับองค์กรที่มีข้อมูลประจำตัวประเภทต่างๆ
รูปที่ 1 ตัวอย่างการติดตั้งใช้งานระดับองค์กรที่มีข้อมูลประจำตัวประเภทต่างๆ

ที่เก็บ 1 ระบุผู้ใช้ด้วยอีเมลโดยใช้ SAML เนื่องจากทราบ อีเมลหลักใน Google Workspace หรือ Cloud Directory จึง ไม่จำเป็นต้องมีแหล่งข้อมูลประจำตัว

ที่เก็บ 2 ทำงานร่วมกับไดเรกทอรีในองค์กรและระบุผู้ใช้ตาม sAMAccountName เนื่องจากใช้แอตทริบิวต์นี้เป็นรหัสภายนอก จึงต้องมีแหล่งที่มาของข้อมูลประจำตัว

สร้างแหล่งที่มาของข้อมูลประจำตัว

หากต้องการแหล่งที่มาของข้อมูลประจำตัว โปรดดูแมปข้อมูลประจำตัวของผู้ใช้ใน Cloud Search

สร้างแหล่งที่มาของข้อมูลประจำตัวก่อนสร้างตัวเชื่อมต่อเนื้อหา คุณต้องใช้รหัสของแหล่งที่มา เพื่อสร้าง ACL และจัดทำดัชนีข้อมูล การสร้างแหล่งที่มาของข้อมูลประจำตัวยังสร้างพร็อพเพอร์ตี้ผู้ใช้ที่กำหนดเองใน Cloud Directory เพื่อจัดเก็บรหัสภายนอกด้วย ชื่อพร็อพเพอร์ตี้ใช้รูปแบบ IDENTITY_SOURCE_ID_identity

ตารางนี้แสดงแหล่งที่มาของข้อมูลประจำตัว 2 แหล่ง ได้แก่ แหล่งที่มาหนึ่งสำหรับชื่อบัญชี SAM และอีกแหล่งที่มาหนึ่งสำหรับ รหัสผู้ใช้ (uid)

แหล่งที่มาของข้อมูลประจำตัว พร็อพเพอร์ตี้ผู้ใช้ รหัสภายนอก
id1 id1_identity sAMAccountName
id2 id2_identity uid

สร้างแหล่งที่มาของข้อมูลประจำตัวสำหรับรหัสภายนอกแต่ละประเภทที่ใช้ในองค์กร

ตารางนี้แสดงลักษณะของผู้ใช้ที่มีบัญชี Google และรหัสภายนอก 2 รายการใน Cloud Directory

ผู้ใช้ อีเมล id1_identity id2_identity
Ann ann@example.com example\ann 1001

คุณสามารถอ้างอิงผู้ใช้รายเดียวกันโดยใช้รหัสใดก็ได้เหล่านี้เมื่อสร้าง ACL สำหรับ การจัดทำดัชนี

เขียน ACL ของผู้ใช้

ใช้ getUserPrincipal() หรือ getGroupPrincipal() เพื่อสร้างหลักการโดยใช้รหัสภายนอก

ตัวอย่างนี้จะดึงสิทธิ์ในไฟล์ รวมถึงผู้ใช้ที่มีสิทธิ์เข้าถึง

FilePermissionSample.java
/**
 * Sample for mapping permissions from a source repository to Cloud Search
 * ACLs. In this example, POSIX file permissions are used a the source
 * permissions.
 *
 * @return Acl
 * @throws IOException if unable to read file permissions
 */
static Acl mapPosixFilePermissionToCloudSearchAcl(Path pathToFile) throws IOException {
  // Id of the identity source for external user/group IDs. Shown here,
  // but may be omitted in the SDK as it is automatically applied
  // based on the `api.identitySourceId` configuration parameter.
  String identitySourceId = "abcdef12345";

  // Retrieve the file system permissions for the item being indexed.
  PosixFileAttributeView attributeView = Files.getFileAttributeView(
      pathToFile,
      PosixFileAttributeView.class,
      LinkOption.NOFOLLOW_LINKS);

  if (attributeView == null) {
    // Can't read, return empty ACl
    return new Acl.Builder().build();
  }

  PosixFileAttributes attrs = attributeView.readAttributes();
  // ...
}

ข้อมูลโค้ดนี้จะสร้างหลักการสำหรับเจ้าของโดยใช้externalUserName แอตทริบิวต์

FilePermissionSample.java
// Owner, for search quality.
// Note that for principals the name is not the primary
// email address in Cloud Directory, but the local ID defined
// by the OS. Users and groups must be referred to by their
// external ID and mapped via an identity source.
List<Principal> owners = Collections.singletonList(
    Acl.getUserPrincipal(attrs.owner().getName(), identitySourceId)
);

ข้อมูลโค้ดนี้จะสร้างหลักการสำหรับผู้อ่าน

FilePermissionSample.java
// List of users to grant access to
List<Principal> readers = new ArrayList<>();

// Add owner, group, others to readers list if permissions
// exist. For this example, other is mapped to everyone
// in the organization.
Set<PosixFilePermission> permissions = attrs.permissions();
if (permissions.contains(PosixFilePermission.OWNER_READ)) {
  readers.add(Acl.getUserPrincipal(attrs.owner().getName(), identitySourceId));
}
if (permissions.contains(PosixFilePermission.GROUP_READ)) {
  String externalGroupName = attrs.group().getName();
  Principal group = Acl.getGroupPrincipal(externalGroupName, identitySourceId);
  readers.add(group);
}
if (permissions.contains(PosixFilePermission.OTHERS_READ)) {
  Principal everyone = Acl.getCustomerPrincipal();
  readers.add(everyone);
}

เมื่อมีผู้อ่านและเจ้าของแล้ว ให้สร้าง ACL โดยทำดังนี้

FilePermissionSample.java
// Build the Cloud Search ACL. Note that inheritance of permissions
// from parents is omitted. See `setInheritFrom()` and `setInheritanceType()`
// methods on the builder if required by your implementation.
Acl acl = new Acl.Builder()
    .setReaders(readers)
    .setOwners(owners)
    .build();

REST API ใช้รูปแบบ identitysources/IDENTITY_SOURCE_ID/users/EXTERNAL_ID id1_identity ของ Ann เปลี่ยนเป็น identitysources/id1_identity/users/example/ann นี่คือรหัสกลางของผู้ใช้

ดูข้อมูลเพิ่มเติมเกี่ยวกับการสร้าง ACL ของที่เก็บได้ที่ ACL

แมปกลุ่ม

แหล่งที่มาของข้อมูลระบุตัวตนยังทำหน้าที่เป็นเนมสเปซสำหรับกลุ่ม ACL ด้วย ใช้เพื่อสร้าง และแมปกลุ่มที่ใช้เพื่อความปลอดภัยเท่านั้นหรือเฉพาะที่ในที่เก็บ

ใช้ Cloud Identity Groups API เพื่อสร้างกลุ่มและจัดการการเป็นสมาชิก เชื่อมโยงกลุ่มกับแหล่งข้อมูลประจำตัวโดยใช้ชื่อแหล่งข้อมูลประจำตัวเป็นเนมสเปซ

ข้อมูลโค้ดนี้จะสร้างกลุ่ม

CreateGroupCommand.java
String namespace = "identitysources/" + idSource;
Group group = new Group()
    .setGroupKey(new EntityKey().setNamespace(namespace).setId(groupId))
    .setDescription("Demo group")
    .setDisplayName(groupName)
    .setLabels(Collections.singletonMap("system/groups/external", ""))
    .setParent(namespace);
try {
  CloudIdentity service = Utils.buildCloudIdentityService();
  Operation createOperation = service.groups().create(group).execute();

  if (createOperation.getDone()) {
    // Note: The response contains the data for a Group object, but as
    // individual fields. To convert to a Group instance, either populate
    // the fields individually or serialize & deserialize to/from JSON.
    //
    // Example:
    // String json = service.getJsonFactory().toString(response);
    // Group createdGroup =  service.getObjectParser()
    //     .parseAndClose(new StringReader(json), Group.class);
    System.out.printf("Group: %s\n",
        createOperation.getResponse().toString());
  } else {
    // Handle case where operation not yet complete, poll for
    // completion. API is currently synchronous and all operations return
    // as completed.
    // ...
  }
} catch (Exception e) {
  System.err.printf("Unable to create group: %s", e.getMessage());
  e.printStackTrace(System.err);
}

สร้าง ACL ของกลุ่ม

ใช้ getGroupPrincipal() เพื่อสร้างหลักการของกลุ่มที่มีรหัสภายนอก จากนั้นสร้าง ACL ดังนี้

FilePermissionSample.java
if (permissions.contains(PosixFilePermission.GROUP_READ)) {
  String externalGroupName = attrs.group().getName();
  Principal group = Acl.getGroupPrincipal(externalGroupName, identitySourceId);
  readers.add(group);
}

เครื่องมือเชื่อมต่อข้อมูลประจำตัว

ผู้ใช้จะดูรายการในผลการค้นหาไม่ได้จนกว่ารหัสภายนอกจะเปลี่ยนเป็น รหัส Google ใน Cloud Directory คุณตรวจสอบได้ 3 วิธีดังนี้

ตัวเชื่อมต่อข้อมูลประจำตัวจะแมปรหัสภายนอกจากข้อมูลประจำตัวขององค์กรกับข้อมูลประจำตัวภายในของ Google หากสร้างแหล่งข้อมูลประจำตัว คุณต้องสร้าง เครื่องมือเชื่อมต่อข้อมูลประจำตัวด้วย

Google Cloud Directory Sync (GCDS) เป็นตัวอย่างของตัวเชื่อมต่อข้อมูลประจำตัว โดยจะแมปข้อมูลผู้ใช้และกลุ่ม จาก Active Directory ไปยัง Cloud Directory

ซิงค์ข้อมูลประจำตัวโดยใช้ REST API

ใช้วิธี update เพื่อซิงค์ข้อมูลประจำตัว

แมปข้อมูลประจำตัวใหม่

หลังจากแมปข้อมูลระบุตัวตนใหม่แล้ว คุณต้องจัดทำดัชนีรายการอีกครั้งเพื่อให้การเปลี่ยนแปลงมีผล

  • หากนำการแมปผู้ใช้ออกหรือเปลี่ยนการแมปผู้ใช้ การแมปเดิมจะยังคงอยู่จนกว่าจะมีการ จัดทำดัชนีอีกครั้ง
  • หากลบกลุ่มที่แมปไว้และสร้างกลุ่มใหม่โดยใช้groupKeyเดียวกัน ระบบจะไม่ให้สิทธิ์เข้าถึงจนกว่าคุณจะจัดทำดัชนีอีกครั้ง