Ejemplo n.º 1
0
        public virtual async Task EnsureUserEnterprise(EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr,
                                                       SecurityManagerClient secMgr, string parentEntLookup, string username)
        {
            if (State.UserEnterpriseLookup.IsNullOrEmpty())
            {
                var hostLookup = $"{parentEntLookup}|{username}";

                var getResp = await entMgr.ResolveHost(hostLookup, false);

                if (!getResp.Status || getResp.Model == null)
                {
                    var createResp = await entArch.CreateEnterprise(new CreateEnterpriseRequest()
                    {
                        Name        = username,
                        Description = username,
                        Host        = hostLookup
                    }, parentEntLookup, username);

                    if (createResp.Status)
                    {
                        State.UserEnterpriseLookup = createResp.Model.EnterpriseLookup;
                    }
                }
                else
                {
                    State.UserEnterpriseLookup = getResp.Model.EnterpriseLookup;
                }
            }

            if (State.UserEnterpriseLookup.IsNullOrEmpty())
            {
                throw new Exception("Unable to establish the user's enterprise, please try again.");
            }
        }
        public RequestUserAccess(ApplicationManagerClient appMgr, SecurityManagerClient secMgr, IdentityManagerClient idMgr)
        {
            this.idMgr = idMgr;

            this.secMgr = secMgr;

            this.appMgr = appMgr;
        }
Ejemplo n.º 3
0
        public MonitorApiClients(string username, string password)
        {
            _discoveryClient = new DiscoveryClient("http://localhost:53931/");
            _context         = _discoveryClient.GetServerAPIContext();

            _securityClient = new SecurityManagerClient(_context.SecurityManagementAPIAddress);
            RequestToken(username, password);
        }
Ejemplo n.º 4
0
        public ForgeInfrastructureStateHarness(HttpRequest req, ILogger logger, ForgeInfrastructureState state)
            : base(req, logger, state)
        {
            devOpsArch = req.ResolveClient <DevOpsArchitectClient>(logger);

            entMgr = req.ResolveClient <EnterpriseManagerClient>(logger);

            secMgr = req.ResolveClient <SecurityManagerClient>(logger);
        }
Ejemplo n.º 5
0
        public virtual async Task GetFathymDashboardURL(SecurityManagerClient secMgr, string entLookup)
        {
            var tpdResp = await secMgr.RetrieveEnterpriseThirdPartyData(entLookup, FATHYM_DASHBOARD_URL_LOOKUP);

            if (tpdResp.Status)
            {
                State.FathymDashboardURL = tpdResp.Model[FATHYM_DASHBOARD_URL_LOOKUP];
            }
        }
Ejemplo n.º 6
0
        public virtual async Task SetFathymDashboardURL(SecurityManagerClient secMgr, string entLookup, string url)
        {
            State.FathymDashboardURL = url;

            await secMgr.SetEnterpriseThirdPartyData(entLookup, new Dictionary <string, string>()
            {
                { FATHYM_DASHBOARD_URL_LOOKUP, url }
            });
        }
        public CompletePayment(EnterpriseManagerClient entMgr, SecurityManagerClient secMgr, IdentityManagerClient idMgr)
        {
            billingEntApiKey = Environment.GetEnvironmentVariable("LCU-BILLING-ENTERPRISE-API-KEY");

            this.entMgr = entMgr;

            this.idMgr = idMgr;

            this.secMgr = secMgr;
        }
        public Refresh(EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr, SecurityManagerClient secMgr)
        {
            billingEntApiKey = Environment.GetEnvironmentVariable("LCU-BILLING-ENTERPRISE-API-KEY");

            this.entArch = entArch;

            this.entMgr = entMgr;

            this.secMgr = secMgr;
        }
        public virtual async Task EnsureUserEnterprise(EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr,
                                                       SecurityManagerClient secMgr, string parentEntLookup, string username)
        {
            if (State.UserEnterpriseLookup.IsNullOrEmpty())
            {
                await DesignOutline.Instance.Retry()
                .SetActionAsync(async() =>
                {
                    try
                    {
                        var hostLookup = $"{parentEntLookup}|{username}";

                        log.LogInformation($"Ensuring user enterprise for {hostLookup}...");

                        var getResp = await entMgr.ResolveHost(hostLookup, false);

                        if (!getResp.Status || getResp.Model == null)
                        {
                            var createResp = await entArch.CreateEnterprise(new CreateEnterpriseRequest()
                            {
                                Name        = username,
                                Description = username,
                                Host        = hostLookup
                            }, parentEntLookup, username);

                            if (createResp.Status)
                            {
                                State.UserEnterpriseLookup = createResp.Model.EnterpriseLookup;
                            }
                        }
                        else
                        {
                            State.UserEnterpriseLookup = getResp.Model.EnterpriseLookup;
                        }

                        return(State.UserEnterpriseLookup.IsNullOrEmpty());
                    }
                    catch (Exception ex)
                    {
                        log.LogError(ex, "Failed ensuring user enterprise");

                        return(true);
                    }
                })
                .SetCycles(5)
                .SetThrottle(25)
                .SetThrottleScale(2)
                .Run();
            }

            if (State.UserEnterpriseLookup.IsNullOrEmpty())
            {
                throw new Exception("Unable to establish the user's enterprise, please try again.");
            }
        }
