Esempio n. 1
0
        private void ConfigureAuthentication()
        {
            var router = Environment.Host.RouteBuilder;
            var hal    = Environment.Hal;

            //
            // Route
            router.MapWebApiRoute(Defines.AuthenticationResource.Guid, $"{Defines.AUTHENTICATION_PATH}/{{id}}", new { controller = "authentication" });

            //
            // Hal
            hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.AuthenticationResource.Name, _ => {
                var id = new AuthenticationId(null, null);
                return(new { href = $"/{Defines.AUTHENTICATION_PATH}/{id.Uuid}" });
            });

            hal.ProvideLink(Sites.Defines.Resource.Guid, Defines.AuthenticationResource.Name, site => {
                var siteId = new SiteId((string)site.id);
                var id     = new AuthenticationId(siteId.Id, "/");
                return(new { href = $"/{Defines.AUTHENTICATION_PATH}/{id.Uuid}" });
            });

            hal.ProvideLink(Applications.Defines.Resource.Guid, Defines.AuthenticationResource.Name, app => {
                var appId = new ApplicationId((string)app.id);
                var id    = new AuthenticationId(appId.SiteId, appId.Path);
                return(new { href = $"/{Defines.AUTHENTICATION_PATH}/{id.Uuid}" });
            });
        }
Esempio n. 2
0
        public object Get(string id)
        {
            var authId = new AuthenticationId(id);

            Site site = authId.SiteId == null ? null : SiteHelper.GetSite(authId.SiteId.Value);

            var obj = new {
                id      = authId.Uuid,
                scope   = site == null ? string.Empty : site.Name + authId.Path,
                website = site == null ? null : SiteHelper.ToJsonModelRef(site)
            };

            return(Environment.Hal.Apply(Defines.AuthenticationResource.Guid, obj));
        }
Esempio n. 3
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            var id = new AuthenticationId(site?.Id, path);

            var obj = new {
                id      = id.Uuid,
                scope   = site == null ? string.Empty : site.Name + path,
                website = site == null ? null : SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.AuthenticationResource.Guid, obj));
        }
Esempio n. 4
0
        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}" });
            });
        }