graphql-auth 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ce2f9bb33a4c20dcb1d1b43ef8dfcdc2f81e781
4
- data.tar.gz: b5d3237050911410dee11cfa3c6690527a6742d2
3
+ metadata.gz: 79461c41709c7d56994651702a94ee154dd0bc20
4
+ data.tar.gz: b6239eef62073916eda2bccbc61be0b9f6f283b7
5
5
  SHA512:
6
- metadata.gz: 3078cb321ac833dc34314a7ba6027602f7392d9e694e42a35eb46f1dd21ee1f5fe060f88183cbf9e876ae4a3e1d51e5e7361e2c0137d1be1b1b3749f0a2dd912
7
- data.tar.gz: 9afb297a06f9e06d814e00b8845777ca14b48a9ac6267393749e95ee3a3cfe6a655e3619a640f07a4db9a2baa5883cb809592732b574182ac33c18059dd74c36
6
+ metadata.gz: b6a68be89825e75ac22efbfa606e2fd4bc1c23b1f786d70c4d1e5161917a1807ab963d33ed654315714ad6885ff433cdcceef898bd1bdda22aa6383bb0a9b334
7
+ data.tar.gz: 97c97beb3238267fdb598b5ef5ffc304b901626b0fd61a3f0f5e54a56c1198e96a6d2429b8441c94671b3f9d555757ba63a767a659a271df6e9c7890f2f6c3bb
@@ -6,15 +6,17 @@ module GraphQL
6
6
  class JwtManager
7
7
  ALGORITHM = 'HS256'
8
8
  TYPE = 'Bearer'
9
-
9
+
10
10
  class << self
11
- def issue(payload)
12
- token = JWT.encode payload.merge(expiration),
11
+ def issue(payload, set_expiration = true)
12
+ payload.merge!(expiration) if set_expiration.present?
13
+
14
+ token = JWT.encode payload,
13
15
  auth_secret,
14
16
  ALGORITHM
15
17
  set_type token
16
18
  end
17
-
19
+
18
20
  def decode(token)
19
21
  token = extract_token token
20
22
  decrypted_token = JWT.decode token,
@@ -25,7 +27,7 @@ module GraphQL
25
27
  end
26
28
 
27
29
  private
28
-
30
+
29
31
  def auth_secret
30
32
  GraphQL::Auth.configuration.jwt_secret_key
31
33
  end
@@ -37,7 +39,7 @@ module GraphQL
37
39
  def extract_token(token)
38
40
  token.gsub "#{TYPE} ", ''
39
41
  end
40
-
42
+
41
43
  def expiration
42
44
  exp = Time.now.to_i + GraphQL::Auth.configuration.token_lifespan
43
45
  { exp: exp }
@@ -1,5 +1,3 @@
1
- require 'jwt'
2
-
3
1
  module GraphQL
4
2
  module Auth
5
3
  class ResetPassword
data/lib/graphql-auth.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'devise'
1
2
  require 'graphql-auth/configuration'
2
3
  require 'graphql-auth/engine'
3
4
  require 'graphql-auth/reset_password'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Ferland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler