rails_jwt_auth 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -11
- data/lib/rails_jwt_auth/spec_helpers.rb +1 -1
- data/lib/rails_jwt_auth/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce38e7a38fa015a6dbf8b1504e41fd273cf3646d0b2d9053c63476d55b3c729
|
4
|
+
data.tar.gz: 9581d2075661754ed5d43f3a344c8d3fd0da631b9b5c8ea8e51b65fa14bb2c33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0bdc862727abcdc1db5d1a3e00bd124b7ac15e45d47e483b8487ba46854dfc68edda3a1dcef1d5cda55fb733840f7679f2bbd03996cae3ee4e775d0f12f5a5d
|
7
|
+
data.tar.gz: 58cd478adf9a9145fb33e7f531e8010faa6e68f86243478515333acc9aa5578531f047ca059620ae1ce867cff8fbbf7a03de5ceb81e30ede35b9d8360e5392b6
|
data/README.md
CHANGED
@@ -5,9 +5,26 @@
|
|
5
5
|
|
6
6
|
Rails-API authentication solution based on JWT and inspired by Devise.
|
7
7
|
|
8
|
-
This is documentation for version `1.x`. If you are using `0.x` version use this
|
8
|
+
> This is documentation for version `1.x`. If you are using `0.x` version use this
|
9
9
|
[link](https://github.com/rjurado01/rails_jwt_auth/tree/0.x)
|
10
10
|
|
11
|
+
## Table of Contents
|
12
|
+
|
13
|
+
- [Installation](#installation)
|
14
|
+
- [Configuration](#configuration)
|
15
|
+
- [Modules](#modules)
|
16
|
+
- [ORMs support](#orms-support)
|
17
|
+
- [Controller helpers](#controller-helpers)
|
18
|
+
- [Default Controllers API](#default-controllers-api)
|
19
|
+
- [Customize]()
|
20
|
+
+ [Controllers](#custom-controllers)
|
21
|
+
+ [Payload](#custom-payload)
|
22
|
+
+ [Responses](#custom-responses)
|
23
|
+
+ [Strong parameters](#custom-strong-parameters)
|
24
|
+
- [Examples](#examples)
|
25
|
+
- [Testing](#testing-rspec)
|
26
|
+
- [License](#license)
|
27
|
+
|
11
28
|
## Installation
|
12
29
|
|
13
30
|
Add this line to your application's Gemfile:
|
@@ -65,6 +82,8 @@ You can edit configuration options into `config/initializers/auth_token_auth.rb`
|
|
65
82
|
|
66
83
|
## Modules
|
67
84
|
|
85
|
+
It's composed of 5 modules:
|
86
|
+
|
68
87
|
| Module | Description |
|
69
88
|
| ------------- | --------------------------------------------------------------------------------------------------------------- |
|
70
89
|
| Authenticable | Hashes and stores a password in the database to validate the authenticity of a user while signing in |
|
@@ -73,7 +92,9 @@ You can edit configuration options into `config/initializers/auth_token_auth.rb`
|
|
73
92
|
| Trackable | Tracks sign in timestamps and IP address |
|
74
93
|
| Invitable | Allows you to invite an user to your application sending an invitation mail |
|
75
94
|
|
76
|
-
|
95
|
+
## ORMs support
|
96
|
+
|
97
|
+
RailsJwtAuth support both Mongoid and ActiveRecord.
|
77
98
|
|
78
99
|
For next examples `auth_field_name` and `email_field_name` are configured to use the field `email`.
|
79
100
|
|
@@ -90,11 +111,11 @@ class User < ApplicationRecord
|
|
90
111
|
|
91
112
|
validates :email, presence: true,
|
92
113
|
uniqueness: true,
|
93
|
-
format:
|
114
|
+
format: URI::MailTo::EMAIL_REGEXP
|
94
115
|
end
|
95
116
|
```
|
96
117
|
|
97
|
-
Ensure you have executed migrate task: `rails g rails_jwt_auth:migrate` and you have uncomented all modules fields.
|
118
|
+
Ensure you have executed migrate task: `rails g rails_jwt_auth:migrate` and you have uncomented all modules fields into generated [migration file](https://github.com/rjurado01/rails_jwt_auth/blob/master/lib/generators/templates/migration.rb).
|
98
119
|
|
99
120
|
**Mongoid**
|
100
121
|
|
@@ -111,7 +132,7 @@ class User
|
|
111
132
|
|
112
133
|
validates :email, presence: true,
|
113
134
|
uniqueness: true,
|
114
|
-
format:
|
135
|
+
format: URI::MailTo::EMAIL_REGEXP
|
115
136
|
end
|
116
137
|
```
|
117
138
|
|
@@ -321,7 +342,11 @@ Invitations api is provided by `RailsJwtAuth::InvitationsController`.
|
|
321
342
|
|
322
343
|
Note: To add more fields, see "Custom strong parameters" below.
|
323
344
|
|
324
|
-
##
|
345
|
+
## Customize
|
346
|
+
|
347
|
+
RailsJwtAuth offers an easy way to customize certain parts.
|
348
|
+
|
349
|
+
### Custom controllers
|
325
350
|
|
326
351
|
You can overwrite RailsJwtAuth controllers to edit actions, responses,
|
327
352
|
permitted parameters...
|
@@ -351,7 +376,7 @@ And edit route resource to use it:
|
|
351
376
|
resource :registration, controller: 'registrations', only: [:create, :update, :destroy]
|
352
377
|
```
|
353
378
|
|
354
|
-
|
379
|
+
### Custom payload
|
355
380
|
|
356
381
|
If you need edit default payload used to generate jwt you can overwrite the method `to_token_payload` into your User class:
|
357
382
|
|
@@ -369,15 +394,17 @@ class User < ApplicationRecord
|
|
369
394
|
end
|
370
395
|
```
|
371
396
|
|
372
|
-
|
397
|
+
### Custom responses
|
373
398
|
|
374
399
|
You can overwrite `RailsJwtAuth::RenderHelper` to customize controllers responses.
|
375
400
|
|
376
|
-
|
401
|
+
### Custom strong parameters
|
377
402
|
|
378
403
|
You can overwrite `RailsJwtAuth::ParamsHelper` to customize controllers strong parameters.
|
379
404
|
|
380
|
-
##
|
405
|
+
## Examples
|
406
|
+
|
407
|
+
### Edit user information
|
381
408
|
|
382
409
|
This is a controller example that allows users to edit their `email` and `password`.
|
383
410
|
|
@@ -401,7 +428,7 @@ class CurrentUserController < ApplicationController
|
|
401
428
|
end
|
402
429
|
```
|
403
430
|
|
404
|
-
|
431
|
+
### Register users with random password
|
405
432
|
|
406
433
|
This is a controller example that allows admins to register users with random password and send email to reset it.
|
407
434
|
If registration is sucess it will send email to `set_password_url` with reset password token.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_jwt_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rjurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '6.1'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '5.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6.1'
|
55
61
|
description: Rails authentication solution based on Warden and JWT and inspired by
|
56
62
|
Devise.
|
57
63
|
email:
|
@@ -113,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
119
|
version: '0'
|
114
120
|
requirements: []
|
115
121
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.7.
|
122
|
+
rubygems_version: 2.7.3
|
117
123
|
signing_key:
|
118
124
|
specification_version: 4
|
119
125
|
summary: Rails jwt authentication.
|