Sha256: 5711386e2a19661c767a46419b1457f55547b6c6727f0bec80f0bf08f5da00b7

Contents?: true

Size: 362 Bytes

Versions: 11

Compression:

Stored size: 362 Bytes

Contents

require 'jwt'

module Mks
  module Auth
    class TokenAuth
      def self.issue(payload)
        JWT.encode(payload, auth_secret, 'HS256')
      end

      def self.decode(token)
        JWT.decode(token, auth_secret, true, algorithm: 'HS256').first
      end

      def self.auth_secret
        Rails.application.config.auth_secret
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mks_auth-1.0.14 lib/mks/auth/token_auth.rb
mks_auth-1.0.13 lib/mks/auth/token_auth.rb
mks_auth-1.0.12 lib/mks/auth/token_auth.rb
mks_auth-1.0.11 lib/mks/auth/token_auth.rb
mks_auth-1.0.10 lib/mks/auth/token_auth.rb
mks_auth-1.0.9 lib/mks/auth/token_auth.rb
mks_auth-1.0.8 lib/mks/auth/token_auth.rb
mks_auth-1.0.7 lib/mks/auth/token_auth.rb
mks_auth-1.0.6 lib/mks/auth/token_auth.rb
mks_auth-1.0.5 lib/mks/auth/token_auth.rb
mks_auth-1.0.4 lib/mks/auth/token_auth.rb