forked from mirrors/misskey
* fix(backend): follow-up of #17415 * fix
This commit is contained in:
parent
623700119c
commit
d74b6462a8
1 changed files with 20 additions and 7 deletions
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import dns from 'node:dns/promises';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||
import * as htmlParser from 'node-html-parser';
|
||||
import httpLinkHeader from 'http-link-header';
|
||||
import ipaddr from 'ipaddr.js';
|
||||
|
|
@ -380,24 +380,26 @@ function registerFormBodyParser(fastify: FastifyInstance): void {
|
|||
}
|
||||
|
||||
@Injectable()
|
||||
export class OAuth2ProviderService {
|
||||
#authorizationTransactionCache = new MemoryKVCache<AuthorizationTransaction>(1000 * 60 * 5);
|
||||
#grantCodeCache = new MemoryKVCache<AuthorizationCodeGrant>(1000 * 60 * 5);
|
||||
export class OAuth2ProviderService implements OnApplicationShutdown {
|
||||
#authorizationTransactionCache: MemoryKVCache<AuthorizationTransaction>;
|
||||
#grantCodeCache: MemoryKVCache<AuthorizationCodeGrant>;
|
||||
#logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
private httpRequestService: HttpRequestService,
|
||||
@Inject(DI.accessTokensRepository)
|
||||
private accessTokensRepository: AccessTokensRepository,
|
||||
private idService: IdService,
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
private idService: IdService,
|
||||
private httpRequestService: HttpRequestService,
|
||||
private cacheService: CacheService,
|
||||
loggerService: LoggerService,
|
||||
private htmlTemplateService: HtmlTemplateService,
|
||||
loggerService: LoggerService,
|
||||
) {
|
||||
this.#authorizationTransactionCache = new MemoryKVCache<AuthorizationTransaction>(1000 * 60 * 5);
|
||||
this.#grantCodeCache = new MemoryKVCache<AuthorizationCodeGrant>(1000 * 60 * 5);
|
||||
this.#logger = loggerService.getLogger('oauth');
|
||||
}
|
||||
|
||||
|
|
@ -715,4 +717,15 @@ export class OAuth2ProviderService {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public dispose(): void {
|
||||
this.#authorizationTransactionCache.dispose();
|
||||
this.#grantCodeCache.dispose();
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public onApplicationShutdown(signal?: string | undefined): void {
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue