gr1d99_auth 0.1.0 → 0.1.1

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: 78c4d7a3f5feff68c29429d036c4cf3e78946eca54ce2701a145666ab055f00d
4
- data.tar.gz: fe4208c0d009be7c859ffd3dbb8f89b64038e6ffaf5daff7d04bdebf0a6417ec
3
+ metadata.gz: 8f6da760779a1c0c0805df4f978ceed97504dd0c3c48924be8f4979843fba109
4
+ data.tar.gz: 6bf45d76781f8e2c6abea48f6cf0c00254057ca2dda91dda2c1b31d182021b9f
5
5
  SHA512:
6
- metadata.gz: 7cbe9217f2287e2f1e5e2e66d064d1713b9469fc88c67d247dc7b8e31a6b538bfb9373118811fa33ae40590aaa3cdf41dd8d076c226fa2f9f6000c4c065d83ae
7
- data.tar.gz: a2b7f68212fe05f06fafd3066ff29b5d4074b01821dff0474c7da121c3aaa9809723ce4ce047c15ee2fff951f930ad3a82ce516e079e68ffc9887f51dbf2b4a4
6
+ metadata.gz: 261b67b6bd0a56190c35f4c2cc1843b17d0c03871ba26ef10b3e67154a6f1606153a8e77ff57d9b1c0a23d10edaf129831e2475dfcbeeda1244cb75fe6081c73
7
+ data.tar.gz: 2ed232416cfe8a598cab8df8ef2318f9677cfe3c000ff8ffc0b48ae63a1f0d3ee2f339e673ba2bb7e19a4609325e180e3d6689f8846459edd640dd87fe32a13f
data/README.md CHANGED
@@ -22,7 +22,46 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### Rails
26
+ 1. Add `gem 'gr1d99_auth'` to your gemfile
27
+ 2. Create a file named `gr1d99_auth.rb` in **config/initializers** directory and add required configurations.
28
+
29
+ It is worth noting that `gr1d99_auth` gem offers minimal configurations to enable the gem to work correctly.
30
+
31
+ These configurations are:
32
+ 1. **jwt_key** - this is just a random string that will be used to encode/decode jwt
33
+ 2. **jwt_verify** - value can either be **true** or **false**, this specifies whether the jwt should be verified during decoding.
34
+ 3. **jwt_algorithm** - specify the algorithm that should be used, currently the tested algorithms and verified that they work correctly is `HS512` and `HS256`, you are highly recommended to use any of them.
35
+ 4. **jwt_exp** - specify the time in seconds that the token should be valid
36
+ 5. **time_zone** - this ensures that the `jwt_exp` is set appropriately.
37
+
38
+ example:
39
+ in **config/initializers/gr1d99_auth.rb** you would typically have this setup.
40
+
41
+ ```ruby
42
+ Gr1d99Auth.configure do |config|
43
+ config.jwt_key = "my-jwt-key"
44
+ config.jwt_verify = true
45
+ config.jwt_algorithm = 'HS512'
46
+ config.jwt_exp = 3600
47
+ config.time_zone = "Africa/Nairobi"
48
+ end
49
+ ```
50
+ 3. In your controller, typically `authentication_controller.rb`, you would encode your payload by
51
+ ```ruby
52
+ payload = { id: user.id, email: user.email, roles: user.roles.pluck(:name) }
53
+ Gr1d99Auth::JWT.encode(payload)
54
+ ```
55
+ 4. To decode token
56
+ ```ruby
57
+ token = response.headers["HTTP_X_ACCESS_TOKEN"]
58
+ Gr1d99Auth::JWT.decode(token)
59
+ ```
60
+
61
+ 5. You should also handle errors raised during decoding, these errors are.
62
+ 1. `JWT::DecodeError`
63
+ 2. `JWT::VerificationError`
64
+ 3. `JWT::IncorrectAlgorithm`
26
65
 
27
66
  ## Development
28
67
 
Binary file
@@ -1,3 +1,3 @@
1
1
  module Gr1d99Auth
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gr1d99_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gideon Kimutai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-08 00:00:00.000000000 Z
11
+ date: 2019-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -98,6 +98,7 @@ files:
98
98
  - Rakefile
99
99
  - bin/console
100
100
  - bin/setup
101
+ - gr1d99_auth-0.1.0.gem
101
102
  - gr1d99_auth.gemspec
102
103
  - lib/gr1d99_auth.rb
103
104
  - lib/gr1d99_auth/configuration.rb