Ejemplo n.º 10
0
        public Refresh(EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr, IdentityManagerClient idMgr,
                       SecurityManagerClient secMgr)
        {
            this.entArch = entArch;

            this.entMgr = entMgr;

            this.idMgr = idMgr;

            this.secMgr = secMgr;
        }
        public Refresh(ApplicationManagerClient appMgr, EnterpriseManagerClient entMgr, IdentityManagerClient idMgr,
                       SecurityManagerClient secMgr)
        {
            this.appMgr = appMgr;

            this.entMgr = entMgr;

            this.idMgr = idMgr;

            this.secMgr = secMgr;
        }
        public virtual async Task <Status> RequestAuthorization(SecurityManagerClient secMgr, ApplicationManagerClient appMgr, IdentityManagerClient idMgr, string userID, string enterpriseID, string hostName)
        {
            // Create an access request
            var accessRequest = new AccessRequest()
            {
                User         = userID,
                EnterpriseID = enterpriseID
            };

            // Create JToken to attached to metadata model
            var model = new MetadataModel();

            model.Metadata.Add(new KeyValuePair <string, JToken>("AccessRequest", JToken.Parse(Newtonsoft.Json.JsonConvert.SerializeObject(accessRequest))));

            // Create token model - is including the access request payload redundant??
            var tokenModel = new CreateTokenModel()
            {
                Payload        = model,
                UserEmail      = userID,
                OrganizationID = enterpriseID,
                Encrypt        = true
            };

            // Encrypt user email and enterpries ID, generate token
            var response = await secMgr.CreateToken("RequestAccessToken", tokenModel);

            // Build grant/deny links and text body
            if (response != null)
            {
                string grantLink = $"<a href=\"{hostName}/grant/token?={response.Model}\">Grant Access</a>";
                string denyLink  = $"<a href=\"{hostName}/deny/token?={response.Model}\">Deny Access</a>";
                string emailHtml = $"A user has requested access to this Organization : {grantLink} {denyLink}";

                // Send email from app manager client

                var email = new AccessRequestEmail()
                {
                    Content      = emailHtml,
                    EmailFrom    = "*****@*****.**",
                    EmailTo      = "*****@*****.**",
                    User         = userID,
                    Subject      = "Access authorization requested",
                    EnterpriseID = enterpriseID
                };

                var emailModel = new MetadataModel();
                model.Metadata.Add(new KeyValuePair <string, JToken>("AccessRequestEmail", JToken.Parse(JsonConvert.SerializeObject(email))));

                appMgr.SendAccessRequestEmail(model, enterpriseID);
            }

            // If successful, adjust state to reflect that a request was sent for this enterprise by this user
            return(Status.Success);
        }
