Skip to content

Optimize secret matching #201

@litoj

Description

@litoj

I am getting Microsoft Entra ID setup and in this article I clearly saw the possibility to quickly determine the key (secret) to check against by making a map of KeyIDs mapped to key secrets. This would allow decoding with just the correct key, instead of trying them all.

That would change the Array verification to something like this:

let decodedTokens = []
if (secret instanceof Array) {
    decodedTokens = secret.map(async s => await verify(token, s, opts));
} else if (secret) {
    decodedTokens = verify(token, secret[token.kid] || secret, opts);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions