Module: JsonWebToken::Jws
- Defined in:
- lib/json_web_token/jws.rb
Constant Summary collapse
- MESSAGE_SIGNATURE_PARTS =
3
Class Method Summary collapse
- .message_signature(header, payload, key) ⇒ Object
- .unsecured_jws(header, payload) ⇒ Object
- .validate(jws, algorithm, key = nil) ⇒ Object
Class Method Details
.message_signature(header, payload, key) ⇒ Object
14 15 16 17 18 |
# File 'lib/json_web_token/jws.rb', line 14 def (header, payload, key) alg = alg_parameter(header) data = signing_input(header, payload) "#{data}.#{signature(alg, key, data)}" end |
.unsecured_jws(header, payload) ⇒ Object
28 29 30 31 |
# File 'lib/json_web_token/jws.rb', line 28 def unsecured_jws(header, payload) fail("Invalid 'alg' header parameter") unless alg_parameter(header) == 'none' "#{signing_input(header, payload)}." # note trailing '.' end |
.validate(jws, algorithm, key = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/json_web_token/jws.rb', line 21 def validate(jws, algorithm, key = nil) compare_alg(jws, algorithm) return jws if algorithm == 'none' signature_valid?(jws, algorithm, key) ? jws : 'Invalid' end |