SAP / cloud-security-services-integration-library

Integration libraries and samples for authenticating users and clients bound to XSUAA authentication and authorization service or Identity authentication service.
Apache License 2.0
151 stars 136 forks source link

Performance: ELK logs full of "Jwt token with audience ... is not issued for these clientIds: ..." if multiple #346

Closed patrickmhaller closed 4 years ago

patrickmhaller commented 4 years ago

Hi Team,

we do have multiple (two) XSUAA instances to verify inbound JWTs with, hence two XsuaaAudienceValidators with different configuration:

    @Bean
    public JwtDecoder getJwtDecoder()
    {
        UaaCredentials xxxApiUaaCredentials = xxxApiUaaCredentials();

        XsuaaAudienceValidator audienceValidator = new XsuaaAudienceValidator(xxxUaaConfig());
        audienceValidator.configureAnotherXsuaaInstance(xxxApiUaaCredentials.getXsAppName(),
                                                        xxxApiUaaCredentials.getClientId());
        return new XsuaaJwtDecoderBuilder(xxxUaaConfig()).withTokenValidators(audienceValidator).build();
    }

Hence, we get

  1. JwtAudienceValidator with clientIds = [sb-xxx-api-sandbox123!b108, xxx-api-sandbox123!b108]
  2. JwtAudienceValidator with clientIds = [sb-xxx-sandbox123!t108, xxx-sandbox123!t108]

The mechanism via AuthTokenDecoder.decodeAndValidate()CombiningValidatorJwtAudienceValidator looks functionally correct, but if the wrong validator is hit first, it always records a warning to ELK via ValidationResults.createInvalid() in any case.

In the context of multiple UAAs, could the either this particular logging case be relaxed or the algorithm changed to avoid the log flood?

Thanks, Patrick

nenaraab commented 4 years ago

Hi @patrickmhaller,

have you followed this guide: https://github.com/SAP/cloud-security-xsuaa-integration/blob/master/spring-xsuaa/Migration_JavaContainerSecurityProjects.md#multiple-xsuaa-bindings

Then i'm not sure, whether there is an easy fix, because you have always two set of validators.

Can you please share with us, which xsuaa plans you make use of, and whether you are already productive or not.

Thanks!

nenaraab commented 4 years ago

Question whether this is related to this cloud sdk issue: https://github.wdf.sap.corp/MA/sdk/issues/3706

TanviiG commented 4 years ago

Hi Nena,

We (cloud SDK team) would like to get some insights related to the issue. Following are the questions:

Regards, Tanvi

nenaraab commented 4 years ago

Hi @TanviiG

nenaraab commented 4 years ago

remove the "bug" flag. as multiple XsuaaAudienceValidators should never exist. We had a similar issue, when one application was bound to two xsuaa instances of the same type (e.g. application). This is not supported.

nenaraab commented 4 years ago

The ticket is in status "Author Action" without any activity for 14 days or longer. Thus, closing the ticket. Please reopen if the issue is still relevant.