Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWL-64] Apple 인증 후 회원가입 구현, 로그인 유지 (access token, refresh token), Apple 인증 후 회원가입, 로그인 유지, global exception filter, global interceptor 구현 #83

Merged
merged 20 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a807326
chore: auth module, controller, service 생성
sjy982 Nov 20, 2023
92a920b
feat: signToken: access, refresh 토큰 생성 함수 구현
sjy982 Nov 20, 2023
1f3de83
feat: loginUser(): login했을 때 accessToken, refreshToken 생성 후 반환하는 함수 구현
sjy982 Nov 20, 2023
da8af98
chore: users module, controller, service 생성
sjy982 Nov 20, 2023
8e6e220
chore: usersRepository 주입
sjy982 Nov 20, 2023
bb0bbd8
feat: authticateWithUserIdAndProvider() => 유저의 아이디가 데이터베이스에 존재하는지 검증하…
sjy982 Nov 20, 2023
1ae7980
chore: profile 모듈, 컨트롤러, 서비스 생성
sjy982 Nov 20, 2023
e7cf4c2
feat: registerWithUserIdAndProvider() => 회원가입 기능 구현
sjy982 Nov 20, 2023
959d663
feat: signup() 구현 -> auth/signup
sjy982 Nov 20, 2023
5ac4737
feat: 토큰 재발급하는 로직 구현
sjy982 Nov 20, 2023
49ddd6c
feat: 토큰 재발급하는 api 구현
sjy982 Nov 20, 2023
c81343b
bearerTokenGuard 구현, refreshTokenGuard 적용
sjy982 Nov 20, 2023
f17fdba
feat: signupDto 생성 후 적용
sjy982 Nov 20, 2023
6505310
chore: lint 적용
sjy982 Nov 20, 2023
b6d6a8d
feat: ResponseTransformInterceptor 구현 => response data를 transfrom 해준다.
sjy982 Nov 20, 2023
a14f2be
feat: httpExceptionFilter 구현, auth 관련된 custom exception 구현
sjy982 Nov 20, 2023
371bcdf
chore: spec 삭제
sjy982 Nov 20, 2023
b6a6852
chore: lint 적용
sjy982 Nov 20, 2023
c6a945d
Merge branch 'develop' into feature/BE/GWL-64
sjy982 Nov 20, 2023
89d48b0
ci: runs-on self-hosted로 변경
sjy982 Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/BackEnd_CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- uses: actions/checkout@v3

Expand Down
153 changes: 146 additions & 7 deletions BackEnd/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions BackEnd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.16",
"@nestjs/typeorm": "^10.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"mysql2": "^3.6.3",
"nest-winston": "^1.9.4",
"reflect-metadata": "^0.1.13",
Expand Down
10 changes: 9 additions & 1 deletion BackEnd/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import { AppService } from './app.service';
import { typeOrmConfig } from './config/typeorm.config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { LoggerMiddleware } from './middlewares/logger.middleware';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { ProfilesModule } from './profiles/profiles.module';

@Module({
imports: [TypeOrmModule.forRoot(typeOrmConfig)],
imports: [
TypeOrmModule.forRoot(typeOrmConfig),
AuthModule,
UsersModule,
ProfilesModule,
],
controllers: [AppController],
providers: [AppService],
})
Expand Down
38 changes: 38 additions & 0 deletions BackEnd/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Body, Controller, Headers, Post, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import { RefreshTokenGuard } from './guard/bearerToken.guard';
import { SignupDto } from './dto/signup.dto';

@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}

@Post('signup')
signup(@Body() body: SignupDto) {
return this.authService.registerWithUserIdAndProvider(body);
}

@Post('token/access')
@UseGuards(RefreshTokenGuard)
tokenAccess(@Headers('authorization') raw: string) {
const token = this.authService.extractTokenFromHeader(raw);

const newToken = this.authService.rotateToken(token, false);

return {
accessToken: newToken,
};
}

@Post('token/access')
@UseGuards(RefreshTokenGuard)
tokenRefresh(@Headers('authorization') raw: string) {
const token = this.authService.extractTokenFromHeader(raw);

const newToken = this.authService.rotateToken(token, true);

return {
refreshToken: newToken,
};
}
}
13 changes: 13 additions & 0 deletions BackEnd/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtModule } from '@nestjs/jwt';
import { UsersModule } from '../users/users.module';
import { ProfilesModule } from '../profiles/profiles.module';

@Module({
imports: [JwtModule.register({}), UsersModule, ProfilesModule],
controllers: [AuthController],
providers: [AuthService],
})
export class AuthModule {}
Loading
Loading