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)); }
private async Task UpdateVersionTokenAsync(string scopeId, CasbinSamModel samModel) { samModel = new CasbinSamModel(scopeId, samModel.Model, await _versionTokenProvider.GenerateVersionTokenAsync(samModel)); _casbinModelCache.AddOrUpdateModel(scopeId, samModel); }
private Enforcer GetEnforcer(string scopeId, CasbinSamModel samModel) { _enforcer.SetModel(samModel.Model); _enforcer.SetAdapter(_samAdapterProvider.GetAdapter(scopeId)); return(_enforcer); }