Ejemplo n.º 13
0
        public virtual async Task CompletePayment(EnterpriseManagerClient entMgr, SecurityManagerClient secMgr, IdentityManagerClient idMgr, string entApiKey,
                                                  string username, string methodId, string customerName, string plan, int trialPeriodDays)
        {
            State.CustomerName = customerName;

            State.PaymentMethodID = methodId;

            // var completeResp = await entMgr.Post<CompleteStripeSubscriptionRequest, CompleteStripeSubscriptionResponse>($"billing/{entApiKey}/stripe/subscription",
            var completeResp = await entMgr.CompleteStripeSubscription(entApiKey,
                                                                       new CompleteStripeSubscriptionRequest()
            {
                CustomerName    = State.CustomerName,
                PaymentMethodID = methodId,
                Plan            = plan,
                TrialPeriodDays = trialPeriodDays,
                Username        = username
            });

            State.PaymentStatus = completeResp.Status;

            if (State.PaymentStatus)
            {
                State.PurchasedPlanLookup = plan;

                var resp = await secMgr.SetIdentityThirdPartyData(entApiKey, username, new Dictionary <string, string>()
                {
                    { "LCU-USER-BILLING.TermsOfService", DateTimeOffset.UtcNow.ToString() },
                    { "LCU-USER-BILLING.EnterpriseAgreement", DateTimeOffset.UtcNow.ToString() }
                });

                var planOption = this.State.Plans.First(p => p.Lookup == plan);

                var licenseType = planOption.Metadata["LicenseType"].ToString();

                var token = planOption.JSONConvert <LicenseAccessToken>();

                token.EnterpriseAPIKey = entApiKey;

                token.Lookup = licenseType;

                token.AccessStartDate = DateTime.Now;

                token.TrialPeriodDays = trialPeriodDays;

                token.Username = username;

                var setLicenseAccessResp = await idMgr.IssueLicenseAccess(token, entApiKey);

                State.PaymentStatus = setLicenseAccessResp.Status;

                State.SuccessRedirect = licenseType == "lcu" ? "/workspace/new" : "https://forecast.fathym-it.com/";
            }
        }
Ejemplo n.º 14
0
        public virtual async Task Refresh(IDurableOrchestrationClient starter, StateDetails stateDetails, ExecuteActionRequest exActReq,
                                          ApplicationArchitectClient appArch, EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr, IdentityManagerClient idMgr,
                                          SecurityManagerClient secMgr, DocumentClient client)
        {
            // await EnsureUserEnterprise(entArch, entMgr, secMgr, stateDetails.EnterpriseLookup, stateDetails.Username);

            State.Loading = false;

            State.HomePage.Loading = false;

            State.SSL.Loading = false;
        }
Ejemplo n.º 15
0
        public virtual async Task SaveGlobalAppSettings(SecurityManagerClient secMgr, string entLookup, GlobalApplicationSettings settings)
        {
            log.LogInformation($"Saving global app settings {entLookup} at {State.ActiveHost}: {settings.ToJSON()}");

            await settings.Metadata.Each(async (setting) =>
            {
                var resp = await secMgr.SetEnterpriseThirdPartyData(entLookup, new Dictionary <string, string>()
                {
                    { $"{State.ActiveHost}:{setting.Key}", setting.Value.ToString() }
                });

                return(!resp.Status);
            });

            await LoadGlobalAppSettings(secMgr, entLookup);
        }
Ejemplo n.º 16
0
        public virtual async Task DetermineRequiredOptIns(SecurityManagerClient secMgr, string entApiKey, string username)
        {
            var thirdPartyData = await secMgr.RetrieveIdentityThirdPartyData(entApiKey, username, "LCU-USER-BILLING.TermsOfService", "LCU-USER-BILLING.EnterpriseAgreement");

            State.RequiredOptIns = new List <string>();

            if (!thirdPartyData.Status || !thirdPartyData.Model.ContainsKey("LCU-USER-BILLING.TermsOfService"))
            {
                State.RequiredOptIns.Add("ToS");
            }

            if (!thirdPartyData.Status || !thirdPartyData.Model.ContainsKey("LCU-USER-BILLING.EnterpriseAgreement"))
            {
                State.RequiredOptIns.Add("EA");
            }
        }
