Class: Rack::PrxAuth::Certificate
- Inherits:
-
Object
- Object
- Rack::PrxAuth::Certificate
- Defined in:
- lib/rack/prx_auth/certificate.rb
Constant Summary collapse
- EXPIRES_IN =
43200
- DEFAULT_CERT_LOC =
URI('https://id.prx.org/api/v1/certs')
Instance Attribute Summary collapse
-
#cert_location ⇒ Object
readonly
Returns the value of attribute cert_location.
Instance Method Summary collapse
-
#initialize(cert_uri = nil) ⇒ Certificate
constructor
A new instance of Certificate.
- #valid?(token) ⇒ Boolean
Constructor Details
#initialize(cert_uri = nil) ⇒ Certificate
Returns a new instance of Certificate.
12 13 14 |
# File 'lib/rack/prx_auth/certificate.rb', line 12 def initialize(cert_uri = nil) @cert_location = cert_uri.nil? ? DEFAULT_CERT_LOC : URI(cert_uri) end |
Instance Attribute Details
#cert_location ⇒ Object (readonly)
Returns the value of attribute cert_location.
10 11 12 |
# File 'lib/rack/prx_auth/certificate.rb', line 10 def cert_location @cert_location end |
Instance Method Details
#valid?(token) ⇒ Boolean
16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/prx_auth/certificate.rb', line 16 def valid?(token) begin JSON::JWT.decode(token, public_key) rescue JSON::JWT::VerificationFailed false else true end end |