auth_jwt_go 0.1.4 → 1.0.3

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
  SHA256:
3
- metadata.gz: 71bef283f2cbdb9e0c9f3673e9bb25cb0b12a195798559a8d9a615b23504c5dd
4
- data.tar.gz: e94a7581948a9d0e139bbe32f69c1415663ed7f5717dc91e9815d8cac179c3ab
3
+ metadata.gz: fd96aa8a92856e45714cb6580c1740447d1b8d054cc7f8907ac36bd4c42ce83b
4
+ data.tar.gz: 61c5cc3916812ec0d2d1c58099e148deb8d28436fa4fe344fc8fa632f619a52e
5
5
  SHA512:
6
- metadata.gz: cfeddc4a76d13d57a887d7595df65bcb8160148763518c1e4d5dd1534c2221d6aad80eef6e2c11dfb42708aad1dd8cb48db09572564deaa304594c33bd360087
7
- data.tar.gz: e69c811f444e68c1220d536012b3608a9d3740f1815ef476e20211495e5047b18c2bff4e848debd5aba88d8983aae989df562474985450e2174cc3414a17bea1
6
+ metadata.gz: ff2b43c6dc5f9ed72d98bc0ab76396a7c004be0954de183ccfb7f3989beaad28754e7ebd392d3cc0a04bfb528cca6eae3a05d8e27b4661d01fb7dbd60d5e1bb7
7
+ data.tar.gz: bb75b6a86721acdbf97473d3e4f741ef1a91a88c225ce0741020154a307a4dc360f170a731155060d0d53a4e7fd790419555a660fa325bac47bcd3738271dd39
data/README.md CHANGED
@@ -8,7 +8,7 @@ Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
10
  gem 'jwt'
11
- gem 'auth_jwt_go', '~> 0.1.4'
11
+ gem 'auth_jwt_go', '~> 1.0.0'
12
12
  ```
13
13
  And then execute:
14
14
 
Binary file
Binary file
Binary file
Binary file
@@ -1,8 +1,9 @@
1
1
  module AuthJwtGo
2
2
  class AuthorizedUser
3
3
  def initialize(fields)
4
- fields.each do |key, value|
5
- self.define_singleton_method(key.to_s.underscore) { return value }
4
+ fields.each do |k, v|
5
+ instance_variable_set("@#{k.to_s.underscore}", v)
6
+ self.class.send(:attr_accessor, k.to_s.underscore)
6
7
  end
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module AuthJwtGo
2
- VERSION = "0.1.4"
2
+ VERSION = "1.0.3"
3
3
  end
data/lib/auth_jwt_go.rb CHANGED
@@ -3,7 +3,7 @@ require 'auth_jwt_go/authorized_user'
3
3
 
4
4
  module AuthJwtGo
5
5
  class << self
6
- mattr_accessor :secret_key_api,
6
+ attr_accessor :secret_key_api,
7
7
  :secret_key_jwt,
8
8
  :algorithm,
9
9
  :class_name_model,
@@ -28,12 +28,15 @@ module AuthJwtGo
28
28
  end
29
29
 
30
30
  def decoded_tenant(http_request)
31
+ return { message: 'The jwt can not decode!!!!', error: true } unless http_request.env["HTTP_AUTHORIZATION"]
31
32
  token = http_request.env["HTTP_AUTHORIZATION"].split(' ')[1]
32
33
  decode = JWT.decode(token, AuthJwtGo::secret_key_jwt, true, { algorithm: AuthJwtGo::algorithm || 'HS256'} )
33
- return {message: 'The jwt can not decode!!!!', error: true} unless decode
34
+ return { message: 'The jwt can not decode!!!!', error: true } unless decode
34
35
  AuthJwtGo::AuthorizedUser.new(decode[0])
35
- rescue JWT::DecodeError
36
- nil
36
+ rescue JWT::DecodeError => e
37
+ { message: "JWT::DecodeError => #{e.to_s}", error: true }
38
+ rescue JWT::ExpiredSignature => e
39
+ { message: "JWT::ExpiredSignature => #{e.to_s}", error: true }
37
40
  end
38
41
 
39
42
  def encode_token(payload)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_jwt_go
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jonathan rojas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: this authenticates your api with jwt include current_user helper
14
14
  email:
@@ -35,6 +35,10 @@ files:
35
35
  - auth_jwt_go-0.1.1.gem
36
36
  - auth_jwt_go-0.1.2.gem
37
37
  - auth_jwt_go-0.1.3.gem
38
+ - auth_jwt_go-0.1.4.gem
39
+ - auth_jwt_go-1.0.0.gem
40
+ - auth_jwt_go-1.0.1.gem
41
+ - auth_jwt_go-1.0.2.gem
38
42
  - auth_jwt_go.gemspec
39
43
  - bin/console
40
44
  - bin/setup
@@ -63,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
67
  - !ruby/object:Gem::Version
64
68
  version: '0'
65
69
  requirements: []
66
- rubygems_version: 3.0.6
70
+ rubygems_version: 3.0.8
67
71
  signing_key:
68
72
  specification_version: 4
69
73
  summary: Auth API with Jwt include current_user helper