groovestack-auth 0.1.5 → 0.1.6
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/Gemfile +8 -1
- data/Gemfile.lock +120 -20
- data/{lib/groovestack/auth/action_cable.rb → app/channels/groovestack/auth/action_cable/connection.rb} +2 -2
- data/app/controllers/concerns/groovestack/auth/graphql/controllers/auth_helpers.rb +69 -0
- data/app/controllers/concerns/groovestack/auth/graphql/controllers/authed_execute.rb +16 -0
- data/app/controllers/groovestack/auth/authenticated_api_controller.rb +10 -0
- data/app/controllers/groovestack/auth/omniauth_callbacks_controller.rb +138 -0
- data/app/controllers/groovestack/auth/passwordless/magic_links_controller.rb +58 -0
- data/app/controllers/groovestack/auth/passwordless/sessions_controller.rb +75 -0
- data/app/graphql/graphql/identity_extensions.rb +11 -0
- data/app/graphql/graphql/user_extensions.rb +14 -0
- data/app/models/concerns/groovestack/auth/authorized_fields_for_serialization.rb +21 -0
- data/app/models/concerns/groovestack/auth/identity.rb +39 -0
- data/app/models/concerns/groovestack/auth/user.rb +14 -0
- data/app/views/devise/mailer/magic_link.html.erb +9 -0
- data/config/initializers/core_config.rb +0 -6
- data/config/initializers/devise.rb +387 -302
- data/config/initializers/omniauth.rb +0 -19
- data/config/locales/devise.en.yml +71 -0
- data/db/migrate/20231103174050_add_devise_to_users_and_identities.rb +59 -0
- data/groovestack-auth.gemspec +7 -7
- data/lib/groovestack/auth/{railtie.rb → engine.rb} +13 -2
- data/lib/groovestack/auth/graphql/authorized_field.rb +19 -0
- data/lib/groovestack/auth/graphql/authorized_object.rb +11 -0
- data/lib/groovestack/auth/graphql/schema_visibility.rb +40 -0
- data/lib/groovestack/auth/graphql/visible_field.rb +21 -0
- data/lib/groovestack/auth/graphql/visible_object.rb +17 -0
- data/lib/groovestack/auth/passwordless/t_otp_tokenizer.rb +89 -0
- data/lib/groovestack/auth/provider.rb +7 -0
- data/lib/groovestack/auth/providers/apple.rb +5 -5
- data/lib/groovestack/auth/providers/facebook.rb +17 -0
- data/lib/groovestack/auth/providers/google.rb +1 -1
- data/lib/groovestack/auth/providers/omni_auth.rb +2 -2
- data/lib/groovestack/auth/routes.rb +26 -0
- data/lib/groovestack/auth/settings.rb +43 -0
- data/lib/groovestack/auth/version.rb +1 -1
- data/lib/groovestack/auth.rb +33 -83
- metadata +55 -50
- data/config/initializers/devise_token_auth.rb +0 -72
- data/config/initializers/graphql_devise.rb +0 -58
- data/config/routes.rb +0 -11
- data/db/migrate/20231103172517_create_users.rb +0 -54
- data/db/migrate/20231103174037_create_identities.rb +0 -19
- data/lib/fabricators/user_fabricator.rb +0 -17
- data/lib/graphql/identity/filter.rb +0 -13
- data/lib/graphql/identity/mutations.rb +0 -27
- data/lib/graphql/identity/queries.rb +0 -25
- data/lib/graphql/identity/type.rb +0 -22
- data/lib/graphql/user/filter.rb +0 -15
- data/lib/graphql/user/mutations.rb +0 -63
- data/lib/graphql/user/queries.rb +0 -40
- data/lib/graphql/user/type.rb +0 -30
- data/lib/groovestack/auth/authenticated_api_controller.rb +0 -13
- data/lib/groovestack/auth/omniauth_callbacks_controller.rb +0 -111
- data/lib/groovestack/auth/schema_plugin.rb +0 -19
- data/lib/identity.rb +0 -31
- data/lib/user.rb +0 -53
- data/lib/users/roles.rb +0 -42
data/lib/groovestack/auth.rb
CHANGED
@@ -1,109 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'devise'
|
4
|
+
require 'devise/passwordless'
|
5
|
+
require 'rotp'
|
5
6
|
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require 'omniauth-apple'
|
7
|
+
require 'groovestack/identities'
|
8
|
+
require 'groovestack/config'
|
9
9
|
|
10
10
|
require 'groovestack/auth/version'
|
11
|
-
require 'groovestack/auth/
|
12
|
-
|
13
|
-
|
14
|
-
# add devise and devise_token_auth app/ dirs to load path
|
15
|
-
Dir[File.join(Gem::Specification.find_by_name('devise').gem_dir, 'app', '*')].each do |sub_dir|
|
16
|
-
$LOAD_PATH.push(sub_dir)
|
17
|
-
end
|
18
|
-
Dir[File.join(Gem::Specification.find_by_name('devise_token_auth').gem_dir, 'app', '*')].each do |sub_dir|
|
19
|
-
$LOAD_PATH.push(sub_dir)
|
20
|
-
end
|
11
|
+
require 'groovestack/auth/engine' if defined?(Rails::Engine)
|
12
|
+
require 'groovestack/auth/settings'
|
13
|
+
require 'groovestack/auth/routes'
|
21
14
|
|
22
|
-
|
23
|
-
|
15
|
+
module Groovestack
|
16
|
+
module Auth
|
17
|
+
module GraphQL
|
18
|
+
autoload :AuthorizedField, 'groovestack/auth/graphql/authorized_field'
|
19
|
+
autoload :AuthorizedObject, 'groovestack/auth/graphql/authorized_object'
|
20
|
+
autoload :VisibleField, 'groovestack/auth/graphql/visible_field'
|
21
|
+
autoload :VisibleObject, 'groovestack/auth/graphql/visible_object'
|
22
|
+
autoload :SchemaVisibility, 'groovestack/auth/graphql/schema_visibility'
|
24
23
|
end
|
25
|
-
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
module Concerns
|
30
|
-
end
|
25
|
+
module Passwordless
|
26
|
+
autoload :TOtpTokenizer, 'groovestack/auth/passwordless/t_otp_tokenizer'
|
31
27
|
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
require 'users/roles'
|
36
|
-
require 'user'
|
37
|
-
require 'identity'
|
38
28
|
|
39
|
-
module GraphQL
|
40
|
-
module Identity
|
41
|
-
autoload :Type, 'graphql/identity/type'
|
42
|
-
autoload :Filter, 'graphql/identity/filter'
|
43
|
-
autoload :Queries, 'graphql/identity/queries'
|
44
|
-
autoload :Mutations, 'graphql/identity/mutations'
|
45
|
-
end
|
46
|
-
|
47
|
-
module User
|
48
|
-
autoload :Filter, 'graphql/user/filter'
|
49
|
-
autoload :Type, 'graphql/user/type'
|
50
|
-
autoload :Queries, 'graphql/user/queries'
|
51
|
-
autoload :Mutations, 'graphql/user/mutations'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
module Groovestack
|
56
|
-
module Auth
|
57
29
|
autoload :Provider, 'groovestack/auth/provider'
|
58
30
|
|
59
|
-
if defined?(GraphqlDevise)
|
60
|
-
autoload :AuthenticatedApiController, 'groovestack/auth/authenticated_api_controller'
|
61
|
-
autoload :OmniauthCallbacksController, 'groovestack/auth/omniauth_callbacks_controller'
|
62
|
-
autoload :ActionCable, 'groovestack/auth/action_cable'
|
63
|
-
autoload :SchemaPlugin, 'groovestack/auth/schema_plugin'
|
64
|
-
end
|
65
|
-
|
66
31
|
module Providers
|
67
32
|
extend ActiveSupport::Autoload
|
68
33
|
|
69
34
|
eager_autoload do
|
70
35
|
autoload :Email, 'groovestack/auth/providers/email'
|
71
|
-
|
72
|
-
|
73
|
-
|
36
|
+
if defined?(OmniAuth)
|
37
|
+
autoload :OmniAuth, 'groovestack/auth/providers/omni_auth'
|
38
|
+
autoload :Apple, 'groovestack/auth/providers/apple'
|
39
|
+
autoload :Facebook, 'groovestack/auth/providers/facebook'
|
40
|
+
autoload :Google, 'groovestack/auth/providers/google'
|
41
|
+
end
|
74
42
|
end
|
75
43
|
end
|
76
44
|
|
77
|
-
|
78
|
-
|
79
|
-
setting :disabled_providers, default: [], reader: true
|
45
|
+
include ::Groovestack::Auth::Settings
|
46
|
+
include ::Groovestack::Auth::Routes
|
80
47
|
end
|
81
48
|
end
|
82
49
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
module Auth
|
89
|
-
Provider = ::Groovestack::Auth::Provider
|
90
|
-
|
91
|
-
if defined?(GraphqlDevise)
|
92
|
-
AuthenticatedApiController = ::Groovestack::Auth::AuthenticatedApiController
|
93
|
-
OmniauthCallbacksController = ::Groovestack::Auth::OmniauthCallbacksController
|
94
|
-
ActionCable = ::Groovestack::Auth::ActionCable
|
95
|
-
SchemaPlugin = ::Groovestack::Auth::SchemaPlugin
|
96
|
-
end
|
97
|
-
|
98
|
-
module Providers
|
99
|
-
Email = ::Groovestack::Auth::Providers::Email
|
100
|
-
OmniAuth = ::Groovestack::Auth::Providers::OmniAuth
|
101
|
-
Apple = ::Groovestack::Auth::Providers::Apple
|
102
|
-
Google = ::Groovestack::Auth::Providers::Google
|
103
|
-
end
|
104
|
-
|
105
|
-
extend Dry::Configurable
|
50
|
+
# Include Auth concerns after Rails is fully loaded
|
51
|
+
ActiveSupport.on_load(:devise) do
|
52
|
+
::GraphQL::User::Type.class_eval do
|
53
|
+
include ::GraphQL::UserExtensions
|
54
|
+
end
|
106
55
|
|
107
|
-
|
56
|
+
::GraphQL::Identity::Type.class_eval do
|
57
|
+
include ::GraphQL::IdentityExtensions
|
108
58
|
end
|
109
59
|
end
|
metadata
CHANGED
@@ -1,84 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groovestack-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Schridde
|
8
|
+
autorequire:
|
8
9
|
bindir: exe
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-05-14 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
|
-
name:
|
14
|
+
name: devise
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- - "~>"
|
17
|
-
- !ruby/object:Gem::Version
|
18
|
-
version: '0.1'
|
19
17
|
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
19
|
+
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- - "~>"
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '0.1'
|
29
24
|
- - ">="
|
30
25
|
- !ruby/object:Gem::Version
|
31
|
-
version: 0
|
26
|
+
version: '0'
|
32
27
|
- !ruby/object:Gem::Dependency
|
33
|
-
name:
|
28
|
+
name: devise-passwordless
|
34
29
|
requirement: !ruby/object:Gem::Requirement
|
35
30
|
requirements:
|
36
|
-
- - "~>"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '0.1'
|
39
31
|
- - ">="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0
|
33
|
+
version: '0'
|
42
34
|
type: :runtime
|
43
35
|
prerelease: false
|
44
36
|
version_requirements: !ruby/object:Gem::Requirement
|
45
37
|
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0.1'
|
49
38
|
- - ">="
|
50
39
|
- !ruby/object:Gem::Version
|
51
|
-
version: 0
|
40
|
+
version: '0'
|
52
41
|
- !ruby/object:Gem::Dependency
|
53
|
-
name:
|
42
|
+
name: groovestack-config
|
54
43
|
requirement: !ruby/object:Gem::Requirement
|
55
44
|
requirements:
|
56
45
|
- - "~>"
|
57
46
|
- !ruby/object:Gem::Version
|
58
|
-
version: '1
|
47
|
+
version: '0.1'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.1.4
|
59
51
|
type: :runtime
|
60
52
|
prerelease: false
|
61
53
|
version_requirements: !ruby/object:Gem::Requirement
|
62
54
|
requirements:
|
63
55
|
- - "~>"
|
64
56
|
- !ruby/object:Gem::Version
|
65
|
-
version: '1
|
57
|
+
version: '0.1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.1.4
|
66
61
|
- !ruby/object:Gem::Dependency
|
67
|
-
name:
|
62
|
+
name: groovestack-identities
|
68
63
|
requirement: !ruby/object:Gem::Requirement
|
69
64
|
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.1'
|
70
68
|
- - ">="
|
71
69
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
70
|
+
version: 0.1.3
|
73
71
|
type: :runtime
|
74
72
|
prerelease: false
|
75
73
|
version_requirements: !ruby/object:Gem::Requirement
|
76
74
|
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.1'
|
77
78
|
- - ">="
|
78
79
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
80
|
+
version: 0.1.3
|
80
81
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
+
name: rotp
|
82
83
|
requirement: !ruby/object:Gem::Requirement
|
83
84
|
requirements:
|
84
85
|
- - ">="
|
@@ -104,41 +105,44 @@ files:
|
|
104
105
|
- CHANGELOG.md
|
105
106
|
- Gemfile
|
106
107
|
- Gemfile.lock
|
108
|
+
- app/channels/groovestack/auth/action_cable/connection.rb
|
109
|
+
- app/controllers/concerns/groovestack/auth/graphql/controllers/auth_helpers.rb
|
110
|
+
- app/controllers/concerns/groovestack/auth/graphql/controllers/authed_execute.rb
|
111
|
+
- app/controllers/groovestack/auth/authenticated_api_controller.rb
|
112
|
+
- app/controllers/groovestack/auth/omniauth_callbacks_controller.rb
|
113
|
+
- app/controllers/groovestack/auth/passwordless/magic_links_controller.rb
|
114
|
+
- app/controllers/groovestack/auth/passwordless/sessions_controller.rb
|
115
|
+
- app/graphql/graphql/identity_extensions.rb
|
116
|
+
- app/graphql/graphql/user_extensions.rb
|
117
|
+
- app/models/concerns/groovestack/auth/authorized_fields_for_serialization.rb
|
118
|
+
- app/models/concerns/groovestack/auth/identity.rb
|
119
|
+
- app/models/concerns/groovestack/auth/user.rb
|
120
|
+
- app/views/devise/mailer/magic_link.html.erb
|
107
121
|
- config.ru
|
108
122
|
- config/initializers/core_config.rb
|
109
123
|
- config/initializers/devise.rb
|
110
|
-
- config/initializers/devise_token_auth.rb
|
111
|
-
- config/initializers/graphql_devise.rb
|
112
124
|
- config/initializers/omniauth.rb
|
113
|
-
- config/
|
114
|
-
- db/migrate/
|
115
|
-
- db/migrate/20231103174037_create_identities.rb
|
125
|
+
- config/locales/devise.en.yml
|
126
|
+
- db/migrate/20231103174050_add_devise_to_users_and_identities.rb
|
116
127
|
- docs/apple-oauth-local-dev.adoc
|
117
128
|
- groovestack-auth.gemspec
|
118
|
-
- lib/fabricators/user_fabricator.rb
|
119
|
-
- lib/graphql/identity/filter.rb
|
120
|
-
- lib/graphql/identity/mutations.rb
|
121
|
-
- lib/graphql/identity/queries.rb
|
122
|
-
- lib/graphql/identity/type.rb
|
123
|
-
- lib/graphql/user/filter.rb
|
124
|
-
- lib/graphql/user/mutations.rb
|
125
|
-
- lib/graphql/user/queries.rb
|
126
|
-
- lib/graphql/user/type.rb
|
127
129
|
- lib/groovestack/auth.rb
|
128
|
-
- lib/groovestack/auth/
|
129
|
-
- lib/groovestack/auth/
|
130
|
-
- lib/groovestack/auth/
|
130
|
+
- lib/groovestack/auth/engine.rb
|
131
|
+
- lib/groovestack/auth/graphql/authorized_field.rb
|
132
|
+
- lib/groovestack/auth/graphql/authorized_object.rb
|
133
|
+
- lib/groovestack/auth/graphql/schema_visibility.rb
|
134
|
+
- lib/groovestack/auth/graphql/visible_field.rb
|
135
|
+
- lib/groovestack/auth/graphql/visible_object.rb
|
136
|
+
- lib/groovestack/auth/passwordless/t_otp_tokenizer.rb
|
131
137
|
- lib/groovestack/auth/provider.rb
|
132
138
|
- lib/groovestack/auth/providers/apple.rb
|
133
139
|
- lib/groovestack/auth/providers/email.rb
|
140
|
+
- lib/groovestack/auth/providers/facebook.rb
|
134
141
|
- lib/groovestack/auth/providers/google.rb
|
135
142
|
- lib/groovestack/auth/providers/omni_auth.rb
|
136
|
-
- lib/groovestack/auth/
|
137
|
-
- lib/groovestack/auth/
|
143
|
+
- lib/groovestack/auth/routes.rb
|
144
|
+
- lib/groovestack/auth/settings.rb
|
138
145
|
- lib/groovestack/auth/version.rb
|
139
|
-
- lib/identity.rb
|
140
|
-
- lib/user.rb
|
141
|
-
- lib/users/roles.rb
|
142
146
|
- readme.adoc
|
143
147
|
homepage: https://github.com/talysto/groovestack-core/
|
144
148
|
licenses: []
|
@@ -163,7 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
167
|
- !ruby/object:Gem::Version
|
164
168
|
version: '0'
|
165
169
|
requirements: []
|
166
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.3.26
|
171
|
+
signing_key:
|
167
172
|
specification_version: 4
|
168
173
|
summary: Groovestack extension for application authentication
|
169
174
|
test_files: []
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(DeviseTokenAuth)
|
4
|
-
DeviseTokenAuth.setup do |config|
|
5
|
-
# By default the authorization headers will change after each request. The
|
6
|
-
# client is responsible for keeping track of the changing tokens. Change
|
7
|
-
# this to false to prevent the Authorization header from changing after
|
8
|
-
# each request.
|
9
|
-
config.change_headers_on_each_request = false
|
10
|
-
|
11
|
-
# By default, users will need to re-authenticate after 2 weeks. This setting
|
12
|
-
# determines how long tokens will remain valid after they are issued.
|
13
|
-
# config.token_lifespan = 2.weeks
|
14
|
-
|
15
|
-
# Limiting the token_cost to just 4 in testing will increase the performance of
|
16
|
-
# your test suite dramatically. The possible cost value is within range from 4
|
17
|
-
# to 31. It is recommended to not use a value more than 10 in other environments.
|
18
|
-
config.token_cost = Rails.env.test? ? 4 : 10
|
19
|
-
|
20
|
-
# Sets the max number of concurrent devices per user, which is 10 by default.
|
21
|
-
# After this limit is reached, the oldest tokens will be removed.
|
22
|
-
# config.max_number_of_devices = 10
|
23
|
-
|
24
|
-
# Sometimes it's necessary to make several requests to the API at the same
|
25
|
-
# time. In this case, each request in the batch will need to share the same
|
26
|
-
# auth token. This setting determines how far apart the requests can be while
|
27
|
-
# still using the same auth token.
|
28
|
-
# config.batch_request_buffer_throttle = 5.seconds
|
29
|
-
|
30
|
-
# This route will be the prefix for all oauth2 redirect callbacks. For
|
31
|
-
# example, using the default '/omniauth', the github oauth2 provider will
|
32
|
-
# redirect successful authentications to '/omniauth/github/callback'
|
33
|
-
config.omniauth_prefix = '/users/auth'
|
34
|
-
|
35
|
-
config.cookie_attributes = {
|
36
|
-
expires: 10.seconds
|
37
|
-
}
|
38
|
-
|
39
|
-
# By default sending current password is not needed for the password update.
|
40
|
-
# Uncomment to enforce current_password param to be checked before all
|
41
|
-
# attribute updates. Set it to :password if you want it to be checked only if
|
42
|
-
# password is updated.
|
43
|
-
# config.check_current_password_before_update = :attributes
|
44
|
-
|
45
|
-
# By default we will use callbacks for single omniauth.
|
46
|
-
# It depends on fields like email, provider and uid.
|
47
|
-
config.default_callbacks = false
|
48
|
-
|
49
|
-
# Makes it possible to change the headers names
|
50
|
-
config.headers_names = {
|
51
|
-
authorization: 'Authorization',
|
52
|
-
'access-token': 'access-token',
|
53
|
-
client: 'client',
|
54
|
-
expiry: 'expiry',
|
55
|
-
id: 'id',
|
56
|
-
'token-type': 'token-type'
|
57
|
-
}
|
58
|
-
|
59
|
-
# Makes it possible to use custom uid column
|
60
|
-
config.other_uid = 'id'
|
61
|
-
|
62
|
-
# By default, only Bearer Token authentication is implemented out of the box.
|
63
|
-
# If, however, you wish to integrate with legacy Devise authentication, you can
|
64
|
-
# do so by enabling this flag. NOTE: This feature is highly experimental!
|
65
|
-
# config.enable_standard_devise_support = false
|
66
|
-
|
67
|
-
# By default DeviseTokenAuth will not send confirmation email, even when including
|
68
|
-
# devise confirmable module. If you want to use devise confirmable module and
|
69
|
-
# send email, set it to true. (This is a setting for compatibility)
|
70
|
-
# config.send_confirmation_email = true
|
71
|
-
end
|
72
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(GraphqlDevise)
|
4
|
-
ActiveSupport.on_load(:after_initialize) do # rubocop:disable Metrics/BlockLength
|
5
|
-
module DeviseTokenAuth
|
6
|
-
module Concerns
|
7
|
-
module ActiveRecordSupport
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
class_methods do
|
11
|
-
# Override to remove provider from attrs b/c use identity model
|
12
|
-
def dta_find_by(attrs = {})
|
13
|
-
attrs.delete(:provider)
|
14
|
-
attrs.delete('provider')
|
15
|
-
find_by(attrs)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class User < ActiveRecord::Base
|
23
|
-
# Override to remove provider from attrs b/c use identity model
|
24
|
-
def self.dta_find_by(attrs = {})
|
25
|
-
attrs.delete(:provider)
|
26
|
-
attrs.delete('provider')
|
27
|
-
find_by(attrs)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
User.include ::GraphqlDevise::Authenticatable
|
32
|
-
|
33
|
-
module AugmentedGraphqlDeviseRegisterArgs
|
34
|
-
extend ActiveSupport::Concern
|
35
|
-
|
36
|
-
included do
|
37
|
-
argument :name, String, required: true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
GraphqlDevise::Mutations::Register.include AugmentedGraphqlDeviseRegisterArgs
|
42
|
-
|
43
|
-
GraphqlDevise::Mutations::Register.class_eval do
|
44
|
-
private
|
45
|
-
|
46
|
-
def build_resource(attrs)
|
47
|
-
# NOTE: remove provider from attrs b/c use identity model
|
48
|
-
attrs.delete(:provider)
|
49
|
-
attrs[:roles] = [Users::Roles::Role::ADMIN] unless Groovestack::Config::App.generate_config[:has_admins]
|
50
|
-
resource_class.new(attrs)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
GraphqlDevise::Types::AuthenticatableType.class_eval do
|
55
|
-
field :id, GraphQL::Types::ID, null: false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/config/routes.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Groovestack::Auth::Railtie.routes.draw do
|
4
|
-
if defined?(Devise)
|
5
|
-
devise_scope :user do
|
6
|
-
match '/users/auth/:provider/callback', to: 'groovestack/auth/omniauth_callbacks#verified', via: %i[get post],
|
7
|
-
as: :omniauth_callback
|
8
|
-
get '/users/auth/failure', to: 'groovestack/auth/omniauth_callbacks#omniauth_failure', as: :omniauth_failure
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# dynamic rails major version as recommended by perplexity
|
4
|
-
class CreateUsers < ActiveRecord::Migration[Gem::Version.new(Rails.version).segments.first.to_f]
|
5
|
-
def change # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
6
|
-
create_table :users, id: :uuid do |t|
|
7
|
-
## Database authenticatable
|
8
|
-
t.string :encrypted_password, null: false, default: ''
|
9
|
-
|
10
|
-
## Recoverable
|
11
|
-
t.string :reset_password_token
|
12
|
-
t.datetime :reset_password_sent_at
|
13
|
-
t.boolean :allow_password_change, default: false, null: false
|
14
|
-
|
15
|
-
## Rememberable
|
16
|
-
t.datetime :remember_created_at
|
17
|
-
|
18
|
-
## Trackable
|
19
|
-
t.integer :sign_in_count, default: 0, null: false
|
20
|
-
t.datetime :current_sign_in_at
|
21
|
-
t.datetime :last_sign_in_at
|
22
|
-
t.inet :current_sign_in_ip
|
23
|
-
t.inet :last_sign_in_ip
|
24
|
-
|
25
|
-
## Confirmable
|
26
|
-
t.string :confirmation_token
|
27
|
-
t.datetime :confirmed_at
|
28
|
-
t.datetime :confirmation_sent_at
|
29
|
-
t.string :unconfirmed_email # Only if using reconfirmable
|
30
|
-
|
31
|
-
# Lockable
|
32
|
-
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
33
|
-
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
34
|
-
# t.datetime :locked_at
|
35
|
-
|
36
|
-
## User Info
|
37
|
-
t.string :name
|
38
|
-
t.string :email
|
39
|
-
t.jsonb :roles, null: false, default: []
|
40
|
-
t.string :language
|
41
|
-
t.string :image
|
42
|
-
|
43
|
-
## Tokens
|
44
|
-
t.json :tokens
|
45
|
-
|
46
|
-
t.timestamps
|
47
|
-
end
|
48
|
-
|
49
|
-
add_index :users, :email, unique: true
|
50
|
-
add_index :users, :reset_password_token, unique: true
|
51
|
-
add_index :users, :confirmation_token, unique: true
|
52
|
-
# add_index :users, :unlock_token, unique: true
|
53
|
-
end
|
54
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# dynamic rails major version as recommended by perplexity
|
4
|
-
class CreateIdentities < ActiveRecord::Migration[Gem::Version.new(Rails.version).segments.first.to_f]
|
5
|
-
def change
|
6
|
-
create_table :identities, id: :uuid do |t|
|
7
|
-
t.string :provider
|
8
|
-
t.string :uid
|
9
|
-
t.jsonb :omniauth_data
|
10
|
-
|
11
|
-
t.references :user, foreign_key: true, index: false, null: false, type: :uuid
|
12
|
-
|
13
|
-
t.timestamps
|
14
|
-
end
|
15
|
-
|
16
|
-
add_index :identities, %i[user_id provider], unique: true
|
17
|
-
add_index :identities, %i[provider uid], unique: true
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'fabrication'
|
4
|
-
require 'faker'
|
5
|
-
|
6
|
-
Fabricator(:user) do
|
7
|
-
name { Faker::Name.name }
|
8
|
-
password { Devise.friendly_token[0, 20] }
|
9
|
-
end
|
10
|
-
|
11
|
-
Fabricator(:user_with_email, from: :user) do
|
12
|
-
email { Faker::Internet.email }
|
13
|
-
end
|
14
|
-
|
15
|
-
Fabricator(:admin_user, from: :user_with_email) do
|
16
|
-
roles [User::Role::ADMIN]
|
17
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Identity
|
5
|
-
class Filter < ::Groovestack::Base::GraphQL::Base::InputObject
|
6
|
-
description 'Identity filter props'
|
7
|
-
|
8
|
-
argument :ids, [ID], required: false
|
9
|
-
|
10
|
-
argument :user_id, ID, required: false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Identity
|
5
|
-
module Mutations
|
6
|
-
class Delete < ::Groovestack::Base::GraphQL::Base::Mutation
|
7
|
-
argument :id, ID, required: true
|
8
|
-
|
9
|
-
type ::GraphQL::Identity::Type
|
10
|
-
|
11
|
-
def perform(id:)
|
12
|
-
identity = ::Identity.find(id)
|
13
|
-
|
14
|
-
identity.destroy!
|
15
|
-
|
16
|
-
identity
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
extend ActiveSupport::Concern
|
21
|
-
|
22
|
-
included do
|
23
|
-
field :delete_identity, mutation: ::GraphQL::Identity::Mutations::Delete, description: 'delete identity'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Identity
|
5
|
-
module Queries
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
include ::Groovestack::Base::GraphQL::Providers::ReactAdmin::Resource
|
10
|
-
|
11
|
-
react_admin_resource :identities, graphql_path: 'GraphQL'
|
12
|
-
end
|
13
|
-
|
14
|
-
def identities_scope(base_scope:, sort_field: nil, sort_order: nil, filter: {})
|
15
|
-
scope = base_scope
|
16
|
-
scope = scope.where(id: filter.ids) if filter.ids.present?
|
17
|
-
scope = scope.where(user_id: filter.user_id) if filter.user_id.present?
|
18
|
-
|
19
|
-
return scope if sort_field.blank?
|
20
|
-
|
21
|
-
scope.order({ sort_field.underscore => sort_order || 'desc' })
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module Identity
|
5
|
-
class Type < ::Groovestack::Base::GraphQL::Base::Object
|
6
|
-
description 'An identity'
|
7
|
-
|
8
|
-
graphql_name 'Identity'
|
9
|
-
|
10
|
-
field :created_at, ::GraphQL::Types::ISO8601DateTime, null: false, description: 'created at'
|
11
|
-
field :id, ID, null: false, description: 'id'
|
12
|
-
field :uid, String, null: false, description: 'uid'
|
13
|
-
field :updated_at, ::GraphQL::Types::ISO8601DateTime, null: false, description: 'updated at'
|
14
|
-
|
15
|
-
field :provider, String, null: true, description: 'provider'
|
16
|
-
|
17
|
-
# associations
|
18
|
-
|
19
|
-
field :user_id, ID, null: false, description: 'user id of the user the identity is associated with'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/graphql/user/filter.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module GraphQL
|
4
|
-
module User
|
5
|
-
class Filter < ::Groovestack::Base::GraphQL::Base::InputObject
|
6
|
-
description 'User filter props'
|
7
|
-
|
8
|
-
argument :ids, [ID], required: false
|
9
|
-
argument :q, String, required: false
|
10
|
-
|
11
|
-
argument :name, String, required: false
|
12
|
-
argument :roles, [String], required: false
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|