Skip to content

Commit

Permalink
v1.5.2 (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat authored Mar 5, 2024
2 parents 3e11a37 + 8fa2740 commit 96234ad
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 105 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ dependencies {

// Excel
implementation 'org.apache.poi:poi:5.2.5'

// Monitoring
implementation 'io.micrometer:micrometer-registry-prometheus'
}

tasks.named('test') {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.gdschongik.gdsc.global.config;

import com.gdschongik.gdsc.global.property.BasicAuthProperty;
import com.gdschongik.gdsc.global.property.DiscordProperty;
import com.gdschongik.gdsc.global.property.JwtProperty;
import com.gdschongik.gdsc.global.property.RedisProperty;
import com.gdschongik.gdsc.global.property.SwaggerProperty;
import com.gdschongik.gdsc.global.property.email.EmailProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties({
JwtProperty.class,
RedisProperty.class,
SwaggerProperty.class,
BasicAuthProperty.class,
DiscordProperty.class,
EmailProperty.class
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.gdschongik.gdsc.domain.auth.application.JwtService;
import com.gdschongik.gdsc.domain.member.dao.MemberRepository;
import com.gdschongik.gdsc.global.annotation.ConditionalOnProfile;
import com.gdschongik.gdsc.global.property.SwaggerProperty;
import com.gdschongik.gdsc.global.property.BasicAuthProperty;
import com.gdschongik.gdsc.global.security.CustomSuccessHandler;
import com.gdschongik.gdsc.global.security.CustomUserService;
import com.gdschongik.gdsc.global.security.JwtExceptionFilter;
Expand Down Expand Up @@ -46,7 +46,7 @@ public class WebSecurityConfig {
private final CookieUtil cookieUtil;
private final ObjectMapper objectMapper;
private final EnvironmentUtil environmentUtil;
private final SwaggerProperty swaggerProperty;
private final BasicAuthProperty basicAuthProperty;

private void defaultFilterChain(HttpSecurity http) throws Exception {
http.httpBasic(AbstractHttpConfigurer::disable)
Expand Down Expand Up @@ -75,6 +75,19 @@ public SecurityFilterChain swaggerFilterChain(HttpSecurity http) throws Exceptio
return http.build();
}

@Bean
@Order(2)
@ConditionalOnProfile(PROD)
public SecurityFilterChain prometheusFilterChain(HttpSecurity http) throws Exception {
defaultFilterChain(http);

http.securityMatcher("/gdsc-actuator/prometheus").httpBasic(withDefaults());

http.authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated());

return http.build();
}

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
defaultFilterChain(http);
Expand All @@ -93,8 +106,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/oauth2/**")
.permitAll()
.requestMatchers("/auth/**")
.permitAll()
.requestMatchers("/gdsc-actuator/**")
.permitAll()
.requestMatchers("/onboarding/verify-email")
Expand All @@ -111,8 +122,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

@Bean
public InMemoryUserDetailsManager inMemoryUserDetailsManager() {
UserDetails user = User.withUsername(swaggerProperty.getUsername())
.password(passwordEncoder().encode(swaggerProperty.getPassword()))
UserDetails user = User.withUsername(basicAuthProperty.getUsername())
.password(passwordEncoder().encode(basicAuthProperty.getPassword()))
.roles("SWAGGER")
.build();
return new InMemoryUserDetailsManager(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

@Getter
@AllArgsConstructor
@ConfigurationProperties(prefix = "swagger")
public class SwaggerProperty {
@ConfigurationProperties(prefix = "auth")
public class BasicAuthProperty {

private final String username;
private final String password;
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application-actuator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ management:
endpoints:
web:
exposure:
include: health
include: health, prometheus
base-path: /gdsc-actuator
jmx:
exposure:
Expand All @@ -11,3 +11,5 @@ management:
endpoint:
health:
enabled: true
prometheus:
enabled: true
4 changes: 4 additions & 0 deletions src/main/resources/application-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ jwt:
secret: ${JWT_REFRESH_TOKEN_SECRET:}
expiration-time: ${JWT_REFRESH_TOKEN_EXPIRATION_TIME:604800}
issuer: ${JWT_ISSUER:}

auth:
username: ${SWAGGER_USER:default}
password: ${SWAGGER_PASSWORD:default}
8 changes: 0 additions & 8 deletions src/main/resources/application-swagger.yml

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ spring:
include:
- redis
- security
- swagger
- actuator
- discord
- email
Expand Down

0 comments on commit 96234ad

Please sign in to comment.