Exemplo n.º 1
0
        public void SetUrls(EnvironmentUrls urls)
        {
            UrlsSet = true;
            if (!string.IsNullOrWhiteSpace(urls.Base))
            {
                ApiBaseUrl      = urls.Base + "/api";
                IdentityBaseUrl = urls.Base + "/identity";
                EventsBaseUrl   = urls.Base + "/events";
                return;
            }

            ApiBaseUrl      = urls.Api;
            IdentityBaseUrl = urls.Identity;
            EventsBaseUrl   = urls.Events;

            // Production
            if (string.IsNullOrWhiteSpace(ApiBaseUrl))
            {
                ApiBaseUrl = "https://api.bitwarden.com";
            }
            if (string.IsNullOrWhiteSpace(IdentityBaseUrl))
            {
                IdentityBaseUrl = "https://identity.bitwarden.com";
            }
            if (string.IsNullOrWhiteSpace(EventsBaseUrl))
            {
                EventsBaseUrl = "https://events.bitwarden.com";
            }
        }
Exemplo n.º 2
0
        public async Task <EnvironmentUrlData> SetUrlsAsync(EnvironmentUrlData urls)
        {
            urls.Base          = FormatUrl(urls.Base);
            urls.WebVault      = FormatUrl(urls.WebVault);
            urls.Api           = FormatUrl(urls.Api);
            urls.Identity      = FormatUrl(urls.Identity);
            urls.Icons         = FormatUrl(urls.Icons);
            urls.Notifications = FormatUrl(urls.Notifications);
            urls.Events        = FormatUrl(urls.Events);
            await _storageService.SaveAsync(Constants.EnvironmentUrlsKey, urls);

            BaseUrl          = urls.Base;
            WebVaultUrl      = urls.WebVault;
            ApiUrl           = urls.Api;
            IdentityUrl      = urls.Identity;
            IconsUrl         = urls.Icons;
            NotificationsUrl = urls.Notifications;
            EventsUrl        = urls.Events;

            var envUrls = new EnvironmentUrls();

            if (!string.IsNullOrWhiteSpace(BaseUrl))
            {
                envUrls.Base = BaseUrl;
            }
            else
            {
                envUrls.Api      = ApiUrl;
                envUrls.Identity = IdentityUrl;
                envUrls.Events   = EventsUrl;
            }

            _apiService.SetUrls(envUrls);
            return(urls);
        }
Exemplo n.º 3
0
        public async Task SetUrlsFromStorageAsync()
        {
            var urls = await _stateService.GetEnvironmentUrlsAsync();

            if (urls == null)
            {
                urls = await _stateService.GetPreAuthEnvironmentUrlsAsync();
            }
            if (urls == null)
            {
                urls = new EnvironmentUrlData();
            }
            var envUrls = new EnvironmentUrls();

            if (!string.IsNullOrWhiteSpace(urls.Base))
            {
                BaseUrl = envUrls.Base = urls.Base;
                _apiService.SetUrls(envUrls);
                return;
            }
            BaseUrl          = urls.Base;
            WebVaultUrl      = urls.WebVault;
            ApiUrl           = envUrls.Api = urls.Api;
            IdentityUrl      = envUrls.Identity = urls.Identity;
            IconsUrl         = urls.Icons;
            NotificationsUrl = urls.Notifications;
            EventsUrl        = envUrls.Events = urls.Events;
            _apiService.SetUrls(envUrls);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 初始化环境列表
 /// </summary>
 /// <param name="environmentList"></param>
 public static void InitEnvironmentUrl(List <EnvironmentListDTO> environmentList)
 {
     EnvironmentUrls = environmentList.Select(m => new KeyValueModel(m.Url, $"{m.Name}[{m.Url}]")).OrderBy(m => m.Value).ToArray();
     if (EnvironmentUrls.Count > 0)
     {
         EnvironmentUrl = EnvironmentUrls.First();
     }
 }
Exemplo n.º 5
0
 public void SetUrls(EnvironmentUrls urls)
 {
     UrlsSet = true;
     if (!string.IsNullOrWhiteSpace(urls.Base))
     {
         ApiBaseUrl      = urls.Base + "/api";
         IdentityBaseUrl = urls.Base + "/identity";
         return;
     }
     if (!string.IsNullOrWhiteSpace(urls.Api) && !string.IsNullOrWhiteSpace(urls.Identity))
     {
         ApiBaseUrl      = urls.Api;
         IdentityBaseUrl = urls.Identity;
         return;
     }
     // Local Dev
     //ApiBaseUrl = "http://localhost:4000";
     //IdentityBaseUrl = "http://localhost:33656";
     // Production
     ApiBaseUrl      = "https://api.bitwarden.com";
     IdentityBaseUrl = "https://identity.bitwarden.com";
 }
Exemplo n.º 6
0
 public SettingsAppService(IOptions <EnvironmentUrls> options)
 {
     _environmentUrls = options.Value;
 }