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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cda828e6471bc07f03c6c52fb0ad1e400a6132f0c5120487182138f684f8dd8
4
- data.tar.gz: 51978e4c36db6c525de7a1bb475ed43794b5f02c8fdd50be4d4a1364846ec77d
3
+ metadata.gz: 4644807dbf31e492493dbd4b6f73b38dbb8679cb4fcafd4bf83d6500724b95cb
4
+ data.tar.gz: 55b894b9f28c87b71196bc877f43f0f65cfdc089e4d888d76a0cbd96afc65273
5
5
  SHA512:
6
- metadata.gz: 103daa42a53f9e04dde07b429fe87c4bced53a637373982e895bd0febdaf9e768e3b73f0736344668b278cadf9e7e323106b79c3ab40b26be2b8d705b85e121c
7
- data.tar.gz: 06015ba1ebb9bea99f13c3fd9787123e1c5cfe7c0700aa91688a114b4a8a7bd60e615077fe2efc4e1fd9a450b36f12503a541fdc616584434b4328b8b5216a52
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
  [![Build Status](https://travis-ci.org/o2web/graphql-auth.svg?branch=master)](https://travis-ci.org/o2web/graphql-auth) [![Maintainability](https://api.codeclimate.com/v1/badges/7e2515bb59f0b205a603/maintainability)](https://codeclimate.com/github/o2web/graphql-auth/maintainability)
4
+ [![Downloads](https://img.shields.io/gem/dt/graphql-auth.svg)](https://rubygems.org/gems/graphql-auth)
5
+ [![Latest Version](https://img.shields.io/gem/v/graphql-auth.svg)](https://rubygems.org/gems/graphql-auth)
4
6
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/graphql-auth`. To experiment with that code, run `bin/console` for an interactive prompt.
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.sign_in_mutation = ::Mutations::CustomSignIn
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 do |field, messages|
26
- field = field == :reset_password_token ? :_error : field.to_s.camelize(:lower)
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: field,
29
- message: messages.first.capitalize }
30
- end
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
  {
@@ -10,4 +10,8 @@ class Types::Auth::Error < GraphQL::Schema::Object
10
10
  field :message, String, null: false do
11
11
  description 'Error message'
12
12
  end
13
+
14
+ field :details, GraphQL::Types::JSON, null: true do
15
+ description 'Error details'
16
+ end
13
17
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Auth
3
- VERSION = '0.4.2'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
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.2
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-03-21 00:00:00.000000000 Z
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.8'
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.8'
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
- rubyforge_project:
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