public object Get(string id) { DigestAuthId digestAuthId = new DigestAuthId(id); Site site = digestAuthId.SiteId == null ? null : SiteHelper.GetSite(digestAuthId.SiteId.Value); return(DigestAuthenticationHelper.ToJsonModel(site, digestAuthId.Path)); }
public object Get() { // Check if the scope of the request is for site or application Site site = ApplicationHelper.ResolveSite(); string path = ApplicationHelper.ResolvePath(); return(DigestAuthenticationHelper.ToJsonModel(site, path)); }
public async Task <object> Post() { if (DigestAuthenticationHelper.IsFeatureEnabled()) { throw new AlreadyExistsException(DigestAuthenticationHelper.FEATURE_NAME); } await DigestAuthenticationHelper.SetFeatureEnabled(true); dynamic auth = DigestAuthenticationHelper.ToJsonModel(null, null); return(Created(DigestAuthenticationHelper.GetLocation(auth.id), auth)); }
private void ConfigureDigestAuthentication() { var router = Environment.Host.RouteBuilder; var hal = Environment.Hal; router.MapWebApiRoute(Defines.DigestAuthResource.Guid, $"{Defines.DIGEST_AUTH_PATH}/{{id?}}", new { controller = "DigestAuth" }); hal.ProvideLink(Defines.DigestAuthResource.Guid, "self", digestAuth => new { href = $"/{Defines.DIGEST_AUTH_PATH}/{digestAuth.id}" }); hal.ProvideLink(Defines.AuthenticationResource.Guid, Defines.DigestAuthResource.Name, auth => { var authId = new AuthenticationId((string)auth.id); Site site = authId.SiteId == null ? null : SiteHelper.GetSite(authId.SiteId.Value); var digestAuthId = new DigestAuthId(authId.SiteId, authId.Path, DigestAuthenticationHelper.IsSectionLocal(site, authId.Path)); return(new { href = $"/{Defines.DIGEST_AUTH_PATH}/{digestAuthId.Uuid}" }); }); }
public void Delete(string id) { DigestAuthId digestAuthId = new DigestAuthId(id); Context.Response.StatusCode = (int)HttpStatusCode.NoContent; Site site = (digestAuthId.SiteId != null) ? SiteHelper.GetSite(digestAuthId.SiteId.Value) : null; if (site == null) { return; } DigestAuthenticationHelper.GetSection(site, digestAuthId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); ManagementUnit.Current.Commit(); }
public async Task Delete(string id) { DigestAuthId digestAuthId = new DigestAuthId(id); Context.Response.StatusCode = (int)HttpStatusCode.NoContent; Site site = (digestAuthId.SiteId != null) ? SiteHelper.GetSite(digestAuthId.SiteId.Value) : null; if (site != null) { DigestAuthenticationHelper.GetSection(site, digestAuthId.Path, ManagementUnit.ResolveConfigScope()).RevertToParent(); ManagementUnit.Current.Commit(); } if (digestAuthId.SiteId == null && DigestAuthenticationHelper.IsFeatureEnabled()) { await DigestAuthenticationHelper.SetFeatureEnabled(false); } }
public object Patch(string id, [FromBody] dynamic model) { DigestAuthId digestAuthId = new DigestAuthId(id); Site site = digestAuthId.SiteId == null ? null : SiteHelper.GetSite(digestAuthId.SiteId.Value); // Targetting section for a site, but unable to find that site if (digestAuthId.SiteId != null && site == null) { return(NotFound()); } string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model); DigestAuthenticationHelper.UpdateSettings(model, site, digestAuthId.Path, configPath); ManagementUnit.Current.Commit(); return(DigestAuthenticationHelper.ToJsonModel(site, digestAuthId.Path)); }