public static OAuth2Client ToClient(this OAuthProvider oAuthProvider) { using (var securityBypass = new SecurityBypass(true)) { var oAuthBase = oAuthProvider.ToBase(); return(oAuthBase.GetClient()); } }
private void SetInstalledPlugins(Service service, IEnumerable <string> plugins) { using (var securityBypass = new SecurityBypass(service)) { service.Variables["CM:InstalledPlugins"] = string.Join(",", plugins); service.Save(); } }
public async Task <ActionResult> Login(int id) { using (var securityBypass = new SecurityBypass(true)) { var provider = DynamicTypeBase.GetCurrent <OAuthProvider>(); Console.WriteLine(provider.GetType()); var guid = Guid.NewGuid(); var oAuthRequestState = new OAuthRequestState { Provider = provider, RequestLoginState = TCAdmin.SDK.Session.IsAuthenticated() ? OAuthRequestLoginState.Link : OAuthRequestLoginState.Login, UserId = TCAdmin.SDK.Session.IsAuthenticated() ? TCAdmin.SDK.Session.GetCurrentUser().UserId : -1 }; OAuthRequests.Add(guid, oAuthRequestState); var redirectUri = new Uri(await provider.ToClient().GetLoginLinkUriAsync(guid.ToString())); return(Redirect(redirectUri.ToString())); } }
public static void DeleteSubdomainForService(DnsProvider dnsProvider, Service service) { var zone = dnsProvider.GetZone(service.Variables["SD-ZoneId"].ToString(), ZoneSearchType.Id); var domainName = Globals.DomainParser.Get(service.Variables["SD-FullSubDomain"].ToString()); var removed = dnsProvider.RemoveZone(zone, domainName.SubDomain); if (removed) { using (var securityBypass = new SecurityBypass(service)) { service.Variables.RemoveValue("SD-FullSubDomain"); service.Variables.RemoveValue("SD-ZoneId"); service.Variables.RemoveValue("SD-DnsProvider"); service.Save(); } return; } throw new SubdomainException($"Failed to delete <strong>{domainName.Hostname}</strong> subdomain."); }
public static void CreateSubdomainForService(DnsProvider dnsProvider, Service service, string subdomain, string baseDomain) { subdomain = ParseSubdomain(subdomain); if (IsIllegal(subdomain)) { throw new SubdomainException($"<strong>Illegal Subdomain - {subdomain}</strong>"); } if (!dnsProvider.ZoneExists(baseDomain, ZoneSearchType.Id)) { throw new SubdomainException($"<strong>Invalid Zone</strong>"); } var zone = dnsProvider.GetZone(baseDomain, ZoneSearchType.Id); if (!dnsProvider.SubdomainAvailable(zone, subdomain)) { throw new SubdomainException($"<strong>{subdomain}.{zone.Name}</strong> is already taken!"); } var created = dnsProvider.AddZone(zone, subdomain, service.PublicIpAddress); if (created) { using (var securityBypass = new SecurityBypass(service)) { service.Variables["SD-FullSubDomain"] = $"{subdomain}.{zone.Name}"; service.Variables["SD-ZoneId"] = $"{zone.Id}"; service.Variables["SD-DnsProvider"] = dnsProvider.DnsProviderType.DnsProviderId; service.Save(); } return; } throw new SubdomainException($"Failed to create <strong>{subdomain}.{zone.Name}</strong> subdomain."); }