paragonie / paseto

Platform-Agnostic Security Tokens
https://paseto.io
Other
3.24k stars 108 forks source link

Allowed protocols as a type #35

Closed aidantwoods closed 6 years ago

aidantwoods commented 6 years ago

Instead of maintaining a whitelist of allowed protocol implementations in a switch/case buried in a method, the whitelist is now in ParagonIE\Paseto\ProtocolCollection::WHITELIST.

Also make protocol version validation implicit in the construction of a ProtocolCollection, so that invalid nonsense protocol header strings just fail to construct a ProtocolInterface (instead of trying to validate the string values everywhere they are used).

aidantwoods commented 6 years ago

The general idea of this is to have a strong type for the protocol version and whitelisting used internally. It might be preferable to relax this back to accepting a string at the public API border for usability reasons though.

aidantwoods commented 6 years ago

Friendly two week ping/reminder :)

cc @paragonie-scott