Sha256: 42c49b399f4d21f2ef31dd194da813979574ff3f8d0ca42d7d46fdd9c61cb13a

Contents?: true

Size: 412 Bytes

Versions: 7

Compression:

Stored size: 412 Bytes

Contents

module Commons
  module Authentication
    class JSONWebToken
      SECRET_KEY = Commons.secret_key_base.to_s

      def self.encode(payload, exp = 24.hours.from_now)
        payload[:expires_at] = exp.to_i
        JWT.encode(payload, SECRET_KEY)
      end

      def self.decode(token)
        decoded = JWT.decode(token, SECRET_KEY)[0]
        HashWithIndifferentAccess.new decoded
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.15.0 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.12.0 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.11.3 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.11.2 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.11.1 lib/commons/authentication/json_web_token.rb
commons_yellowme-0.11.0 lib/commons/authentication/json_web_token.rb