added registration uri to server config, changed index of client config service to be server config not just issuer
parent
fc1088c841
commit
cf39b49657
|
@ -152,6 +152,11 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
|
|
||||||
IssuerServiceResponse issResp = issuerService.getIssuer(request);
|
IssuerServiceResponse issResp = issuerService.getIssuer(request);
|
||||||
|
|
||||||
|
if (issResp == null) {
|
||||||
|
logger.error("Null issuer response returned from service.");
|
||||||
|
throw new AuthenticationServiceException("No issuer found.");
|
||||||
|
}
|
||||||
|
|
||||||
if (issResp.shouldRedirect()) {
|
if (issResp.shouldRedirect()) {
|
||||||
response.sendRedirect(issResp.getRedirectUrl());
|
response.sendRedirect(issResp.getRedirectUrl());
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,7 +176,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ClientDetails clientConfig = clients.getClientConfiguration(issuer);
|
ClientDetails clientConfig = clients.getClientConfiguration(serverConfig);
|
||||||
if (clientConfig == null) {
|
if (clientConfig == null) {
|
||||||
logger.error("No client configuration found for issuer: " + issuer);
|
logger.error("No client configuration found for issuer: " + issuer);
|
||||||
throw new AuthenticationServiceException("No client configuration found for issuer: " + issuer);
|
throw new AuthenticationServiceException("No client configuration found for issuer: " + issuer);
|
||||||
|
@ -222,7 +227,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
|
|
||||||
// pull the configurations based on that issuer
|
// pull the configurations based on that issuer
|
||||||
ServerConfiguration serverConfig = servers.getServerConfiguration(issuer);
|
ServerConfiguration serverConfig = servers.getServerConfiguration(issuer);
|
||||||
ClientDetails clientConfig = clients.getClientConfiguration(issuer);
|
ClientDetails clientConfig = clients.getClientConfiguration(serverConfig);
|
||||||
|
|
||||||
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
|
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
|
||||||
form.add("grant_type", "authorization_code");
|
form.add("grant_type", "authorization_code");
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.mitre.openid.connect.client.service;
|
package org.mitre.openid.connect.client.service;
|
||||||
|
|
||||||
|
import org.mitre.openid.connect.config.ServerConfiguration;
|
||||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +12,6 @@ import org.springframework.security.oauth2.provider.ClientDetails;
|
||||||
*/
|
*/
|
||||||
public interface ClientConfigurationService {
|
public interface ClientConfigurationService {
|
||||||
|
|
||||||
public ClientDetails getClientConfiguration(String issuer);
|
public ClientDetails getClientConfiguration(ServerConfiguration issuer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.mitre.openid.connect.client.service.impl;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.mitre.openid.connect.client.service.ClientConfigurationService;
|
import org.mitre.openid.connect.client.service.ClientConfigurationService;
|
||||||
|
import org.mitre.openid.connect.config.ServerConfiguration;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||||
|
|
||||||
|
@ -42,9 +43,9 @@ public class StaticClientConfigurationService implements ClientConfigurationServ
|
||||||
* @see org.mitre.openid.connect.client.service.ClientConfigurationService#getClientConfiguration(java.lang.String)
|
* @see org.mitre.openid.connect.client.service.ClientConfigurationService#getClientConfiguration(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ClientDetails getClientConfiguration(String issuer) {
|
public ClientDetails getClientConfiguration(ServerConfiguration issuer) {
|
||||||
|
|
||||||
return clients.get(issuer);
|
return clients.get(issuer.getIssuer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class ServerConfiguration {
|
||||||
|
|
||||||
private String tokenEndpointUri;
|
private String tokenEndpointUri;
|
||||||
|
|
||||||
|
private String registrationEndpointUri;
|
||||||
|
|
||||||
private String issuer;
|
private String issuer;
|
||||||
|
|
||||||
private String jwksUri;
|
private String jwksUri;
|
||||||
|
@ -106,4 +108,95 @@ public class ServerConfiguration {
|
||||||
this.userInfoUri = userInfoUri;
|
this.userInfoUri = userInfoUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the registrationEndpointUri
|
||||||
|
*/
|
||||||
|
public String getRegistrationEndpointUri() {
|
||||||
|
return registrationEndpointUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param registrationEndpointUri the registrationEndpointUri to set
|
||||||
|
*/
|
||||||
|
public void setRegistrationEndpointUri(String registrationEndpointUri) {
|
||||||
|
this.registrationEndpointUri = registrationEndpointUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#hashCode()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((authorizationEndpointUri == null) ? 0 : authorizationEndpointUri.hashCode());
|
||||||
|
result = prime * result + ((issuer == null) ? 0 : issuer.hashCode());
|
||||||
|
result = prime * result + ((jwksUri == null) ? 0 : jwksUri.hashCode());
|
||||||
|
result = prime * result + ((registrationEndpointUri == null) ? 0 : registrationEndpointUri.hashCode());
|
||||||
|
result = prime * result + ((tokenEndpointUri == null) ? 0 : tokenEndpointUri.hashCode());
|
||||||
|
result = prime * result + ((userInfoUri == null) ? 0 : userInfoUri.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ServerConfiguration other = (ServerConfiguration) obj;
|
||||||
|
if (authorizationEndpointUri == null) {
|
||||||
|
if (other.authorizationEndpointUri != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!authorizationEndpointUri.equals(other.authorizationEndpointUri)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (issuer == null) {
|
||||||
|
if (other.issuer != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!issuer.equals(other.issuer)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (jwksUri == null) {
|
||||||
|
if (other.jwksUri != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!jwksUri.equals(other.jwksUri)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (registrationEndpointUri == null) {
|
||||||
|
if (other.registrationEndpointUri != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!registrationEndpointUri.equals(other.registrationEndpointUri)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tokenEndpointUri == null) {
|
||||||
|
if (other.tokenEndpointUri != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!tokenEndpointUri.equals(other.tokenEndpointUri)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (userInfoUri == null) {
|
||||||
|
if (other.userInfoUri != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!userInfoUri.equals(other.userInfoUri)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue