Abp Version: 7.4.4
I am using GetAsync(Id) or DbSet.FirstOrDefaultAsync(a => a.Id == Id), to Get a Entity from database, every thing works good when I do not set an Access token. But after I set the Access Token the Query do not get the entity anymore from database (I need to close the end point with authorization). The access token was generated by keycloak.
Query did by the frame work when there is no token (it works fine):
SELECT a
.Id
, a
.ConcurrencyStamp
, a
.CreationTime
, a
.CreatorId
, a
.Description
, a
.ExtraProperties
, a
.LastModificationTime
, a
.LastModifierId
, a
.PointName
, a
.TenantId
FROM AccessPoints
AS a
WHERE (@__ef_filter__p_0 OR (a
.TenantId
= @__ef_filter__CurrentTenantId_1)) AND (a
.Id
= @__Id_0)
LIMIT 1
Query did by the framework when the access token is setted (do not work):
SELECT a
.Id
, a
.ConcurrencyStamp
, a
.CreationTime
, a
.CreatorId
, a
.Description
, a
.ExtraProperties
, a
.LastModificationTime
, a
.LastModifierId
, a
.PointName
, a
.TenantId
FROM AccessPoints
AS a
WHERE (@__ef_filter__p_0 OR (a
.TenantId
IS NULL)) AND (a
.Id
= @__Id_0)
LIMIT 1
The second query is asking to entities that have TenantId null, even though, passing __tenant on header.
I tried some way of to set the TenantId for CurrentUser, but it was not possíble, because the access to this property is private. I thought that, maybe the query was trying to use the TenantId of the CurrentUser, however I not sure if can be that.