Skip to content

Commit

Permalink
Fixed: OpenIDHashVariable - To obtain token endpoint from issuer disc…
Browse files Browse the repository at this point in the history
…overy if the issuer type is not "Custom"
  • Loading branch information
damienjoget committed Jul 15, 2024
1 parent 8db88e3 commit 8308ccf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.joget</groupId>
<artifactId>openid-connect-authentication</artifactId>
<packaging>bundle</packaging>
<version>7.0.6</version>
<version>7.0.7</version>
<name>openid-connect-authentication</name>
<url>http://www.joget.org</url>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String getDescription() {

@Override
public String getVersion() {
return "7.0.6";
return "7.0.7";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public String getDescription() {

@Override
public String getVersion() {
return "7.0.6";
return "7.0.7";
}

@Override
Expand Down Expand Up @@ -247,7 +247,7 @@ public void webService(HttpServletRequest request, HttpServletResponse response)
}
}

public OIDCProviderMetadata IssuerDiscovery() throws IOException, URISyntaxException {
public static OIDCProviderMetadata IssuerDiscovery() throws IOException, URISyntaxException {
DirectoryManagerProxyImpl dm = (DirectoryManagerProxyImpl) AppUtil.getApplicationContext().getBean("directoryManager");
SecureDirectoryManagerImpl dmImpl = (SecureDirectoryManagerImpl) dm.getDirectoryManagerImpl();

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/joget/plugin/marketplace/OpenIDHashVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.nimbusds.oauth2.sdk.token.RefreshToken;
import com.nimbusds.oauth2.sdk.token.Tokens;
import com.nimbusds.openid.connect.sdk.OIDCTokenResponseParser;
import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -39,7 +40,7 @@ public String getName() {

@Override
public String getVersion() {
return "7.0.6";
return "7.0.7";
}

@Override
Expand Down Expand Up @@ -105,7 +106,16 @@ public String processHashVariable(String variableKey) {
try {
RefreshToken receivedRefreshToken = new RefreshToken(refreshTokenUmd.getValue());
AuthorizationGrant refreshTokenGrant = new RefreshTokenGrant(receivedRefreshToken);
URI tokenEndpoint = new URI(dmImpl.getPropertyString("tokenEndpoint"));
//URI tokenEndpoint = new URI(dmImpl.getPropertyString("tokenEndpoint"));
URI tokenEndpoint;

if (dmImpl.getPropertyString("tokenEndpoint").isEmpty()) {
OIDCProviderMetadata providerMetadata = OpenIDDirectoryManager.IssuerDiscovery();
tokenEndpoint = providerMetadata.getTokenEndpointURI();
} else {
tokenEndpoint = new URI(dmImpl.getPropertyString("tokenEndpoint"));
}

ClientID clientID = new ClientID(dmImpl.getPropertyString("clientId"));
Secret secret = new Secret(dmImpl.getPropertyString("clientSecret"));
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, secret);
Expand Down

0 comments on commit 8308ccf

Please sign in to comment.