예제 #1
0
        public async Task <ProviderRegistration> RunActivity(
            [ActivityTrigger] ProviderRegisterCommand command,
            ILogger log)
        {
            if (command is null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            using (log.BeginCommandScope(command))
            {
                try
                {
                    var identity = await azureSessionService
                                   .GetIdentityAsync()
                                   .ConfigureAwait(false);

                    var registration = new ProviderRegistration
                    {
                        PrincipalId = identity?.ObjectId
                    };

                    return(registration);
                }
                catch (Exception exc)
                {
                    log.LogError(exc, $"{nameof(ProviderRegisterActivity)} failed: {exc.Message}");

                    throw exc.AsSerializable();
                }
            }
        }
        private async Task <string> GetOrchestratorIdentityAsync()
        {
            var identity = await azureSessionService
                           .GetIdentityAsync()
                           .ConfigureAwait(false);

            return(identity.ObjectId.ToString());
        }
예제 #3
0
    private async Task <User> GetCommandUserAsync(Guid organizationId, string organizationName)
    {
        var identity = await azureSessionService
                       .GetIdentityAsync()
                       .ConfigureAwait(false);

        return(new User()
        {
            Id = identity.ObjectId.ToString(),
            Organization = organizationId.ToString(),
            OrganizationName = organizationName
        });
    }
예제 #4
0
        public async Task <User> RunActivity(
            [ActivityTrigger] IDurableActivityContext functionContext)
        {
            if (functionContext is null)
            {
                throw new System.ArgumentNullException(nameof(functionContext));
            }

            var systemIdentity = await azureSessionService
                                 .GetIdentityAsync()
                                 .ConfigureAwait(false);

            return(new User()
            {
                Id = systemIdentity.ObjectId,
                Role = UserRoles.TeamCloud.Admin
            });
        }
예제 #5
0
        public async Task <UserDocument> RunActivity(
            [ActivityTrigger] IDurableActivityContext activityContext)
        {
            if (activityContext is null)
            {
                throw new System.ArgumentNullException(nameof(activityContext));
            }

            var systemIdentity = await azureSessionService
                                 .GetIdentityAsync()
                                 .ConfigureAwait(false);

            return(new UserDocument()
            {
                Id = systemIdentity.ObjectId.ToString(),
                Role = TeamCloudUserRole.None,
                UserType = UserType.System
            });
        }
        private async Task EnsureKeyVaultAccessAsync(Project project, Guid principalId)
        {
            var keyVault = await azureResourceService
                           .GetResourceAsync <AzureKeyVaultResource>(project.KeyVault.VaultId, throwIfNotExists : true)
                           .ConfigureAwait(false);

            if (keyVault != null)
            {
                var systemIdentity = await azureSessionService
                                     .GetIdentityAsync()
                                     .ConfigureAwait(false);

                if (systemIdentity.ObjectId == principalId)
                {
                    await keyVault
                    .SetAllCertificatePermissionsAsync(principalId)
                    .ConfigureAwait(false);

                    await keyVault
                    .SetAllKeyPermissionsAsync(principalId)
                    .ConfigureAwait(false);

                    await keyVault
                    .SetAllSecretPermissionsAsync(principalId)
                    .ConfigureAwait(false);
                }
                else
                {
                    await keyVault
                    .SetCertificatePermissionsAsync(principalId, CertificatePermissions.Get, CertificatePermissions.List)
                    .ConfigureAwait(false);

                    await keyVault
                    .SetKeyPermissionsAsync(principalId, KeyPermissions.Get, KeyPermissions.List)
                    .ConfigureAwait(false);

                    await keyVault
                    .SetSecretPermissionsAsync(principalId, SecretPermissions.Get, SecretPermissions.List)
                    .ConfigureAwait(false);
                }
            }
        }
예제 #7
0
        public async Task <ProviderRegistration> RunActivity(
            [ActivityTrigger] ProviderRegisterCommand command,
            ILogger log)
        {
            if (command is null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var identity = await azureSessionService
                           .GetIdentityAsync()
                           .ConfigureAwait(false);

            var registration = new ProviderRegistration
            {
                PrincipalId = identity?.ObjectId
            };

            return(registration);
        }