stormpath / stormpath-sdk-java

Official Java SDK for the Stormpath User Management REST API
222 stars 155 forks source link

[Okta] OIDCKeysList and Account aren't being cached #1325

Closed andersonkyle closed 7 years ago

andersonkyle commented 7 years ago

Unnecessary HTTP requests are being made to Okta due to the OIDCKeysList and Account objects not being cached.

The WriteCacheFilter.isCacheable(...) method has a number of conditions that need to be satisfied in order for the object to be cached.

The OIDCKeysList and Account objects don't satisfy the conditions contained within AbstractResource.isMaterialized(...).

    public static boolean isMaterialized(Map<String, ?> props) {
        return props != null && props.get(HREF_PROP_NAME) != null && props.size() > 1;
    }

Both objects do not contain keys named href. The OIDCKeysList size in my instance is not greater than one either.

These additional HTTP requests to Okta add significant time to each request to my application, so a fix would be greatly appreciated. Thanks!

bdemers commented 7 years ago

@andersonkyle Thanks! We already have a fix in the works for the next release.

bdemers commented 7 years ago

Fixed in 2.0.0-okta-rc1 Implementation note: Account will be cacheable. OIDCKeysList is not (but the keys contain in the list are, and the remote resource is only queried when a key cannot be found locally.

@andersonkyle give it a shot and reopen this issue if you run into any problems

andersonkyle commented 7 years ago

That did the trick. Thanks!