public void Ensure(SecurityEntityTypes entityType, SecurityMethods method) { string rightToCheck = GetDummyRightName(entityType, method); string currentIdentityName = this.GetCurrentIdentityName(); if (!this.dummyUserRights.ContainsKey(currentIdentityName) || !this.dummyUserRights[currentIdentityName].Contains(rightToCheck)) { throw new SecurityException(); } }
/// <summary> /// Lists blogs. /// </summary> /// <param name="ownerType">The owner type.</param> /// <param name="owner">The owner identifier.</param> /// <param name="q">The query arguments.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <returns>The collection of result.</returns> public async Task <IEnumerable <BlogEntity> > ListBlogsAsync(SecurityEntityTypes ownerType, string owner, QueryArgs q, CancellationToken cancellationToken = default) { var t = (int)ownerType; return(await GetContext(true).Blogs.ListEntities(q, ele => ele.OwnerId == owner && ele.OwnerTypeCode == t).ToListAsync(cancellationToken)); }
private static string GetDummyRightName(SecurityEntityTypes entityType, SecurityMethods method) => $"{Enum.GetName(entityType.GetType(), entityType)}_{Enum.GetName(method.GetType(), method)}";
public void Ensure(SecurityEntityTypes contact, SecurityMethods create) { }
/// <summary> /// Gets a client credential by app identifier. /// </summary> /// <param name="provider">The provider name or url.</param> /// <param name="ownerType">The owner type.</param> /// <param name="ownerId">The owner identifier.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <returns>The user entity matched if found; otherwise, null.</returns> public Task <IEnumerable <AuthorizationCodeEntity> > GetAuthorizationCodesByOwnerAsync(string provider, SecurityEntityTypes ownerType, string ownerId, CancellationToken cancellationToken = default) { return(ToListAsync(GetAuthorizationCodesByOwner(provider, ownerType, ownerId), cancellationToken)); }
/// <summary> /// Gets a client credential by app identifier. /// </summary> /// <param name="provider">The provider name or url.</param> /// <param name="ownerType">The owner type.</param> /// <param name="ownerId">The owner identifier.</param> /// <returns>The user entity matched if found; otherwise, null.</returns> public IEnumerable <AuthorizationCodeEntity> GetAuthorizationCodesByOwner(string provider, SecurityEntityTypes ownerType, string ownerId) { return(codes.Where(ele => ele.OwnerId == ownerId && ele.OwnerType == ownerType)); }
/// <summary> /// Lists blogs. /// </summary> /// <param name="ownerType">The owner type.</param> /// <param name="owner">The owner identifier.</param> /// <param name="q">The query arguments.</param> /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param> /// <returns>The collection of result.</returns> public override async Task <IEnumerable <BlogEntity> > ListBlogsAsync(SecurityEntityTypes ownerType, string owner, QueryArgs q, CancellationToken cancellationToken = default) { return(await DataProvider.ListBlogsAsync(ownerType, owner, q, cancellationToken)); }
/// <summary> /// Gets a client credential by app identifier. /// </summary> /// <param name="provider">The provider name or url.</param> /// <param name="ownerType">The owner type.</param> /// <param name="ownerId">The owner identifier.</param> /// <returns>The user entity matched if found; otherwise, null.</returns> IEnumerable <AuthorizationCodeEntity> IAccountDataProvider.GetAuthorizationCodesByOwner(string provider, SecurityEntityTypes ownerType, string ownerId) { return(GetAuthorizationCodesByOwner(provider, ownerType, ownerId)); }
/// <summary> /// Gets a client credential by app identifier. /// </summary> /// <param name="provider">The provider name or url.</param> /// <param name="ownerType">The owner type.</param> /// <param name="ownerId">The owner identifier.</param> /// <returns>The user entity matched if found; otherwise, null.</returns> public IQueryable <AuthorizationCodeEntity> GetAuthorizationCodesByOwner(string provider, SecurityEntityTypes ownerType, string ownerId) { return(GetContext(true).Codes.Where(ele => ele.OwnerId == ownerId && ele.OwnerTypeCode == (int)ownerType && ele.ServiceProvider == provider)); }