public bool IsClientGranted(Client client, IEnumerable <string> scopeNames) { var grantDetail = GrantedClients.SingleOrDefault(gd => gd.ClientId == client.Id); if (grantDetail != null) { var grantedScopeNames = grantDetail.ScopeNames; var inputSet = new HashSet <string>(scopeNames); return(inputSet.IsSubsetOf(grantedScopeNames)); } return(false); }
public void GrantClient(Client client, IEnumerable <PermissionScope> scopes) { var grantDetail = GrantedClients.SingleOrDefault(gd => gd.ClientId == client.Id); if (grantDetail != null) { grantDetail.ScopeNames = scopes.Select(s => s.ScopeName).ToList(); } else { GrantedClients.Add(new ClientAuthorizationDetail { ClientId = client.Id, ScopeNames = scopes.Select(s => s.ScopeName).ToList() }); } }