ory / hydra-client-java

Apache License 2.0
26 stars 7 forks source link

ApiClient tokenUrl value is hardcoded #12

Closed alainbodiguel closed 1 year ago

alainbodiguel commented 2 years ago

Preflight checklist

Describe the bug

In the class sh.ory.hydra.ApiClient of the SDK v1.9.0, we can find this line:

String tokenUrl = "https://hydra.demo.ory.sh/oauth2/token";

I can't see how to override it with the url of my local instance of Hydra. I should be able to do so. Obviously this prevents us from adopting Hydra as a solution.

Reproducing the bug

// Import classes:
import sh.ory.hydra.ApiClient;
import sh.ory.hydra.ApiException;
import sh.ory.hydra.Configuration;
import sh.ory.hydra.models.*;
import sh.ory.hydra.api.AdminApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("http://localhost");

    AdminApi apiInstance = new AdminApi(defaultClient);
    String loginChallenge = "loginChallenge_example"; // String | 
    try {
      LoginRequest result = apiInstance.getLoginRequest(loginChallenge);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling AdminApi#getLoginRequest");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Relevant log output

Exception when calling AdminApi#getLoginRequest
Status code: 0
Reason: null
Response headers: null
sh.ory.hydra.ApiException: java.io.IOException: org.apache.oltu.oauth2.common.exception.OAuthSystemException: javax.net.ssl.SSLPeerUnverifiedException: Hostname hydra.demo.ory.sh not verified:
    certificate: sha256/rfyDOVno51fo8v+E2IF9CfHWiqLb51V+rFspoxSNO1s=
    DN: CN=*.numericable.fr
    subjectAltNames: [*.numericable.fr, numericable.fr]
    at sh.ory.hydra.ApiClient.execute(ApiClient.java:988)
    at sh.ory.hydra.api.AdminApi.getLoginRequestWithHttpInfo(AdminApi.java:1775)
    at sh.ory.hydra.api.AdminApi.getLoginRequest(AdminApi.java:1752)


### Relevant configuration

_No response_

### Version

SDK v1.9.0

### On which operating system are you observing this issue?

Other

### In which environment are you deploying?

Docker

### Additional Context

_No response_
aeneasr commented 2 years ago

I believe this should be fixed in the newly released version of the SDK!

jdsalchow commented 2 years ago

Looks like this is still a problem. Fwiw, it seems like this was introduced in 1.7.0

CGNonofr commented 1 year ago

Any update on this?

ardetrick commented 1 year ago

I no longer see this issue on 2.x (although it was likely fixed in a much earlier version).