Ejemplo n.º 17
0
        public virtual async Task Refresh(EnterpriseManagerClient entMgr, SecurityManagerClient secMgr, string entApiKey, string username, string licenseType)
        {
            ResetStateCheck();

            await LoadBillingPlans(entMgr, entApiKey, licenseType);

            var ltName = licenseType == "lcu" ? "Fathym Framework" : licenseType == "forecast" ? "Fathym Forecast" : "";

            State.LicenseType = new LicenseTypeDetails()
            {
                Lookup = licenseType,
                Name   = ltName
            };

            SetUsername(username);

            await DetermineRequiredOptIns(secMgr, entApiKey, username);
        }
        public virtual async Task <Status> Refresh(EnterpriseArchitectClient entArch, EnterpriseManagerClient entMgr,
                                                   IdentityManagerClient idMgr, SecurityManagerClient secMgr, StateDetails stateDetails)
        {
            await EnsureUserEnterprise(entArch, entMgr, secMgr, stateDetails.EnterpriseLookup, stateDetails.Username);

            await Task.WhenAll(
                HasLicenseAccess(idMgr, stateDetails.EnterpriseLookup, stateDetails.Username)
                );

            await Task.WhenAll(
                EnsureAPISubscription(entArch, stateDetails.EnterpriseLookup, stateDetails.Username),
                LoadAPIOptions()
                );

            State.Loading = false;

            return(Status.Success);
        }
Ejemplo n.º 19
0
        public virtual async Task Refresh(ApplicationManagerClient appMgr, EnterpriseManagerClient entMgr, IdentityManagerClient idMgr,
                                          SecurityManagerClient secMgr, string entLookup, string host)
        {
            log.LogInformation($"Refreshing data apps management state for {entLookup} at {State.ActiveHost}");

            // if (State.ActiveHost.IsNullOrEmpty())
            SetActiveHost(host);

            await LoadApplications(appMgr, entLookup);

            await Task.WhenAll(
                LoadAccessRightOptions(idMgr, entLookup),
                LoadDAFAppOptions(appMgr, entLookup),
                LoadGlobalAppSettings(secMgr, entLookup),
                RefreshZipOptions(appMgr, entMgr, entLookup)
                );

            await LoadSupportedDAFAppTypes();
        }
Ejemplo n.º 20
0
        public virtual async Task LoadGlobalAppSettings(SecurityManagerClient secMgr, string entLookup)
        {
            log.LogInformation($"Loading global app settings {entLookup}");

            var lookups = new[] {
                $"{State.ActiveHost}:GOOGLE-ANALYTICS-MEASUREMENT-ID",
                $"{State.ActiveHost}:GOOGLE-TAG-MANAGER-ID",
                $"{State.ActiveHost}:ORIBI-ANALYTICS-TRACKING-ID"
            };

            var resp = await secMgr.RetrieveEnterpriseThirdPartyData(entLookup, lookups);

            State.GlobalAppSettings = new GlobalApplicationSettings();

            resp.Model.Each(setting =>
            {
                if (!setting.Value.IsNullOrEmpty())
                {
                    State.GlobalAppSettings.Metadata[setting.Key.Replace($"{State.ActiveHost}:", String.Empty)] = setting.Value;
                }
            });
        }
 public SaveGlobalAppSettings(SecurityManagerClient secMgr)
 {
     this.secMgr = secMgr;
 }
Ejemplo n.º 22
0
        public ResetStateCheck(EnterpriseManagerClient entMgr, SecurityManagerClient secMgr)
        {
            this.entMgr = entMgr;

            this.secMgr = secMgr;
        }
Ejemplo n.º 23
0
 public Refresh(SecurityManagerClient secMgr)
 {
     this.secMgr = secMgr;
 }
 public SaveFathymDashboardURL(SecurityManagerClient secMgr)
 {
     this.secMgr = secMgr;
 }