cf-java-client icon indicating copy to clipboard operation
cf-java-client copied to clipboard

Create Orgs/Spaces Fails When Using Client Credentials

Open twoseat opened this issue 6 years ago • 2 comments
trafficstars

Report from a customer:

"We’re trying to use client credentials auth everywhere as opposed to CF users. I hit a problem when trying to create an Org after making that change. The java client attempts to set the org manager user, by extracting the username of the currently authenticated user from the access token. Only now we’re using a client rather than a user, there is no username available…"

This issue has already been resolved in the CLI, we need to reflect their solution. Note that there are other related issues that will probably need handling separately.

twoseat avatar Jan 17 '19 14:01 twoseat

HI, I am experiencing again this problem. when using ClientCredentialsGrantTokenProvider for ReactorUaaClient to creato organization


    @Value("${cf.clientId}")
    private String clientId;

    @Value("${cf.clientSecret}")
    private String clientSecret;

//...

cloudFoundryOperations = DefaultCloudFoundryOperations.builder()
                    .cloudFoundryClient(useCloudFoundryClient())
                    .uaaClient(ReactorUaaClient.builder()
                            .connectionContext(DefaultConnectionContext.builder()
                                    .apiHost(apiHost)
                                    .build())
                            .tokenProvider(ClientCredentialsGrantTokenProvider.builder()
                                    .clientId(clientId)
                                    .clientSecret(clientSecret)
                                    .build())
                            .build())
                    .build();

I get this exception:

java.lang.IllegalStateException: Unable to retrieve username from token
        at org.cloudfoundry.reactor.uaa.UsernameProvider.lambda$getUsername$3(UsernameProvider.java:75) ~[cloudfoundry-client-reactor-5.1.0.RELEASE.jar:na]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
        reactor.core.publisher.Mono.checkpoint(Mono.java:1879)
        org.cloudfoundry.operations.organizations.DefaultOrganizations.create(DefaultOrganizations.java:87)
Error has been observed at the following site(s):
        |_ Mono.checkpoint ? at org.cloudfoundry.operations.organizations.DefaultOrganizations.create(DefaultOrganizations.java:87)
Stack trace:
                at org.cloudfoundry.reactor.uaa.UsernameProvider.lambda$getUsername$3(UsernameProvider.java:75) ~[cloudfoundry-client-reactor-5.1.0.RELEASE.jar:na]

Is it still actual or is it fixed? Thank you. It was closed 2 years ago, then opened again, would like to know the status of it.

andrejb-dev avatar May 28 '21 12:05 andrejb-dev

@Zavael Sorry, I do not believe that this has been resolved. I'm trying to get up-to-speed on this one as @twoseat is not on the team anymore. Given the fact this issue is open and PR #951 is not merged, I'm under the impression this is an outstanding issue. I will get this on the roadmap to be addressed.

dmikusa avatar Jun 04 '21 13:06 dmikusa