Module: Rack::Jwt::Auth::AuthToken

Defined in:
lib/rack/jwt/auth/auth_token.rb

Class Method Summary collapse

Class Method Details

.issue_token(payload, secret) ⇒ Object

Note: this method is only used by specs



8
9
10
# File 'lib/rack/jwt/auth/auth_token.rb', line 8

def self.issue_token(payload, secret)
  JWT.encode(payload, secret, 'HS256')
end

.valid?(token, secret, opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
# File 'lib/rack/jwt/auth/auth_token.rb', line 12

def self.valid?(token, secret, opts = {})
  begin
    JWT.decode(token, secret, true, opts)
  rescue
    false
  end
end