Module: RobustServerSocket::SecureToken::Decrypt
- Defined in:
- lib/robust_server_socket/secure_token/decrypt.rb
Class Method Summary collapse
- .call(token) ⇒ Object
-
.clear_private_key_cache! ⇒ Object
Clear cached private key (useful for hot reloading in development).
Class Method Details
.call(token) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/robust_server_socket/secure_token/decrypt.rb', line 10 def call(token) unless token.is_a?(String) && token.match?(BASE64_REGEXP) raise InvalidToken, 'Invalid token format' end decoded_token = ::Base64.strict_decode64(token) if decoded_token.bytesize > 1024 raise InvalidToken, 'Token too large' end private_key.private_decrypt(decoded_token, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING).force_encoding('UTF-8') rescue ::OpenSSL::PKey::RSAError, ArgumentError raise InvalidToken, 'Invalid token' end |
.clear_private_key_cache! ⇒ Object
Clear cached private key (useful for hot reloading in development)
27 28 29 |
# File 'lib/robust_server_socket/secure_token/decrypt.rb', line 27 def clear_private_key_cache! @private_key = nil end |