Esempio n. 1
0
        public async Task RevokeTenantTokenToThisNode(RevokeTenantTokenDetails revokeTenantTokenDetails)
        {
            if (_tenantRepository.GetTenantToken(revokeTenantTokenDetails.Tenant, revokeTenantTokenDetails.Token) != null)
            {
                _tenantApiService.RevokeToken(revokeTenantTokenDetails.Tenant, revokeTenantTokenDetails.Token);
            }

            // send to other nodes....
            await _storageHubService.SendRevokeTenantTokenStorage(revokeTenantTokenDetails);
        }
Esempio n. 2
0
        public bool RevokeToken(string tenantName, string token)
        {
            // Remove from the memory
            _tenantRepository.RemoveTenantToken(tenantName, token);
            // remove from config file

            List <TenantConfiguration> tenants = TenantIOReader.ReadTenantsFromConfigFile();
            var tenant = tenants.Find(x => x.Name == tenantName);

            if (tenant == null)
            {
                return(false);
            }

            // remove from config file.
            var tenantToken = tenant.Settings.Tokens.Find(x => x.Token == token);

            if (tenantToken == null)
            {
                return(true);
            }

            tenant.Settings.Tokens.Remove(tenantToken);

            // Write into file
            if (TenantIOWriter.WriteTenantsConfiguration(tenants) == true)
            {
                // Send to the Cluster
                _storageHubService.SendRevokeTenantTokenStorage(new Model.Storages.Requests.Tenants.RevokeTenantTokenDetails()
                {
                    Tenant = tenantName,
                    Token  = token,
                    StoragesAlreadySent = new List <string>()
                });
                return(true);
            }

            return(false);
        }