mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 22:27:48 +00:00
Describe query
This commit is contained in:
@@ -54,10 +54,22 @@ export const identityAccessTokenDALFactory = (db: TDbClient) => {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.orWhere((qb) => {
|
.orWhere((qb) => {
|
||||||
void qb
|
void qb.where("accessTokenTTL", ">", 0).andWhereRaw(
|
||||||
.where("accessTokenTTL", ">", 0)
|
`
|
||||||
.andWhereRaw(
|
-- Check if the token's effective expiration time has passed.
|
||||||
`COALESCE("${TableName.IdentityAccessToken}"."accessTokenLastRenewedAt", "${TableName.IdentityAccessToken}"."createdAt") + make_interval(secs => LEAST("${TableName.IdentityAccessToken}"."accessTokenTTL", ?)) < NOW()`,
|
-- The expiration time is calculated by adding its TTL to its last renewal/creation time.
|
||||||
|
COALESCE(
|
||||||
|
"${TableName.IdentityAccessToken}"."accessTokenLastRenewedAt", -- Use last renewal time if available
|
||||||
|
"${TableName.IdentityAccessToken}"."createdAt" -- Otherwise, use creation time
|
||||||
|
)
|
||||||
|
+ make_interval(
|
||||||
|
secs => LEAST(
|
||||||
|
"${TableName.IdentityAccessToken}"."accessTokenTTL", -- Token's specified TTL
|
||||||
|
? -- Capped by MAX_TTL (parameterized value)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
< NOW() -- Check if the calculated time is before now
|
||||||
|
`,
|
||||||
[MAX_TTL]
|
[MAX_TTL]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user