JCL-444: Improve support for RFC 9207 by acoburn · Pull Request #1246 · inrupt/solid-client-java
In short, we need that additional if statement you refer to.
Now I recall how all this fits together in the context of a web application:
// Intialize the OAuth2 authorization code flow @GET @Path("/login") public CompletionStage<Response> login() { var client = new OpenIdProvider(issuer, dpop); var request = AuthorizationRequest.newBuilder() .scope("openid") .scope("webid") .build(config.clientId, config.redirectUri); // Redirect the client to the authorization endpoint return client.authorize(request).thenApply(Response::seeOther); }
Then, the response gets processed in the following way:
// Continue the OAuth2 authorization code flow // The client will receive a URL such as /callback?code=123456&iss=https://op.example @GET @Path("/callback") public CompletionStage<Response> callback(@QueryParam("code") String code, @QueryParam("iss") String issuer) { var client = new OpenIdProvider(issuer, dpop); var request = TokenRequest.newBuilder() .code(code) .issuer(issuer) .build("authorization_code", config.clientId); return client.token(request) .thenApply(token -> { // store or process token.idToken // set a session cookie for the application // redirect the user to a landing page (e.g. /profile) return Response.seeOther(URI.create("/profile")); }); }
In this flow, setting TokenRequest.Builder.issuer() with a null value is equivalent to not setting it at all. And so, if the designated OP supports RFC 9207 (via the Metadata response), then we should expect that the value not only matches the OP's own issuer URI but also that it is non-null.