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));
        }
        public object Get()
        {
            // Check if the scope of the request is for site or application
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            return(WindowsAuthenticationHelper.ToJsonModel(site, path));
        }
Example #3
0
        public async Task <object> Post()
        {
            if (WindowsAuthenticationHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(WindowsAuthenticationHelper.FEATURE_NAME);
            }

            await WindowsAuthenticationHelper.SetFeatureEnabled(true);

            dynamic auth = WindowsAuthenticationHelper.ToJsonModel(null, null);

            return(Created(WindowsAuthenticationHelper.GetLocation(auth.id), auth));
        }
Example #4
0
        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();
        }
Example #6
0
        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));
        }