-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Provide support for OAuth 2.0 #4238
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
Conversation
* Spring IO Athens-BUILD-SNAPSHOT -> Cairo-BUILD-SNAPSHOT * CGLib 3.1 -> 3.2.5 latest release Issue related to ASM cglib/cglib#20 * AssertJ 2.2.0 -> 3.6.2 latest release * PowerMock 1.6.2 -> 1.6.5 latest release is 1.6.6 but has regression Issue powermock/powermock#717
General
spring-security-oauth2-core
spring-security-oauth2-client
oauth2login
|
@@ -29,7 +29,7 @@ | |||
*/ | |||
public class JavaVersionTests { | |||
|
|||
private static final int JDK6_CLASS_VERSION = 50; |
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.
All infrastructure changes (i.e. updating to Java 8) should be in a distinct commit
@@ -0,0 +1,19 @@ | |||
apply from: BOOT_SAMPLE_GRADLE |
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.
This should only use tabs
*/ | ||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { |
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.
Configuration should be simplified
- The customization of
ClientRegistration
for github needs to go away some how. Perhaps rather than customizing it in the configure any customization should be done in the bean definition itself. - I don't like the boilerplate code here (copy paste, modify for each provider we are leveraging, profiles, etc). Some of this might be necessary in a standard application, but it should not be required in a Boot application. AutoConfiguraiton can live in this sample (within a separate package) until we can get it into boot. In the end we should only have the yml file (the entire SecurityConfig should be removed).
- Now that this is getting merged we should add the
oauthLogin
toHttpSecurity
@@ -0,0 +1,34 @@ | |||
/* |
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.
This probably belongs in oauth2-client rather than oauth2-core
import org.springframework.security.core.Authentication; | ||
|
||
/** | ||
* Root exception for all OAuth2-related general errors. |
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.
This is not true because as the NOTE mentions, OAuth2AuthenticationException is also used. I think we should try to rename this to be more exact. Perhaps OAuth2AuthorizationException (does that work for the use cases it is intended for)?
filterChain.doFilter(request, response); | ||
} | ||
|
||
private void obtainAuthorization(HttpServletRequest request, HttpServletResponse response) |
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.
Perhaps rename to authorizationRequestRedirect
response.sendError(HttpServletResponse.SC_BAD_REQUEST, failed.getMessage()); | ||
} | ||
|
||
private String normalizeUri(String uri) { |
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.
Rather than implement this yourself, use UriComponentsBuilder
|
||
@Override | ||
public final void afterPropertiesSet() { | ||
Assert.notEmpty(this.clientRegistrationRepository.getRegistrations(), "clientRegistrationRepository cannot be empty"); |
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.
Validate not empty at time of creating the ClientRegistrationRepository
/** | ||
* @author Joe Grandja | ||
*/ | ||
public interface AuthorizationRequestRepository { |
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.
Pass in the HttpServletResponse so that cookies could be used
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.
Use a data object rather than having lots of params
/** | ||
* @author Joe Grandja | ||
*/ | ||
public interface AuthorizationGrantTokenExchanger<T extends AuthorizationGrantAuthenticationToken> { |
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.
Why does this need to take a generic argument? Can it just always use AuthorizationCodeGrantAuthenticationToken
Closing with new PR to follow |
Provide support for an OAuth 2.0 Client.