利用Kentico的许可来许可自定义模块

Ped*_*sta 6 c# kentico

我们开发了一个Kentico模块,我们希望在每个站点上进行许可.

有没有其他人试图利用内置的Kentico Licensing来达到这个目的?

我正在考虑的是在我们的服务器上有一个安全的终点,它将验证运行该模块的Kentico站点的域/许可证.

例如,如果我们的服务器中不存在域/许可证,则该模块将不会为该站点运行.

这可行吗?

Ped*_*sta 4

我想我可能已经弄清楚了这一点。

在我的模块上,我已经重写了 CheckLicense 方法,如下所示:

    public override bool CheckLicense(string domain, FeatureEnum feature, ObjectActionEnum action)
    {
        if (domain != null)
            domain = LicenseKeyInfoProvider.ParseDomainName(domain);

        int siteId = LicenseHelper.GetSiteIDbyDomain(domain);
        var licenseKey = LicenseKeyInfoProvider.GetLicenseKeyInfo(domain, FeatureEnum.Unknown);
        if (siteId > 0 && licenseKey != null)
        {
            // TODO: query external service with licenseKey.Domain for a valid license for this module
            return true;
        }

        return false;
    }
Run Code Online (Sandbox Code Playgroud)

然后我可以使用:

ModuleManager.CheckModuleLicense("My.Module.Name", RequestContext.CurrentDomain, FeatureEnum.Unknown, ObjectActionEnum.Read)
Run Code Online (Sandbox Code Playgroud)

在功能上确保模块获得正确许可。

方法重写是一种简化,我已经对外部服务请求实现了缓存,以防止每次我们想要检查权限时都必须查询服务。

我还发送了 licenseKey.Domain 因为我们不关心别名,只要主域获得许可,模块就应该在任何别名下工作。

这种方法看起来怎么样?非常感谢做过此类事情的任何人提供的反馈,以及选择的解决方案是什么?

谢谢,p。