-
Notifications
You must be signed in to change notification settings - Fork 2
20260202 #207 개발자용 관리자 페이지 구현 #223
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
Merged
The head ref may contain hidden characters: "20260202-#207-\uAC1C\uBC1C\uC790\uC6A9-\uAD00\uB9AC\uC790-\uD398\uC774\uC9C0-\uAD6C\uD604"
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f3b935
[BE][FEAT] Spring boot admin 관리자 페이지 구현
nayoung04 32401f2
[BE][FIX] resolve conflict
nayoung04 d7e3eb3
[BE][FEAT] 관리자페이지 로그인 설정
nayoung04 8391ca6
[BE][FEAT] 관리자 페이지 보안 설정 추가
nayoung04 02a89e8
[BE][FEAT] 관리자 페이지 보안 설정 추가
nayoung04 1a83bd2
[BE][FEAT] 관리자 페이지 보안 설정 추가
nayoung04 a92a3d1
Merge branch 'main' of https://github.com/SISC-IT/sisc-web into 20260…
nayoung04 ef9bfb6
[BE][FEAT] 엔드포인트 상수화 및 시크릿키 등록
nayoung04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
78 changes: 78 additions & 0 deletions
78
backend/src/main/java/org/sejongisc/backend/common/config/security/AdminSecurityConfig.java
This file contains hidden or 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,78 @@ | ||
| package org.sejongisc.backend.common.config.security; | ||
|
|
||
| import de.codecentric.boot.admin.server.config.AdminServerProperties; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.core.annotation.Order; | ||
| import org.springframework.security.authentication.dao.DaoAuthenticationProvider; | ||
| import org.springframework.security.config.Customizer; | ||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| import org.springframework.security.core.userdetails.User; | ||
| import org.springframework.security.core.userdetails.UserDetails; | ||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||
| import org.springframework.security.provisioning.InMemoryUserDetailsManager; | ||
| import org.springframework.security.web.SecurityFilterChain; | ||
|
|
||
| @Configuration | ||
| public class AdminSecurityConfig { | ||
|
|
||
| private final AdminServerProperties adminServerProperties; | ||
| private final PasswordEncoder passwordEncoder; | ||
|
|
||
| @Value("${spring.security.user.name}") | ||
| private String adminUsername; | ||
|
|
||
| @Value("${spring.security.user.password}") | ||
| private String adminPassword; | ||
|
|
||
| public AdminSecurityConfig(AdminServerProperties adminServerProperties, PasswordEncoder passwordEncoder) { | ||
| this.adminServerProperties = adminServerProperties; | ||
| this.passwordEncoder = passwordEncoder; | ||
| } | ||
|
|
||
| @Bean | ||
| @Order(1) // 1순위로 체크: /admin 및 /actuator 경로는 이 설정이 우선 적용됨 | ||
| public SecurityFilterChain adminSecurityFilterChain(HttpSecurity http) throws Exception { | ||
| String adminContextPath = adminServerProperties.getContextPath(); | ||
|
|
||
| // 관리자 계정 설정 | ||
| UserDetails adminUser = User.withUsername(adminUsername) | ||
| .password(passwordEncoder.encode(adminPassword)) | ||
| .roles("ADMIN") | ||
| .build(); | ||
|
|
||
| InMemoryUserDetailsManager userDetailsService = new InMemoryUserDetailsManager(adminUser); | ||
|
|
||
| // 관리자 전용 인증 프로바이더 설정 | ||
| DaoAuthenticationProvider adminAuthenticationProvider = new DaoAuthenticationProvider(); | ||
| adminAuthenticationProvider.setUserDetailsService(userDetailsService); | ||
| adminAuthenticationProvider.setPasswordEncoder(passwordEncoder); | ||
|
|
||
| http | ||
| .securityMatcher(SecurityConstants.ADMIN_URLS) | ||
| .authenticationProvider(adminAuthenticationProvider) | ||
| .csrf(csrf -> csrf.ignoringRequestMatchers( | ||
| adminContextPath + "/instances", | ||
| adminContextPath + "/instances/**", | ||
| "/actuator/**" | ||
| )) | ||
| .authorizeHttpRequests(auth -> auth | ||
| // 무인증 허용 리스트 | ||
| .requestMatchers(SecurityConstants.ADMIN_PUBLIC_URLS).permitAll() | ||
|
|
||
| // SBA 클라이언트 등록 엔드포인트 보호 | ||
| .requestMatchers(adminContextPath + "/instances", adminContextPath + "/instances/**").authenticated() | ||
|
|
||
| // 나머지는 관리자 인증 필수 | ||
| .anyRequest().authenticated() | ||
| ) | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .formLogin(form -> form | ||
| .loginPage(adminContextPath + "/login") | ||
| .defaultSuccessUrl(adminContextPath + "/", true) | ||
| ) | ||
| .httpBasic(Customizer.withDefaults()); | ||
|
|
||
| return http.build(); | ||
| } | ||
nayoung04 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.