mirror of
https://github.com/bitwarden/server
synced 2025-12-17 16:53:23 +00:00
* chore: remove fc refs in CreateGroup and UpdateGroup commands, refs AC-2646 * chore: remove fc refs and update interface to represent usage/get rid of double enumeration warnings, refs AC-2646 * chore: remove org/provider service fc callers, refs AC-2646 * chore: remove collection service fc callers, refs AC-2646 * chore: remove cipher service import ciphers fc callers, refs AC-2646 * fix: UpdateOrganizationUserCommandTests collections to list, refs AC-2646 * fix: update CreateGroupCommandTests, refs AC-2646 * fix: adjust UpdateGroupCommandTests, refs AC-2646 * fix: adjust UpdateOrganizationUserCommandTests for FC always true, refs AC-2646 * fix: update CollectionServiceTests, refs AC-2646 * fix: remove unnecessary test with fc disabled, refs AC-2646 * fix: update tests to account for AccessAll removal and Manager removal, refs AC-2646 * chore: remove dependence on FC flag for tests, refs AC-2646
67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using Bit.Core.AdminConsole.Enums;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Business;
|
|
using Bit.Core.Models.Data;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Scim.Models;
|
|
|
|
public class ScimUserRequestModel : BaseScimUserModel
|
|
{
|
|
public ScimUserRequestModel()
|
|
: base(false)
|
|
{ }
|
|
|
|
public OrganizationUserInvite ToOrganizationUserInvite(ScimProviderType scimProvider)
|
|
{
|
|
return new OrganizationUserInvite
|
|
{
|
|
Emails = new[] { EmailForInvite(scimProvider) },
|
|
|
|
// Permissions cannot be set via SCIM so we use default values
|
|
Type = OrganizationUserType.User,
|
|
Collections = new List<CollectionAccessSelection>(),
|
|
Groups = new List<Guid>()
|
|
};
|
|
}
|
|
|
|
private string EmailForInvite(ScimProviderType scimProvider)
|
|
{
|
|
var email = PrimaryEmail?.ToLowerInvariant();
|
|
|
|
if (!string.IsNullOrWhiteSpace(email))
|
|
{
|
|
return email;
|
|
}
|
|
|
|
switch (scimProvider)
|
|
{
|
|
case ScimProviderType.AzureAd:
|
|
return UserName?.ToLowerInvariant();
|
|
default:
|
|
email = WorkEmail?.ToLowerInvariant();
|
|
if (string.IsNullOrWhiteSpace(email))
|
|
{
|
|
email = Emails?.FirstOrDefault()?.Value?.ToLowerInvariant();
|
|
}
|
|
|
|
return email;
|
|
}
|
|
}
|
|
|
|
public string ExternalIdForInvite()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(ExternalId))
|
|
{
|
|
return ExternalId;
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(UserName))
|
|
{
|
|
return UserName;
|
|
}
|
|
|
|
return CoreHelpers.RandomString(15);
|
|
}
|
|
}
|