1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00
unleash.unleash/src/lib/services
Gastón Fournier 3e4ed38e2b
chore: remove logs for secret and change invalid token query logic (#6907)
## About the changes
What's going on is the following:
1. When a token is not found in the token's cache we try to find it in
the db
2. To prevent a denial of service attack using invalid tokens, we cache
the invalid tokens so we don't hit the db.
3. The issue is that we stored this token in the cache regardless we
found it or not. And if the token was valid the first time we'd add a
timestamp to avoid querying this token again the next time.
4. The next iteration the token should be in the cache:
54383a6578/src/lib/services/api-token-service.ts (L162)
but for some reason it is not and therefore we have to make a query. But
this is where the query prevention mechanism kicks in because it finds
the token in the cache and kicks us out. This PR fixes this by only
storing in the cache for misses if not found:
54383a6578/src/lib/services/api-token-service.ts (L164-L165)

The token was added to the cache because we were not checking if it had
expired. Now we added a check and we also have a log for expired tokens.
Some improvement opportunities:
- I don't think we display that a token has expired in the UI which
probably led to this issue
- When a token expired we don't display a specific error message or
error response saying that which is not very helpful for users
2024-04-23 11:44:59 +00:00
..
access-service.test.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
access-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
account-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
addon-schema.ts
addon-service-test-simple-addon.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
addon-service.test.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
addon-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
api-token-service.test.ts chore: remove logs for secret and change invalid token query logic (#6907) 2024-04-23 11:44:59 +00:00
api-token-service.ts chore: remove logs for secret and change invalid token query logic (#6907) 2024-04-23 11:44:59 +00:00
client-spec-service.test.ts
client-spec-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
context-schema.ts
context-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
edge-service.ts feat: make edge use token's cache (#6893) 2024-04-19 15:40:15 +02:00
email-service.test.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
email-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
event-announcer-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
event-service.ts chore: re use extract user methods (#5947) 2024-01-18 13:15:21 +01:00
favorites-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
feature-service-potentially-stale.test.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
feature-tag-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
feature-type-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
group-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
health-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
index.ts feat: allow schedulers to run in a single node (#6794) 2024-04-10 11:47:22 +02:00
openapi-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
pat-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
project-health-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
project-schema.ts
public-signup-token-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
reset-token-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
scheduler-service.test.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
segment-schema.ts
session-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
setting-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
state-schema.ts
state-service-export-v1.json
state-service.test.ts chore: scheduled created-by migrations metrics (#6089) 2024-01-31 12:30:42 +01:00
state-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
state-util.ts Biome1.5.1 (#5867) 2024-01-12 09:25:59 +00:00
strategy-schema.ts
strategy-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
tag-schema.test.ts
tag-schema.ts chore: automate openapi schema list (#6463) 2024-03-08 14:58:22 +01:00
tag-service.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
tag-type-schema.test.ts
tag-type-schema.ts
user-feedback-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
user-service.test.ts feat: use audit info in events (#6872) 2024-04-18 16:32:35 +02:00
user-service.ts feat: allow admin login using demo auth (#6808) 2024-04-23 08:39:33 +02:00
user-splash-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00
version-service.test.ts fix: version-service should not use process.nextTick (#6124) 2024-02-05 11:24:37 +01:00
version-service.ts chore: Bump biome and configure husky (#6589) 2024-03-18 13:58:05 +01:00