graphql-auth 0.4.2 → 0.5.0
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 +4 -4
- data/README.md +15 -11
- data/app/graphql/mutations/auth/reset_password.rb +8 -5
- data/app/graphql/types/auth/error.rb +4 -0
- data/lib/graphql-auth/version.rb +1 -1
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4644807dbf31e492493dbd4b6f73b38dbb8679cb4fcafd4bf83d6500724b95cb
|
4
|
+
data.tar.gz: 55b894b9f28c87b71196bc877f43f0f65cfdc089e4d888d76a0cbd96afc65273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64709cf08a8c9e8b2ab3346e883751540adf3eb1ee558e8dd6432a458779a96cd57191e8c1a2f3ebf0f6c7fc2fbc76d94d9e415a8eff8f5a94e090a964d69a3e
|
7
|
+
data.tar.gz: b0082ca1eba339aa94ff3ea0fa68d3af20142063a313f0b991806cf93190d2270c408454f084825ea07b0902bd32c8a10dc06322e94bdbc59f2e11b7580e8281
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# GraphQL Auth
|
2
2
|
|
3
3
|
[](https://travis-ci.org/o2web/graphql-auth) [](https://codeclimate.com/github/o2web/graphql-auth/maintainability)
|
4
|
+
[](https://rubygems.org/gems/graphql-auth)
|
5
|
+
[](https://rubygems.org/gems/graphql-auth)
|
4
6
|
|
5
|
-
|
7
|
+
This gem provides an authentication mechanism on a GraphQL API. It use JSON Web Token (JWT) and Devise logic.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -32,7 +34,7 @@ Make sure to read all configurations present inside the file and fill them with
|
|
32
34
|
|
33
35
|
Use Devise with a User model and skip all route
|
34
36
|
|
35
|
-
```
|
37
|
+
```ruby
|
36
38
|
Rails.application.routes.draw do
|
37
39
|
devise_for :users, skip: :all
|
38
40
|
end
|
@@ -49,14 +51,14 @@ APP_URL=
|
|
49
51
|
|
50
52
|
Make sure the `Authorization` header is allowed in your api
|
51
53
|
|
52
|
-
```
|
54
|
+
```ruby
|
53
55
|
Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
54
56
|
allow do
|
55
57
|
origins '*'
|
56
58
|
resource '*',
|
57
|
-
headers: %w(Authorization),
|
59
|
+
headers: %w(Authorization Expires RefreshToken),
|
58
60
|
methods: :any,
|
59
|
-
expose: %w(Authorization),
|
61
|
+
expose: %w(Authorization Expires RefreshToken),
|
60
62
|
max_age: 600
|
61
63
|
end
|
62
64
|
end
|
@@ -64,7 +66,7 @@ end
|
|
64
66
|
|
65
67
|
Make sure to include `Graphql::AuthHelper` in your `GraphqlController`. A context method returning the current_user will be available
|
66
68
|
|
67
|
-
```
|
69
|
+
```ruby
|
68
70
|
class GraphqlController < ActionController::API
|
69
71
|
|
70
72
|
include Graphql::AuthHelper
|
@@ -81,7 +83,7 @@ class GraphqlController < ActionController::API
|
|
81
83
|
|
82
84
|
Make sure to implement `GraphqlAuth` in your `MutationType` to make auth mutations available
|
83
85
|
|
84
|
-
```
|
86
|
+
```ruby
|
85
87
|
class Types::MutationType < Types::BaseObject
|
86
88
|
implements ::Types::GraphqlAuth
|
87
89
|
end
|
@@ -91,16 +93,18 @@ end
|
|
91
93
|
|
92
94
|
If you can to customize any mutation, make sure to update the configurations
|
93
95
|
|
94
|
-
```
|
96
|
+
```ruby
|
95
97
|
GraphQL::Auth.configure do |config|
|
96
98
|
# config.token_lifespan = 4.hours
|
97
99
|
# config.jwt_secret_key = ENV['JWT_SECRET_KEY']
|
98
100
|
# config.app_url = ENV['APP_URL']
|
99
101
|
|
100
|
-
config.
|
101
|
-
|
102
|
-
...
|
102
|
+
# config.user_type = '::Types::Auth::User'
|
103
103
|
|
104
|
+
# config.sign_up_mutation = false
|
105
|
+
# config.lock_account_mutation = false
|
106
|
+
# config.unlock_account_mutation = false
|
107
|
+
end
|
104
108
|
```
|
105
109
|
|
106
110
|
## Development
|
@@ -22,12 +22,15 @@ class Mutations::Auth::ResetPassword < GraphQL::Schema::Mutation
|
|
22
22
|
if user.errors.any?
|
23
23
|
{
|
24
24
|
success: false,
|
25
|
-
errors: user.errors.messages.map
|
26
|
-
|
25
|
+
errors: user.errors.messages.map { |field, messages|
|
26
|
+
error_field = field == :reset_password_token ? :_error : field.to_s.camelize(:lower)
|
27
|
+
|
27
28
|
{
|
28
|
-
field:
|
29
|
-
message: messages.first.capitalize
|
30
|
-
|
29
|
+
field: error_field,
|
30
|
+
message: messages.first.capitalize,
|
31
|
+
details: user.errors.details.dig(field)
|
32
|
+
}
|
33
|
+
}
|
31
34
|
}
|
32
35
|
else
|
33
36
|
{
|
data/lib/graphql-auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Ferland
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,20 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.9'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.9.6
|
35
38
|
type: :runtime
|
36
39
|
prerelease: false
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
42
|
- - "~>"
|
40
43
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
44
|
+
version: '1.9'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.6
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: devise
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
195
|
- !ruby/object:Gem::Version
|
190
196
|
version: '0'
|
191
197
|
requirements: []
|
192
|
-
|
193
|
-
rubygems_version: 2.7.6
|
198
|
+
rubygems_version: 3.0.3
|
194
199
|
signing_key:
|
195
200
|
specification_version: 4
|
196
201
|
summary: GraphQL + JWT + Devise
|