@@ -22,48 +22,14 @@ class MongoDbTokenBlacklistService implements TokenBlacklistService {
22
22
required MongoDbConnectionManager connectionManager,
23
23
required Logger log,
24
24
}) : _connectionManager = connectionManager,
25
- _log = log {
26
- // Fire-and-forget initialization. Errors are logged internally.
27
- _init ();
28
- }
25
+ _log = log;
29
26
30
27
final MongoDbConnectionManager _connectionManager;
31
28
final Logger _log;
32
29
33
30
DbCollection get _collection =>
34
31
_connectionManager.db.collection (kBlacklistedTokensCollection);
35
32
36
- /// Initializes the service by ensuring the TTL index exists.
37
- /// This is idempotent and safe to call multiple times.
38
- Future <void > _init () async {
39
- try {
40
- _log.info ('Ensuring TTL index exists for blacklist collection...' );
41
- // Using a raw command is more robust against client library changes.
42
- final command = {
43
- 'createIndexes' : kBlacklistedTokensCollection,
44
- 'indexes' : [
45
- {
46
- 'key' : {'expiry' : 1 },
47
- 'name' : 'expiry_ttl_index' ,
48
- 'expireAfterSeconds' : 0 ,
49
- }
50
- ]
51
- };
52
- await _connectionManager.db.runCommand (command);
53
- _log.info ('Blacklist TTL index is set up correctly.' );
54
- } catch (e, s) {
55
- _log.severe (
56
- 'Failed to create TTL index for blacklist collection. '
57
- 'Failed to create TTL index for blacklist collection. '
58
- 'Automatic cleanup of expired tokens will not work.' ,
59
- e,
60
- s,
61
- );
62
- // Rethrow the exception to halt startup if the index is critical.
63
- rethrow ;
64
- }
65
- }
66
-
67
33
@override
68
34
Future <void > blacklist (String jti, DateTime expiry) async {
69
35
try {
0 commit comments