Revert "redis接続確認"
This reverts commit 28c5704b16fd161a96668e13e26a6d6c47770528.
This commit is contained in:
parent
28c5704b16
commit
d8d5789f5a
@ -25,6 +25,3 @@ STORAGE_ACCOUNT_KEY_EU=XXXXXXXXXXXXXXXXXXXXXXX
|
|||||||
STORAGE_ACCOUNT_ENDPOINT_US=https://AAAAAAAAAAAAA
|
STORAGE_ACCOUNT_ENDPOINT_US=https://AAAAAAAAAAAAA
|
||||||
STORAGE_ACCOUNT_ENDPOINT_AU=https://AAAAAAAAAAAAA
|
STORAGE_ACCOUNT_ENDPOINT_AU=https://AAAAAAAAAAAAA
|
||||||
STORAGE_ACCOUNT_ENDPOINT_EU=https://AAAAAAAAAAAAA
|
STORAGE_ACCOUNT_ENDPOINT_EU=https://AAAAAAAAAAAAA
|
||||||
REDIS_HOST=redis-cache
|
|
||||||
REDIS_PORT=6379
|
|
||||||
REDIS_PASSWORD=omdsredispass
|
|
||||||
@ -42,7 +42,6 @@ import { SortCriteriaRepositoryModule } from './repositories/sort_criteria/sort_
|
|||||||
import { TemplateFilesRepositoryModule } from './repositories/template_files/template_files.repository.module';
|
import { TemplateFilesRepositoryModule } from './repositories/template_files/template_files.repository.module';
|
||||||
import { WorktypesRepositoryModule } from './repositories/worktypes/worktypes.repository.module';
|
import { WorktypesRepositoryModule } from './repositories/worktypes/worktypes.repository.module';
|
||||||
import { OptionItemsRepositoryModule } from './repositories/option_items/option_items.repository.module';
|
import { OptionItemsRepositoryModule } from './repositories/option_items/option_items.repository.module';
|
||||||
import { RedisModule } from './gateways/redis/redis.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -99,7 +98,6 @@ import { RedisModule } from './gateways/redis/redis.module';
|
|||||||
SortCriteriaRepositoryModule,
|
SortCriteriaRepositoryModule,
|
||||||
WorktypesRepositoryModule,
|
WorktypesRepositoryModule,
|
||||||
OptionItemsRepositoryModule,
|
OptionItemsRepositoryModule,
|
||||||
RedisModule,
|
|
||||||
],
|
],
|
||||||
controllers: [
|
controllers: [
|
||||||
HealthController,
|
HealthController,
|
||||||
|
|||||||
@ -23,14 +23,13 @@ import {
|
|||||||
import { retrieveAuthorizationToken } from '../../common/http/helper';
|
import { retrieveAuthorizationToken } from '../../common/http/helper';
|
||||||
import { makeContext } from '../../common/log';
|
import { makeContext } from '../../common/log';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { RedisService } from '../../gateways/redis/redis.service';
|
|
||||||
|
|
||||||
@ApiTags('auth')
|
@ApiTags('auth')
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
constructor(
|
constructor(
|
||||||
// TODO「タスク 1828: IDトークンを一度しか使えないようにする」で使用する予定
|
// TODO「タスク 1828: IDトークンを一度しか使えないようにする」で使用する予定
|
||||||
private readonly redisService: RedisService,
|
// private readonly redisService: RedisService,
|
||||||
private readonly authService: AuthService,
|
private readonly authService: AuthService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -65,8 +64,6 @@ export class AuthController {
|
|||||||
HttpStatus.BAD_REQUEST,
|
HttpStatus.BAD_REQUEST,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.log('Storing ID tokens in redis');
|
|
||||||
await this.redisService.set(body.idToken, 'used');
|
|
||||||
|
|
||||||
const context = makeContext(uuidv4());
|
const context = makeContext(uuidv4());
|
||||||
|
|
||||||
@ -80,9 +77,6 @@ export class AuthController {
|
|||||||
context,
|
context,
|
||||||
refreshToken,
|
refreshToken,
|
||||||
);
|
);
|
||||||
const res = await this.redisService.get(body.idToken);
|
|
||||||
console.log('Obtaining an ID token from redis');
|
|
||||||
console.log(res);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accessToken,
|
accessToken,
|
||||||
|
|||||||
@ -4,9 +4,8 @@ import { AdB2cModule } from '../../gateways/adb2c/adb2c.module';
|
|||||||
import { UsersRepositoryModule } from '../../repositories/users/users.repository.module';
|
import { UsersRepositoryModule } from '../../repositories/users/users.repository.module';
|
||||||
import { AuthController } from './auth.controller';
|
import { AuthController } from './auth.controller';
|
||||||
import { AuthService } from './auth.service';
|
import { AuthService } from './auth.service';
|
||||||
import { RedisModule } from '../../gateways/redis/redis.module';
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ConfigModule, AdB2cModule, UsersRepositoryModule, RedisModule],
|
imports: [ConfigModule, AdB2cModule, UsersRepositoryModule],
|
||||||
controllers: [AuthController],
|
controllers: [AuthController],
|
||||||
providers: [AuthService],
|
providers: [AuthService],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
import { CacheModule, Module } from '@nestjs/common';
|
|
||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
||||||
import * as redisStore from 'cache-manager-redis-store';
|
|
||||||
import { RedisService } from './redis.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
CacheModule.registerAsync({
|
|
||||||
imports: [ConfigModule],
|
|
||||||
useFactory: async (configService: ConfigService) => {
|
|
||||||
if (process.env.STAGE === 'local') {
|
|
||||||
return {
|
|
||||||
store: redisStore,
|
|
||||||
host: configService.get('REDIS_HOST'),
|
|
||||||
port: configService.get('REDIS_PORT'),
|
|
||||||
password: configService.get('REDIS_PASSWORD'),
|
|
||||||
ttl: configService.get('REDIS_TTL'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
store: redisStore,
|
|
||||||
url: `rediss://${configService.get('REDIS_HOST')}:${configService.get(
|
|
||||||
'REDIS_PORT',
|
|
||||||
)}`,
|
|
||||||
password: configService.get('REDIS_PASSWORD'),
|
|
||||||
ttl: configService.get('REDIS_TTL'),
|
|
||||||
tls: {},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: [ConfigService],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
providers: [RedisService],
|
|
||||||
exports: [RedisService],
|
|
||||||
})
|
|
||||||
export class RedisModule {}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
import {
|
|
||||||
CACHE_MANAGER,
|
|
||||||
Inject,
|
|
||||||
Injectable,
|
|
||||||
InternalServerErrorException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { Cache } from 'cache-manager';
|
|
||||||
|
|
||||||
// TODO「タスク 1828: IDトークンを一度しか使えないようにする」で本実装する予定
|
|
||||||
@Injectable()
|
|
||||||
export class RedisService {
|
|
||||||
constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}
|
|
||||||
|
|
||||||
async set(key: string, value: string): Promise<void> {
|
|
||||||
try {
|
|
||||||
await this.cacheManager.set(key, value);
|
|
||||||
} catch (error) {
|
|
||||||
throw new InternalServerErrorException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async get(key: string): Promise<string> {
|
|
||||||
try {
|
|
||||||
const value = await this.cacheManager.get<string>(key);
|
|
||||||
return value;
|
|
||||||
} catch (error) {
|
|
||||||
throw new InternalServerErrorException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user