-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from woowacourse-teams/develop
[ALL] 모모의 두번째 배포가 무사하길 기원해요
- Loading branch information
Showing
179 changed files
with
5,481 additions
and
1,220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/kr/momo/config/DataSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package kr.momo.config; | ||
|
||
import java.util.Map; | ||
import javax.sql.DataSource; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.jdbc.DataSourceBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy; | ||
|
||
@Configuration | ||
@Profile("prod") | ||
public class DataSourceConfig { | ||
|
||
public static final String SOURCE_SERVER = "source"; | ||
public static final String REPLICA_SERVER = "replica"; | ||
|
||
@Bean(SOURCE_SERVER) | ||
@ConfigurationProperties(prefix = "spring.datasource.source") | ||
public DataSource sourceDataSource() { | ||
return DataSourceBuilder.create() | ||
.build(); | ||
} | ||
|
||
@Bean(REPLICA_SERVER) | ||
@ConfigurationProperties(prefix = "spring.datasource.replica") | ||
public DataSource replicaDataSource() { | ||
return DataSourceBuilder.create() | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public DataSource routingDataSource( | ||
@Qualifier(SOURCE_SERVER) DataSource source, | ||
@Qualifier(REPLICA_SERVER) DataSource replica | ||
) { | ||
RoutingDataSource routingDataSource = new RoutingDataSource(); | ||
Map<Object, Object> dataSourceMap = Map.of( | ||
SOURCE_SERVER, source, | ||
REPLICA_SERVER, replica | ||
); | ||
routingDataSource.setTargetDataSources(dataSourceMap); | ||
routingDataSource.setDefaultTargetDataSource(source); | ||
return routingDataSource; | ||
} | ||
|
||
@Bean | ||
@Primary | ||
public DataSource dataSource() { | ||
DataSource dataSource = routingDataSource(sourceDataSource(), replicaDataSource()); | ||
return new LazyConnectionDataSourceProxy(dataSource); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/kr/momo/config/PasswordEncoderConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.momo.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
@Configuration | ||
public class PasswordEncoderConfig { | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/kr/momo/config/RoutingDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.momo.config; | ||
|
||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; | ||
import org.springframework.transaction.support.TransactionSynchronizationManager; | ||
|
||
public class RoutingDataSource extends AbstractRoutingDataSource { | ||
|
||
@Override | ||
protected Object determineCurrentLookupKey() { | ||
if (TransactionSynchronizationManager.isCurrentTransactionReadOnly()) { | ||
return DataSourceConfig.REPLICA_SERVER; | ||
} | ||
return DataSourceConfig.SOURCE_SERVER; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/kr/momo/domain/attendee/AttendeeRawPassword.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package kr.momo.domain.attendee; | ||
|
||
import java.util.regex.Pattern; | ||
import kr.momo.exception.MomoException; | ||
import kr.momo.exception.code.AttendeeErrorCode; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
public record AttendeeRawPassword(String password) { | ||
|
||
private static final Pattern PASSWORD_PATTERN = Pattern.compile("^\\d{4}+$"); | ||
|
||
public AttendeeRawPassword { | ||
validatePassword(password); | ||
} | ||
|
||
private void validatePassword(String password) { | ||
if (password == null || !PASSWORD_PATTERN.matcher(password).matches()) { | ||
throw new MomoException(AttendeeErrorCode.INVALID_PASSWORD_FORMAT); | ||
} | ||
} | ||
|
||
public AttendeePassword encodePassword(PasswordEncoder passwordEncoder) { | ||
return new AttendeePassword(passwordEncoder.encode(password)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/kr/momo/domain/meeting/MeetingType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package kr.momo.domain.meeting; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import kr.momo.exception.MomoException; | ||
import kr.momo.exception.code.MeetingErrorCode; | ||
|
||
public enum MeetingType { | ||
|
||
DAYSONLY, | ||
DATETIME; | ||
|
||
public boolean isDaysOnly() { | ||
return this.equals(DAYSONLY); | ||
} | ||
|
||
@JsonCreator | ||
public static MeetingType from(String type) { | ||
try { | ||
return MeetingType.valueOf(type.toUpperCase()); | ||
} catch (IllegalArgumentException | NullPointerException e) { | ||
throw new MomoException(MeetingErrorCode.INVALID_TYPE); | ||
} | ||
} | ||
} |
Oops, something went wrong.