public object Get(string id) { WinAuthId winAuthId = new WinAuthId(id); Site site = winAuthId.SiteId == null ? null : SiteHelper.GetSite(winAuthId.SiteId.Value); return(WindowsAuthenticationHelper.ToJsonModel(site, winAuthId.Path)); }
private void ConfigureWindowsAuthentication() { var router = Environment.Host.RouteBuilder; var hal = Environment.Hal; router.MapWebApiRoute(Defines.WinAuthResource.Guid, $"{Defines.WIN_AUTH_PATH}/{{id?}}", new { controller = "winauth" }); hal.ProvideLink(Defines.WinAuthResource.Guid, "self", winAuth => new { href = $"/{Defines.WIN_AUTH_PATH}/{winAuth.id}" }); hal.ProvideLink(Defines.AuthenticationResource.Guid, Defines.WinAuthResource.Name, auth => { var authId = new AuthenticationId((string)auth.id); Site site = authId.SiteId == null ? null : SiteHelper.GetSite(authId.SiteId.Value); var winAuthId = new WinAuthId(authId.SiteId, authId.Path, WindowsAuthenticationHelper.IsSectionLocal(site, authId.Path)); return(new { href = $"/{Defines.WIN_AUTH_PATH}/{winAuthId.Uuid}" }); }); }
public void Delete(string id) { WinAuthId winAuthId = new WinAuthId(id); Context.Response.StatusCode = (int)HttpStatusCode.NoContent; Site site = (winAuthId.SiteId != null) ? SiteHelper.GetSite(winAuthId.SiteId.Value) : null; if (site == null) { return; } WindowsAuthenticationHelper.GetSection(site, winAuthId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); ManagementUnit.Current.Commit(); }
public async Task Delete(string id) { WinAuthId winAuthId = new WinAuthId(id); Context.Response.StatusCode = (int)HttpStatusCode.NoContent; Site site = (winAuthId.SiteId != null) ? SiteHelper.GetSite(winAuthId.SiteId.Value) : null; if (site != null) { WindowsAuthenticationHelper.GetSection(site, winAuthId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); ManagementUnit.Current.Commit(); } if (winAuthId.SiteId == null && WindowsAuthenticationHelper.IsFeatureEnabled()) { await WindowsAuthenticationHelper.SetFeatureEnabled(false); } }
public object Patch(string id, [FromBody] dynamic model) { WinAuthId winAuthId = new WinAuthId(id); Site site = winAuthId.SiteId == null ? null : SiteHelper.GetSite(winAuthId.SiteId.Value); // Targetting section for a site, but unable to find that site if (winAuthId.SiteId != null && site == null) { return(NotFound()); } string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model); WindowsAuthenticationHelper.UpdateSettings(model, site, winAuthId.Path, configPath); ManagementUnit.Current.Commit(); return(WindowsAuthenticationHelper.ToJsonModel(site, winAuthId.Path)); }
public static object ToJsonModel(Site site, string path) { var section = GetSection(site, path); // Construct id passing possible site and application associated WinAuthId id = new WinAuthId(site?.Id, path, section.IsLocallyStored); var obj = new { id = id.Uuid, enabled = section.Enabled, scope = site == null ? string.Empty : site.Name + path, metadata = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective), use_kernel_mode = section.UseKernelMode, token_checking = Enum.GetName(typeof(TokenChecking), section.TokenCheckingAttribute).ToLower(), providers = ProvidersJsonModel(section), website = site == null ? null : SiteHelper.ToJsonModelRef(site) }; return(Core.Environment.Hal.Apply(Defines.WinAuthResource.Guid, obj)); }