コード例 #1
0
        private async ValueTask <CasbinSamModel> GetSamModelAsync(string scopeId)
        {
            if (_casbinModelCache.TryGetModel(scopeId, out var samModel))
            {
                return(samModel);
            }

            samModel = new CasbinSamModel(scopeId, CoreEnforcer.NewModel(),
                                          await _versionTokenProvider.GenerateVersionTokenAsync());

            return(_casbinModelCache.AddOrUpdateModel(scopeId, samModel));
        }
コード例 #2
0
 private async Task UpdateVersionTokenAsync(string scopeId, CasbinSamModel samModel)
 {
     samModel = new CasbinSamModel(scopeId, samModel.Model,
                                   await _versionTokenProvider.GenerateVersionTokenAsync(samModel));
     _casbinModelCache.AddOrUpdateModel(scopeId, samModel);
 }
コード例 #3
0
 private Enforcer GetEnforcer(string scopeId, CasbinSamModel samModel)
 {
     _enforcer.SetModel(samModel.Model);
     _enforcer.SetAdapter(_samAdapterProvider.GetAdapter(scopeId));
     return(_enforcer);
 }