1. User security

Automate user management

Content Hub tracks and records all user actions, logging activities that can be matched with concurrent events for detailed tracking. This is especially important during onboarding and offboarding, where controlling user permissions is vital. It also supports GDPR compliance by tracking data access and user actions, via logs that provide a record of activities for auditing and security purposes.

Note

In Sitecore Content Hub, each user is uniquely identified with a username, a password, and a profile. Together with other settings, the profile determines which tasks the user can perform, what data the user can see, and what the user can do with the data.

To make it easier to work with multiple user accounts at the same time, you can automate user account management using any of the following options.

REST API

You can automate user management using the REST API.

  • Add a user with username SampleUser:

    • Method: POST

    • URL: https://my-instance.com/api/entitydefinitions/User/entities

    • Request body:

      {
       "properties":{
        "Username":"SampleUser",
        "UserGroupConfiguration":null,
        "HasToken":null,
        "EmailConfirmationPending":null,
        "LockoutEndDate":null,
        "AccessFailedCount":null,
        "IsRestricted":null,
        "LastLoginDateTime":null,
        "LastPasswordChangeDateTime":null
       },
       "entitydefinition":{
        "href":"https://my-instance.com/api/entitydefinitions/User"
       },
      }
    • Example response:

      201 created
      Content-Length: content length
      Location : https://my-instance.com/api/entities/10657
  • Delete a user with ID 10657:

    • Method: DELETE

    • URL: https://my-instance.com/api/entities/10657

    • No request body.

Scripting SDK

You can automate user management using the Users client in the Scripting SDK.

  • Add a user:

    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
  • Delete a user:

    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);

Web SDK

You can automate user management using the User client in the Web Client SDK.

  • Add a user:

    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
  • Delete a user:

    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);
If you have suggestions for improving this article, let us know!