// ReSharper disable once UnusedMember.Local private void RegisterFr8OwnTerminal(UnitOfWork uow, SecurityObjectsStorage securityObjectStorage, string devUrl, string prodUrl = null, bool isFr8OwnTerminal = true) { var terminalRegistration = new TerminalDO(); string terminalPort = ExtractPort(devUrl); devUrl = NormalizeUrl(devUrl); var existingTerminal = uow.TerminalRepository.GetAll().FirstOrDefault( x => x.DevUrl != null && (string.Equals(NormalizeUrl(x.DevUrl), devUrl, StringComparison.OrdinalIgnoreCase) || (ExtractPort(x.DevUrl) != null && ExtractPort(devUrl) != null && string.Equals(ExtractPort(x.DevUrl), terminalPort, StringComparison.OrdinalIgnoreCase) ))); if (existingTerminal != null) { //in order to avoid problems, check if permissions for terminal is already applied. If not, create those permissions securityObjectStorage.SetDefaultRecordBasedSecurityForObject(string.Empty, Roles.StandardUser, existingTerminal.Id, nameof(TerminalDO), Guid.Empty, null, new List <PermissionType>() { PermissionType.UseTerminal }); securityObjectStorage.SetDefaultRecordBasedSecurityForObject(string.Empty, Roles.Guest, existingTerminal.Id, nameof(TerminalDO), Guid.Empty, null, new List <PermissionType>() { PermissionType.UseTerminal }); return; } terminalRegistration.Id = Guid.NewGuid(); terminalRegistration.Endpoint = devUrl; terminalRegistration.DevUrl = devUrl; terminalRegistration.ProdUrl = prodUrl; terminalRegistration.IsFr8OwnTerminal = isFr8OwnTerminal; terminalRegistration.TerminalStatus = TerminalStatus.Undiscovered; terminalRegistration.ParticipationState = ParticipationState.Unapproved; uow.TerminalRepository.Add(terminalRegistration); uow.SaveChanges(); //make the terminal visible for all users securityObjectStorage.SetDefaultRecordBasedSecurityForObject(string.Empty, Roles.StandardUser, terminalRegistration.Id, nameof(TerminalDO), Guid.Empty, null, new List <PermissionType>() { PermissionType.UseTerminal }); securityObjectStorage.SetDefaultRecordBasedSecurityForObject(string.Empty, Roles.Guest, terminalRegistration.Id, nameof(TerminalDO), Guid.Empty, null, new List <PermissionType>() { PermissionType.UseTerminal }); }
private void RegisterTerminals(UnitOfWork uow, IContainer container) { // IMPORTANT: After the migrations have worked out and after you've made sure that // your terminal works fine on the target environment, you need to go to the Terminals page // and manually Approve your terminal to make it available for all users. // If you're not an Administrator, ask someone who is to approve your terminal. // Note that if you're adding a Fr8 own terminal, the URL must be port-based. // If you're adding a 3rd party terminal, one created by an external developer // or just one which is not deployed by Fr8, it may have any URL but // you need to set the Fr8OwnTerminal argument to true. For details see FR-4945. var securityObjectStorage = new SecurityObjectsStorage(uow, container.GetInstance <ISecurityObjectsCache>(), container.GetInstance <ISecurityObjectsStorageProvider>()); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:10109", "https://terminalInstagram.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:56785", "https://terminalAsana.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:46281", "https://terminalAzure.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:61121", "https://terminalBasecamp2.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:54642", "https://terminalBox.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:39504", "https://terminalSlack.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:53234", "https://terminalDocuSign.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:30700", "https://terminalNotifier.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:51234", "https://terminalSalesforce.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:50705", "https://terminalFr8Core.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:10601", "https://terminalSendGrid.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:30699", "https://terminalTwilio.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:25923", "https://terminalGoogle.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:47011", "https://terminalExcel.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:19760", "https://terminalDropbox.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:30701", "https://terminalPapertrail.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:39768", "https://terminalAtlassian.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:48317", "https://terminalQuickBooks.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:39555", "https://terminalYammer.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:50479", "https://terminalTutorial.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:48675", "https://terminalStatX.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:22666", "https://terminalFacebook.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "http://localhost:59022", "https://terminalTelegram.fr8.co"); RegisterFr8OwnTerminal(uow, securityObjectStorage, "https://terminalTwitter.fr8.co", "https://terminalTwitter.fr8.co", false); }