-
Notifications
You must be signed in to change notification settings - Fork 12
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
CSRF Filter, Refactoring 리뷰 요청드립니다. #3
Open
parkjun5
wants to merge
4
commits into
next-step:parkjun5
Choose a base branch
from
parkjun5:step1
base: parkjun5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ public interface MemberRepository { | |
List<Member> findAll(); | ||
|
||
Member save(Member member); | ||
|
||
void deleteAll(); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/nextstep/security/authentication/AuthenticationManagerBuilder.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,34 @@ | ||
package nextstep.security.authentication; | ||
|
||
import nextstep.security.userdetails.UserDetailsService; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AuthenticationManagerBuilder { | ||
|
||
private final List<AuthenticationProvider> authenticationProviders = new ArrayList<>(); | ||
|
||
public AuthenticationManagerBuilder(ApplicationContext context) { | ||
List<UserDetailsService> userDetailsServices = new ArrayList<>(context.getBeansOfType(UserDetailsService.class).values()); | ||
if (userDetailsServices.isEmpty()) { | ||
return; | ||
} | ||
if (userDetailsServices.size() > 1) { | ||
return; | ||
} | ||
|
||
UserDetailsService userDetailsService = userDetailsServices.get(0); | ||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(userDetailsService); | ||
authenticationProvider(provider); | ||
} | ||
|
||
public void authenticationProvider(AuthenticationProvider authenticationProvider) { | ||
this.authenticationProviders.add(authenticationProvider); | ||
} | ||
|
||
public AuthenticationManager build() { | ||
return new ProviderManager(this.authenticationProviders); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/nextstep/security/autoconfig/OAuth2ClientAutoConfiguration.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,11 @@ | ||
package nextstep.security.autoconfig; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@AutoConfiguration(before = SecurityAutoConfiguration.class) | ||
@Import({OAuth2ClientRegistrationRepositoryConfiguration.class}) | ||
public class OAuth2ClientAutoConfiguration { | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...in/java/nextstep/security/autoconfig/OAuth2ClientRegistrationRepositoryConfiguration.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,36 @@ | ||
package nextstep.security.autoconfig; | ||
|
||
import nextstep.oauth2.OAuth2ClientProperties; | ||
import nextstep.oauth2.registration.ClientRegistration; | ||
import nextstep.oauth2.registration.ClientRegistrationRepository; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@EnableConfigurationProperties(OAuth2ClientProperties.class) | ||
public class OAuth2ClientRegistrationRepositoryConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(ClientRegistrationRepository.class) | ||
ClientRegistrationRepository clientRegistrationRepository(OAuth2ClientProperties properties) { | ||
Map<String, ClientRegistration> registrations = getClientRegistrations(properties); | ||
return new ClientRegistrationRepository(registrations); | ||
} | ||
|
||
private static Map<String, ClientRegistration> getClientRegistrations(OAuth2ClientProperties properties) { | ||
Map<String, ClientRegistration> clientRegistrations = new HashMap<>(); | ||
properties.getRegistration().forEach((key, value) -> clientRegistrations.put(key, | ||
getClientRegistration(key, value, properties.getProvider().get(key)))); | ||
return clientRegistrations; | ||
} | ||
|
||
private static ClientRegistration getClientRegistration(String registrationId, | ||
OAuth2ClientProperties.Registration registration, OAuth2ClientProperties.Provider provider) { | ||
return new ClientRegistration(registrationId, registration.getClientId(), registration.getClientSecret(), registration.getRedirectUri(), registration.getScope(), provider.getAuthorizationUri(), provider.getTokenUri(), provider.getUserInfoUri(), provider.getUserNameAttributeName()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/nextstep/security/autoconfig/SecurityFilterAutoConfiguration.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,14 @@ | ||
package nextstep.security.autoconfig; | ||
|
||
import org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
public class SecurityFilterAutoConfiguration { | ||
|
||
private static final String DEFAULT_FILTER_NAME = "springSecurityFilterChain"; | ||
|
||
@Bean | ||
public DelegatingFilterProxyRegistrationBean securityFilterChainRegistration() { | ||
return new DelegatingFilterProxyRegistrationBean(DEFAULT_FILTER_NAME); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/nextstep/security/config/annotation/EnableWebSecurity.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,12 @@ | ||
package nextstep.security.config.annotation; | ||
|
||
import org.springframework.context.annotation.Import; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Documented | ||
@Import({HttpSecurityConfiguration.class, WebSecurityConfiguration.class}) | ||
public @interface EnableWebSecurity { | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/login, /logout은 제외하신 이유가 있을까요?