parent
336e247e70
commit
4476df93e9
|
@ -38,7 +38,7 @@ public class DefaultAuthorizationRequestUriBuilder implements AuthorizationReque
|
|||
public URI build(AuthorizationRequestAttributes authorizationRequestAttributes) {
|
||||
UriComponentsBuilder uriBuilder = UriComponentsBuilder
|
||||
.fromUriString(authorizationRequestAttributes.getAuthorizeUri())
|
||||
.queryParam(OAuth2Parameter.RESPONSE_TYPE, ResponseType.CODE.value());
|
||||
.queryParam(OAuth2Parameter.RESPONSE_TYPE, ResponseType.CODE.getValue());
|
||||
if (authorizationRequestAttributes.getRedirectUri() != null) {
|
||||
uriBuilder.queryParam(OAuth2Parameter.REDIRECT_URI, authorizationRequestAttributes.getRedirectUri());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.springframework.security.oauth2.core.endpoint;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The <i>response_type</i> parameter is consumed by the authorization endpoint which
|
||||
* is used by the authorization code grant type and implicit grant type flows.
|
||||
|
@ -31,16 +33,33 @@ package org.springframework.security.oauth2.core.endpoint;
|
|||
* @since 5.0
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-3.1.1">Section 3.1.1 Response Type</a>
|
||||
*/
|
||||
public enum ResponseType {
|
||||
CODE("code");
|
||||
|
||||
public final class ResponseType {
|
||||
public static final ResponseType CODE = new ResponseType("code");
|
||||
private final String value;
|
||||
|
||||
ResponseType(String value) {
|
||||
public ResponseType(String value) {
|
||||
Assert.hasText(value, "value cannot be empty");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ResponseType that = (ResponseType) obj;
|
||||
return this.getValue().equals(that.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getValue().hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class OAuth2LoginApplicationTests {
|
|||
|
||||
Map<String, String> params = uriComponents.getQueryParams().toSingleValueMap();
|
||||
|
||||
assertThat(params.get(OAuth2Parameter.RESPONSE_TYPE)).isEqualTo(ResponseType.CODE.value());
|
||||
assertThat(params.get(OAuth2Parameter.RESPONSE_TYPE)).isEqualTo(ResponseType.CODE.getValue());
|
||||
assertThat(params.get(OAuth2Parameter.CLIENT_ID)).isEqualTo(this.githubClientRegistration.getClientId());
|
||||
String redirectUri = AUTHORIZE_BASE_URL + "/" + this.githubClientRegistration.getClientAlias();
|
||||
assertThat(URLDecoder.decode(params.get(OAuth2Parameter.REDIRECT_URI), "UTF-8")).isEqualTo(redirectUri);
|
||||
|
|
Loading…
Reference in New Issue