Skip to content

Combination of legacyKeys and caching Feature return legacy keys during masking #18

Description

@gako

I encountered a behaviour that seems to be against the definition for the usage of legacy keys.

I have an IdMask with legacy keys for backward compatibility, which works fine
`
KeyManager.IdSecretKey legacyKey = new KeyManager.IdSecretKey(0, legacySecret);
KeyManager.IdSecretKey domainKey = new KeyManager.IdSecretKey(1, domainSecret);
KeyManager keyManager = KeyManager.Factory.withKeyAndLegacyKeys(domainKey, legacyKey);

IdMasks.forLongIds(Config.builder(keyManager).enableCache(true)
`

If I unmask a id that was masked with the legacyKey in the past and then try to mask the same value with the new idmask it will still return the old legacy masked value, probably due to the fact that unmasking the legacy value stores it in the cache and reused it during masking.

As a workaround disabled cache solves the problem, but it probably would be better to not stored legacy masked values in the cache or distinguis in the cache between used cache keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions