0

im trying to adapt the very nice sample spring-webmvc-pac4j-boot-demo. i made some minor change to this working exemple with PAC4J and Spring MVC to request OKTA hosted login page with some OIDCclient i was exepecting to be redirected to the okta login page and after successful login being granted to the requested page. But i receive an HTTP 400 instead

My parameters at the okta part are:

Sign-in redirect URIs  = http://localhost:8080/oidc
Sign-out redirect URIs = http://localhost:8080
Initiate login URI = http://localhost:8080/callback

at the application code (Pac4jConfig.java): i created an Oidc config:

     final OidcConfiguration oidcConfiguration = new OidcConfiguration();
     oidcConfiguration.setClientId("my client ID");
     oidcConfiguration.setSecret("big big secret");
     oidcConfiguration.setDiscoveryURI("https://myforeverhostatokta.okta.com/oauth2/default/.well-known/openid-configuration");
    final OidcClient oidcClient = new OidcClient(oidcConfiguration);
    oidcClient.setCallbackUrl("http://localhost:8080/callback");
...

and i created an interceptor (SecurityConfig.java):
...
    registry.addInterceptor(buildInterceptor("OidcClient")).addPathPatterns("/oidc/*");

when i run the modified sample and request localhost:8080/oidc, im redirected to my OKTA server with an HTTP 400 error page claiming that my client application should have some redirect uri set in it. Im sticked with that because i dont know where the Hell should i set this redirect uri in my pac4j configuration. Any Help or hinsights for that problem ?

1 Answer 1

0

I wrote a Build a Java REST API with Java EE and OIDC tutorial on the Okta developer blog that should help. Specifically, the Use Pac4j to Lock Down Your Java REST API section.

You could also clone the GitHub repo and look at the code:

git clone -b pac4j https://github.com/oktadev/okta-java-ee-rest-api-example.git

Not the answer you're looking for? Browse other questions tagged or ask your own question.